Ñò ¦sÖIc@sùdZddkZddkZddkZddkZddkZddkiZddk l Z l Z ddk l Z lZlZlZlZddddd d d d d dddg ZeidƒZeieiƒo eiZn d„Zd efd„ƒYZdefd„ƒYZdefd„ƒYZd efd„ƒYZd efd„ƒYZdefd„ƒYZhZe Z!de"fd„ƒYZ#defd„ƒYZ$d e$fd„ƒYZ%de$fd„ƒYZ&d e$fd„ƒYZ'e'Z(dS(sContainer and Namespace classesiÿÿÿÿN(tCreationAbortedErrortMissingCacheParameter(t _threadingtfile_synchronizertmutex_synchronizertNameLocktnull_synchronizertValuet ContainertContainerContexttMemoryContainert DBMContainertNamespaceManagertMemoryNamespaceManagertDBMNamespaceManagert FileContainertOpenResourceNamespaceManagertFileNamespaceManagerRsbeaker.containercGsdS(N((tmessagetargs((s4/usr/lib/python2.6/site-packages/beaker/container.pytdebugscBs›eZdZd„Zd„Zd„Zd„Zd„Zed„Z d„Z d„Z d „Z d „Z dd „Zd „Zd „Zd„Zd„ZRS(s‡Handles dictionary operations and locking for a namespace of values. The implementation for setting and retrieving the namespace data is handled by subclasses. NamespaceManager may be used alone, or may be privately accessed by one or more Container objects. Container objects provide per-key services like expiration times and automatic recreation of values. Multiple NamespaceManagers created with a particular name will all share access to the same underlying datasource and will attempt to synchronize against a common mutex object. The scope of this sharing may be within a single process or across multiple processes, depending on the type of NamespaceManager used. The NamespaceManager itself is generally threadsafe, except in the case of the DBMNamespaceManager in conjunction with the gdbm dbm implementation. cCs ||_dS(N(t namespace(tselfR((s4/usr/lib/python2.6/site-packages/beaker/container.pyt__init__2scCs tƒ‚dS(N(tNotImplementedError(Rtkey((s4/usr/lib/python2.6/site-packages/beaker/container.pytget_creation_lock5scCs tƒ‚dS(N(R(R((s4/usr/lib/python2.6/site-packages/beaker/container.pyt do_remove8scCsdS(N((R((s4/usr/lib/python2.6/site-packages/beaker/container.pytacquire_read_lock;scCsdS(N((R((s4/usr/lib/python2.6/site-packages/beaker/container.pytrelease_read_lock>scCstS(N(tTrue(Rtwait((s4/usr/lib/python2.6/site-packages/beaker/container.pytacquire_write_lockAscCsdS(N((R((s4/usr/lib/python2.6/site-packages/beaker/container.pytrelease_write_lockDscCs |i|ƒS(N(t __contains__(RR((s4/usr/lib/python2.6/site-packages/beaker/container.pythas_keyGscCs tƒ‚dS(N(R(RR((s4/usr/lib/python2.6/site-packages/beaker/container.pyt __getitem__JscCs tƒ‚dS(N(R(RRtvalue((s4/usr/lib/python2.6/site-packages/beaker/container.pyt __setitem__MscCs|||(RR9((s4/usr/lib/python2.6/site-packages/beaker/container.pyR;¦s  cCs@|iiƒz|idtƒ|iƒWd|iiƒXdS(NR9(R1R R;tFalseRR!(R((s4/usr/lib/python2.6/site-packages/beaker/container.pyR+´s  (R,R-R.RR0R6R7RRRR R!R?R:R;R+(((s4/usr/lib/python2.6/site-packages/beaker/container.pyRgs        cBsheZdZdddd„Zd„Zd „Zd „Zd „Zd „Z d „Z d„Z d„Z RS(Rt createfuncR'texpire_argumentt starttimet storedtimeRcCs:||_||_||_||_d|_||_dS(Niÿÿÿÿ(RR@RARBRCR(RRRR@R'RB((s4/usr/lib/python2.6/site-packages/beaker/container.pyRÀs      cCs9|iiƒz|ii|iƒSWd|iiƒXdS(srreturn true if the container has a value stored. This is regardless of it being expired or not. N(RRR#RR(R((s4/usr/lib/python2.6/site-packages/beaker/container.pyt has_valueÈs cCs|iƒp |idj S(N(thas_current_valueR@R/(R((s4/usr/lib/python2.6/site-packages/beaker/container.pytcan_have_valueÔscCs^|iiƒz<|ii|iƒ}|o|iƒ}|iƒ StSWd|iiƒXdS(N(RRR#Rt_Value__get_valuet _is_expiredR?R(RRDR%((s4/usr/lib/python2.6/site-packages/beaker/container.pyRE×s   cCsM|idj o|i|ijp*|idj otiƒ|i|ijS(sÂReturn true if this container's value is expired. Note that this method is only correct if has_current_value() or get_value() have been called already. N(RBR/RCR'ttime(R((s4/usr/lib/python2.6/site-packages/beaker/container.pyRHãs cCsÁ|iiƒzp|iƒ}|o<y"|iƒ}|iƒp|SWq_tj oq_Xn|ipt|iƒ‚nWd|iiƒXt }|ii |iƒ}|o6|i dt ƒpt dƒ|St dƒt }n|p"t dƒ|i ƒt dƒnz–|iiƒzM|iƒo<y"|iƒ}|iƒp|SWqktj oqkXnWd|iiƒXt dƒ|iƒ}|i|ƒ|SWd|iƒt dƒXdS(NRs6get_value returning old value while new one is createdslock_creatfunc (didnt wait)slock_createfunc (waiting)slock_createfunc (waited)sget_value creating new valuesreleased create lock(RRRDRGRHtKeyErrorR@RRR?RR=RRR(R>(RRDR%thas_createlockt creation_locktv((s4/usr/lib/python2.6/site-packages/beaker/container.pyt get_valueösT                      cCs¹|i|i}y|\|_|_}Wn‰tj o}t|ƒdjp‚n|\|_}d|_|_td|i|iƒ|ii ƒ|i |ƒ|ii ƒnX|S(Nis*get_value upgrading time %r expire time %r( RRRCR't ValueErrortlenR/RARRR(R(RR%((s4/usr/lib/python2.6/site-packages/beaker/container.pyt __get_value.s  cCsp|iiƒzNtiƒ|_td|i|iƒ|ii|i|i|i|fƒWd|iiƒXdS(Ns'set_value stored time %r expire time %r( RR RIRCRRAR(RR!(RR%((s4/usr/lib/python2.6/site-packages/beaker/container.pyR(>s  )cCsz|iiƒzXtdƒ|ii|iƒo+y|i|i=Wq[tj oq[Xnd|_Wd|iiƒXdS(Nt clear_valueiÿÿÿÿ(RR RR#RRJRCR!(R((s4/usr/lib/python2.6/site-packages/beaker/container.pyRRGs    (skeys createfuncs expiretimesexpire_arguments starttimes storedtimes namespaceN( R,R-t __slots__R/RRDRFRERHRNRGR(RR(((s4/usr/lib/python2.6/site-packages/beaker/container.pyR¼s   8  cBseeZeiƒZd„Zd„Zd„Zd„Zd„Z d„Z d„Z d„Z d„Z RS( cKs/ti||ƒtii|itƒ|_dS(N(R RR t namespacestgetRtdictt dictionary(RRtkwargs((s4/usr/lib/python2.6/site-packages/beaker/container.pyRYscCs tdd|i|fdtƒS(Nt identifiersmemorycontainer/funclock/%s/%st reentrant(RRR(RR((s4/usr/lib/python2.6/site-packages/beaker/container.pyR]scCs |i|S(N(RW(RR((s4/usr/lib/python2.6/site-packages/beaker/container.pyR$cscCs|ii|ƒS(N(RWR"(RR((s4/usr/lib/python2.6/site-packages/beaker/container.pyR"fscCs|ii|ƒS(N(RWR"(RR((s4/usr/lib/python2.6/site-packages/beaker/container.pyR#iscCs||i|s>     (      KUš#fU