0001-decorators-allow-cache-decorators-to-vary-on-a-subse.patch
src/authentic2/decorators.py | ||
---|---|---|
119 | 119 |
return cls(**kwargs)(args[0]) |
120 | 120 |
return super(CacheDecoratorBase, cls).__new__(cls, *args, **kwargs) |
121 | 121 | |
122 |
def __init__(self, timeout=None, hostname_vary=True): |
|
122 |
def __init__(self, timeout=None, hostname_vary=True, args=None, |
|
123 |
kwargs=None): |
|
123 | 124 |
self.timeout = timeout |
124 | 125 |
self.hostname_vary = hostname_vary |
126 |
self.args = args |
|
127 |
self.kwargs = kwargs |
|
125 | 128 | |
126 | 129 |
def set(self, key, value): |
127 | 130 |
raise NotImplementedError |
... | ... | |
160 | 163 |
# if we cannot determine the hostname it's better to ignore the |
161 | 164 |
# cache |
162 | 165 |
raise CacheUnusable |
163 |
for arg in args: |
|
166 |
for i, arg in enumerate(args): |
|
167 |
if self.args and i not in self.args: |
|
168 |
continue |
|
164 | 169 |
parts.append(unicode(arg)) |
170 | ||
165 | 171 |
for kw, arg in sorted(kwargs.iteritems(), key=lambda x: x[0]): |
172 |
if self.kwargs in kw not in self.kwargs: |
|
173 |
continue |
|
166 | 174 |
parts.append(u'%s-%s' % (unicode(kw), unicode(arg))) |
167 | 175 |
return u'|'.join(parts) |
168 | 176 | |
169 |
- |