On Fri, Jun 11, 2010 at 7:34 PM, Patryk Zawadzki <pat...@pld-linux.org> wrote: > Maybe something simpler?
Actually you might want to have a couple of instances with different __init__ params: ---- 8< ---- from threading import local, Thread class View(object): _child = local() def __new__(cls, *args, **kwargs): if not hasattr(cls._child, 'dict'): cls._child.dict = {} param_hash = (args, tuple(kwargs.items())) existing = cls._child.dict.get(param_hash, None) if not existing: print 'first time in this thread with args', param_hash cls._child.dict[param_hash] = super(View, cls).__new__(cls) return cls._child.dict[param_hash] def __call__(self, foo): print 'call', id(self), foo return 'bar' -- Patryk Zawadzki -- You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-develop...@googlegroups.com. To unsubscribe from this group, send email to django-developers+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.