/usr/share/pyshared/paste/webkit/FakeWebware/MiscUtils/ParamFactory.py is in python-pastewebkit 1.0-7build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | from threading import Lock
class ParamFactory:
def __init__(self, klass, **extraMethods):
self.lock = Lock()
self.cache = {}
self.klass = klass
for name, func in extraMethods.items():
setattr(self, name, func)
def __call__(self, *args):
self.lock.acquire()
if not self.cache.has_key(args):
value = self.klass(*args)
self.cache[args] = value
self.lock.release()
return value
else:
self.lock.release()
return self.cache[args]
def allInstances(self):
return self.cache.values()
|