It seems like threading.local is more straightforward and more robust.
+1
A:
Because threading.local
is new in Python 2.4. The StackedObjectProxy
uses threading.local if it can.
THC4k
2009-11-06 10:53:49
Python 2.4 came out in 2004 so I'm not sure "new" is the right word.
Dave Webb
2009-11-06 11:27:48
I'm just kind of quoting http://docs.python.org/library/threading.html#threading.local ;-)
THC4k
2009-11-06 12:14:17
+1
A:
StackedObjectProxy uses a threading.local underneath it. Pylons doesn't use plain threading.locals for 2 reasons:
1) it'd be a more intrusive API than a proxy. E.g. request().POST.get('file') vs request.POST.get('file')
2) StackedObjectProxys are not only thread safe, but also "request safe" -- meaning it's safe for a Pylons application to be embedded in another and reference the same proxy objects. The need for this kind of safety is rare, but is certainly a possibility with how easy it is for WSGI apps to call other WSGI apps + the use of global objects
See the paste.registry docs for more information
Philip Jenvey
2009-11-11 19:12:42