/opt/alt/python37/lib/python3.7/site-packages/paste
NameSizeModeActions
auth/-0755rm
cowbell/-0755rm
debug/-0755rm
evalexception/-0755rm
exceptions/-0755rm
util/-0755rm
__pycache__/-0755rm
cascade.py45080644editdlrm
cascade.pyc44750644editdlrm
cascade.pyo44750644editdlrm
cgiapp.py95900644editdlrm
cgiapp.pyc85540644editdlrm
cgiapp.pyo83370644editdlrm
cgitb_catcher.py37520644editdlrm
cgitb_catcher.pyc38510644editdlrm
cgitb_catcher.pyo38510644editdlrm
config.py43120644editdlrm
config.pyc52840644editdlrm
config.pyo52840644editdlrm
errordocument.py137770644editdlrm
errordocument.pyc130800644editdlrm
errordocument.pyo130800644editdlrm
fileapp.py136080644editdlrm
fileapp.pyc133520644editdlrm
fileapp.pyo132180644editdlrm
fixture.py579920644editdlrm
fixture.py.stdlib580750644editdlrm
fixture.pyc607260644editdlrm
fixture.pyo584530644editdlrm
flup_session.py39410644editdlrm
flup_session.pyc39590644editdlrm
flup_session.pyo39590644editdlrm
gzipper.py36920644editdlrm
gzipper.pyc45780644editdlrm
gzipper.pyo45780644editdlrm
httpexceptions.py242220644editdlrm
httpexceptions.pyc283800644editdlrm
httpexceptions.pyo276230644editdlrm
httpheaders.py430900644editdlrm
httpheaders.pyc452740644editdlrm
httpheaders.pyo439740644editdlrm
httpserver.py556620644editdlrm
httpserver.pyc486610644editdlrm
httpserver.pyo479990644editdlrm
lint.py149990644editdlrm
lint.pyc178890644editdlrm
lint.pyo137720644editdlrm
modpython.py79760644editdlrm
modpython.pyc89530644editdlrm
modpython.pyo89530644editdlrm
pony.py22790644editdlrm
pony.pyc27530644editdlrm
pony.pyo27530644editdlrm
progress.py81620644editdlrm
progress.pyc94160644editdlrm
progress.pyo94160644editdlrm
proxy.py101810644editdlrm
proxy.pyc87870644editdlrm
proxy.pyo87870644editdlrm
recursive.py146640644editdlrm
recursive.pyc181410644editdlrm
recursive.pyo178160644editdlrm
registry.py221930644editdlrm
registry.pyc229410644editdlrm
registry.pyo229410644editdlrm
reloader.py60100644editdlrm
reloader.pyc61340644editdlrm
reloader.pyo61340644editdlrm
request.py141450644editdlrm
request.pyc140650644editdlrm
request.pyo139690644editdlrm
response.py76590644editdlrm
response.pyc94680644editdlrm
response.pyo93840644editdlrm
session.py113350644editdlrm
session.pyc120530644editdlrm
session.pyo120530644editdlrm
transaction.py43620644editdlrm
transaction.pyc58570644editdlrm
transaction.pyo58570644editdlrm
translogger.py48120644editdlrm
translogger.pyc43740644editdlrm
translogger.pyo43740644editdlrm
url.py146240644editdlrm
url.pyc185810644editdlrm
url.pyo185810644editdlrm
urlmap.py90320644editdlrm
urlmap.pyc97730644editdlrm
urlmap.pyo96250644editdlrm
urlparser.py264240644editdlrm
urlparser.pyc226700644editdlrm
urlparser.pyo224940644editdlrm
wsgilib.py201340644editdlrm
wsgilib.pyc222360644editdlrm
wsgilib.pyo221800644editdlrm
wsgiwrappers.py221650644editdlrm
wsgiwrappers.pyc244500644editdlrm
wsgiwrappers.pyo244500644editdlrm
Edit: /opt/alt/python37/lib/python3.7/site-packages/paste/registry.pyc (22941B)
Ñò aòNc@sÆdZddkZddkiiZddddgZdefd„ƒYZdefd „ƒYZd efd „ƒYZ defd „ƒYZ defd „ƒYZ e ƒZ d„Z e ie _dS(s Registry for handling request-local module globals sanely Dealing with module globals in a thread-safe way is good if your application is the sole responder in a thread, however that approach fails to properly account for various scenarios that occur with WSGI applications and middleware. What is actually needed in the case where a module global is desired that is always set properly depending on the current request, is a stacked thread-local object. Such an object is popped or pushed during the request cycle so that it properly represents the object that should be active for the current request. To make it easy to deal with such variables, this module provides a special StackedObjectProxy class which you can instantiate and attach to your module where you'd like others to access it. The object you'd like this to actually "be" during the request is then registered with the RegistryManager middleware, which ensures that for the scope of the current WSGI application everything will work properly. Example: .. code-block:: python #yourpackage/__init__.py from paste.registry import RegistryManager, StackedObjectProxy myglobal = StackedObjectProxy() #wsgi app stack app = RegistryManager(yourapp) #inside your wsgi app class yourapp(object): def __call__(self, environ, start_response): obj = someobject # The request-local object you want to access # via yourpackage.myglobal if environ.has_key('paste.registry'): environ['paste.registry'].register(myglobal, obj) You will then be able to import yourpackage anywhere in your WSGI app or in the calling stack below it and be assured that it is using the object you registered with Registry. RegistryManager can be in the WSGI stack multiple times, each time it appears it registers a new request context. Performance =========== The overhead of the proxy object is very minimal, however if you are using proxy objects extensively (Thousands of accesses per request or more), there are some ways to avoid them. A proxy object runs approximately 3-20x slower than direct access to the object, this is rarely your performance bottleneck when developing web applications. Should you be developing a system which may be accessing the proxy object thousands of times per request, the performance of the proxy will start to become more noticeable. In that circumstance, the problem can be avoided by getting at the actual object via the proxy with the ``_current_obj`` function: .. code-block:: python #sessions.py Session = StackedObjectProxy() # ... initialization code, etc. # somemodule.py import sessions def somefunc(): session = sessions.Session._current_obj() # ... tons of session access This way the proxy is used only once to retrieve the object for the current context and the overhead is minimized while still making it easy to access the underlying object. The ``_current_obj`` function is preceded by an underscore to more likely avoid clashing with the contained object's attributes. **NOTE:** This is *highly* unlikely to be an issue in the vast majority of cases, and requires incredibly large amounts of proxy object access before one should consider the proxy object to be causing slow-downs. This section is provided solely in the extremely rare case that it is an issue so that a quick way to work around it is documented. iÿÿÿÿNtStackedObjectProxytRegistryManagertStackedObjectRestorertrestorert NoDefaultcBseZRS((t__name__t __module__(((s?/opt/alt/python37/lib/python3.7/site-packages/paste/registry.pyRbscBseZdZedd„Zd„Zd„Zd„Zd„Zd„Z d„Z d „Z d „Z d „Z d „Zd „Zd„Zd„Zd„Zd„Zdd„Zd„Zd„Zdeie_d„Zdeie_dd„Zdeie_RS(s»Track an object instance internally using a stack The StackedObjectProxy proxies access to an object internally using a stacked thread-local. This makes it safe for complex WSGI environments where access to the object may be desired in multiple places without having to pass the actual object around. New objects are added to the top of the stack with _push_object while objects can be removed with _pop_object. tDefaultcCsB||id(treprRRtAttributeErrorRRRtid(R((s?/opt/alt/python37/lib/python3.7/site-packages/paste/registry.pyt__repr__s   cCst|iƒƒS(N(titerR(R((s?/opt/alt/python37/lib/python3.7/site-packages/paste/registry.pyt__iter__¥scCst|iƒƒS(N(tlenR(R((s?/opt/alt/python37/lib/python3.7/site-packages/paste/registry.pyt__len__¨scCs||iƒjS(N(R(RR#((s?/opt/alt/python37/lib/python3.7/site-packages/paste/registry.pyt __contains__«scCst|iƒƒS(N(tboolR(R((s?/opt/alt/python37/lib/python3.7/site-packages/paste/registry.pyt __nonzero__®scCszy|ii}Wntj o d}nX|o |dS|iidtƒ}|tj o|Std|iƒ‚dS(sÉReturns the current active object being proxied to In the event that no object was pushed, the default object if provided will be used. Otherwise, a TypeError will be raised. iÿÿÿÿR s8No object (name: %s) has been registered for this threadN( R tobjectsR+tNoneR tgetRRR(RR5tobj((s?/opt/alt/python37/lib/python3.7/site-packages/paste/registry.pyR±s   cCsPy|iii|ƒWn2tj o&g|i_|iii|ƒnXdS(spMake ``obj`` the active object for this thread-local. This should be used like: .. code-block:: python obj = yourobject() module.glob = StackedObjectProxy() module.glob._push_object(obj) try: ... do stuff ... finally: module.glob._pop_object(conf) N(R R5tappendR+(RR8((s?/opt/alt/python37/lib/python3.7/site-packages/paste/registry.pyt _push_objectÇs  cCsjyD|iiiƒ}|o'||j otd||fƒ‚nWntj otdƒ‚nXdS(s¢Remove a thread-local object. If ``obj`` is given, it is checked against the popped object and an error is emitted if they don't match. sBThe object popped (%s) is not the same as the object expected (%s)s-No object has been registered for this threadN(R R5tpoptAssertionErrorR+(RR8tpopped((s?/opt/alt/python37/lib/python3.7/site-packages/paste/registry.pyt _pop_objectÝscCsKy0y|ii}Wntj ogSX|SWntj ogSXdS(sjReturns all of the objects stacked in this container (Might return [] if there are none) N(R R5R+R<(Rtobjs((s?/opt/alt/python37/lib/python3.7/site-packages/paste/registry.pyt _object_stackís cCs.tiƒ}|oti||ƒS|iƒS(N(Rtin_restorationtget_saved_proxied_objt_current_obj_orig(Rt request_id((s?/opt/alt/python37/lib/python3.7/site-packages/paste/registry.pyt_current_obj_restorationÿs s.%s (StackedObjectRestorer restoration enabled)cCs"tiƒp|i|ƒndS(N(RRAt_push_object_orig(RR8((s?/opt/alt/python37/lib/python3.7/site-packages/paste/registry.pyt_push_object_restorations cCs"tiƒp|i|ƒndS(N(RRAt_pop_object_orig(RR8((s?/opt/alt/python37/lib/python3.7/site-packages/paste/registry.pyt_pop_object_restorations N(RRt__doc__RRRRR R"R$R%R&R)R-R/R1R2R4RR:R6R>R@RERGRI(((s?/opt/alt/python37/lib/python3.7/site-packages/paste/registry.pyRds8                      tRegistrycBsAeZdZd„Zd„Zd„Zd„ZeZd„ZRS(swTrack objects and stacked object proxies for removal The Registry object is instantiated a single time for the request no matter how many times the RegistryManager is used in a WSGI stack. Each RegistryManager must call ``prepare`` before continuing the call to start a new context for object registering. Each context is tracked with a dict inside a list. The last list element is the currently executing context. Each context dict is keyed by the id of the StackedObjectProxy instance being proxied, the value is a tuple of the StackedObjectProxy instance and the object being tracked. cCs g|_dS(s•Create a new Registry object ``prepare`` must still be called before this Registry object can be used to register objects. N(treglist(R((s?/opt/alt/python37/lib/python3.7/site-packages/paste/registry.pyR%scCs|iihƒdS(såUsed to create a new registry context Anytime a new RegistryManager is called, ``prepare`` needs to be called on the existing Registry object. This sets up a new context for registering objects. N(RLR9(R((s?/opt/alt/python37/lib/python3.7/site-packages/paste/registry.pytprepare.scCsg|id}t|ƒ}||jo |i||dƒ||=n|i|ƒ||f||R:(RtstackedR8t myreglistt stacked_id((s?/opt/alt/python37/lib/python3.7/site-packages/paste/registry.pytregister8s     cCs~|id}xj|D]b\}}t|ƒ}||jo |i||dƒ||=n|i|ƒ||f||R:(Rt stacklistRORNR8RP((s?/opt/alt/python37/lib/python3.7/site-packages/paste/registry.pyt multiregisterBs      cCsBx.|idiƒD]\}}|i|ƒqW|iiƒdS(skRemove all objects from all StackedObjectProxy instances that were tracked at this Registry contextiÿÿÿÿN(RLt itervaluesR>R;(RRNR8((s?/opt/alt/python37/lib/python3.7/site-packages/paste/registry.pytcleanupYs ( RRRJRRMRQRStreplaceRU(((s?/opt/alt/python37/lib/python3.7/site-packages/paste/registry.pyRKs cBs,eZdZed„Zd„Zd„ZRS(s7Creates and maintains a Registry context RegistryManager creates a new registry context for the registration of StackedObjectProxy instances. Multiple RegistryManager's can be in a WSGI stack and will manage the context so that the StackedObjectProxies always proxy to the proper object. The object being registered can be any object sub-class, list, or dict. Registering objects is done inside a WSGI application under the RegistryManager instance, using the ``environ['paste.registry']`` object which is a Registry instance. cCs||_||_dS(N(t applicationt streaming(RRWRX((s?/opt/alt/python37/lib/python3.7/site-packages/paste/registry.pyRos cCs)d}|idtƒƒ}|iƒ|io|i|||ƒSy|i||ƒ}Wn¿tj o}|idƒoYt }x4|idgƒD] }t ||ƒo t }q•q•W|pt i |ƒqÕn|iƒ‚n@|idƒot i |ƒn|iƒ‚n X|iƒ|S(Nspaste.registryspaste.evalexceptionspaste.expected_exceptions(R6t setdefaultRKRMRXtstreaming_iterRWt ExceptionR7tFalset isinstancetTrueRtsave_registry_stateRU(Rtenvirontstart_responsetapp_itertregtetexpectedtexpect((s?/opt/alt/python37/lib/python3.7/site-packages/paste/registry.pyR)ss2     ccsöy&x|i||ƒD] }|VqWWn¿tj o}|idƒoYt}x4|idgƒD] }t||ƒo t}qbqbW|pti|ƒq¢n|iƒ‚n@|idƒoti|ƒn|iƒ‚n X|iƒdS(Nspaste.evalexceptionspaste.expected_exceptions( RWR[R7R\R]R^RR_RU(RRcR`RatitemRdReRf((s?/opt/alt/python37/lib/python3.7/site-packages/paste/registry.pyRZ—s*   (RRRJR\RR)RZ(((s?/opt/alt/python37/lib/python3.7/site-packages/paste/registry.pyR`s  $cBsVeZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z RS( sTrack StackedObjectProxies and their proxied objects for automatic restoration within EvalException's interactive debugger. An instance of this class tracks all StackedObjectProxy state in existence when unexpected exceptions are raised by WSGI applications housed by EvalException and RegistryManager. Like EvalException, this information is stored for the life of the process. When an unexpected exception occurs and EvalException is present in the WSGI stack, save_registry_state is intended to be called to store the Registry state and enable automatic restoration on all currently registered StackedObjectProxies. With restoration enabled, those StackedObjectProxies' _current_obj (overwritten by _current_obj_restoration) method's strategy is modified: it will return its appropriate proxied object from the restorer when a restoration context is active in the current thread. The StackedObjectProxies' _push/pop_object methods strategies are also changed: they no-op when a restoration context is active in the current thread (because the pushing/popping work is all handled by the Registry/restorer). The request's Registry objects' reglists are restored from the restorer when a restoration context begins, enabling the Registry methods to work while their changes are tracked by the restorer. The overhead of enabling restoration is negligible (another threadlocal access for the changed StackedObjectProxy methods) for normal use outside of a restoration context, but worth mentioning when combined with StackedObjectProxies normal overhead. Once enabled it does not turn off, however: o Enabling restoration only occurs after an unexpected exception is detected. The server is likely to be restarted shortly after the exception is raised to fix the cause o StackedObjectRestorer is only enabled when EvalException is enabled (not on a production server) and RegistryManager exists in the middleware stackcCsh|_tiƒ|_dS(N(tsaved_registry_statesR R trestoration_context_id(R((s?/opt/alt/python37/lib/python3.7/site-packages/paste/registry.pyRÞs cCs¨|idƒ}| p*t|iƒ p|i|ƒ|ijodS||if|i|i|ƒt _restorationt_orig(s _current_objs _push_objects _pop_object(R R(RRNt func_namet orig_functrestoration_func((s?/opt/alt/python37/lib/python3.7/site-packages/paste/registry.pyRks cCsddkl}||ƒS(s2Return a unique identifier for the current requestiÿÿÿÿ(tget_debug_count(tpaste.evalexception.middlewareRt(RR`Rt((s?/opt/alt/python37/lib/python3.7/site-packages/paste/registry.pyRj#scCs@||ijo |i|\}}||_n||i_dS(sWEnable a restoration context in the current thread for the specified request_idN(RhRLRiRD(RRDRlRL((s?/opt/alt/python37/lib/python3.7/site-packages/paste/registry.pytrestoration_begin(s cCs'y |i`Wntj onXdS(s9Register a restoration context as finished, if one existsN(RiRDR+(R((s?/opt/alt/python37/lib/python3.7/site-packages/paste/registry.pytrestoration_end2s cCst|idtƒS(sŠDetermine if a restoration context is active for the current thread. Returns the request_id it's active for if so, otherwise FalseRD(RRiR\(R((s?/opt/alt/python37/lib/python3.7/site-packages/paste/registry.pyRA9s( RRRJRR_RBRkRjRvRwRA(((s?/opt/alt/python37/lib/python3.7/site-packages/paste/registry.pyRµs(      cCs t|ƒS(N(R(tappt global_conf((s?/opt/alt/python37/lib/python3.7/site-packages/paste/registry.pytmake_registry_managerBs(RJtsystpaste.util.threadinglocaltutilR t__all__tobjectRRRKRRRRz(((s?/opt/alt/python37/lib/python3.7/site-packages/paste/registry.pyt[s   ²JU‰