ó [³XMc@s†dZddlZddlmZddlmZmZmZdejfd„ƒYZ dej fd„ƒYZ d „Z d „Z dS( s] Persistently cached objects for PB. Maintainer: Glyph Lefkowitz Future Plans: None known. iÿÿÿÿN(tdefer(tbananatjellytflavorst PublishablecBsDeZdZd„Zd„Zd„Zd„Zd„Zd„ZRS(s;An object whose cached state persists across sessions. cCs|jƒ||_dS(N(t republisht publishedID(tselfR((s:/usr/lib/python2.7/dist-packages/twisted/spread/publish.pyt__init__s cCstjƒ|_dS(sFSet the timestamp to current and (TODO) update all observers. N(ttimet timestamp(R((s:/usr/lib/python2.7/dist-packages/twisted/spread/publish.pyRscCs |j|ƒS(s (internal)(tgetStateToPublishFor(Rt perspective((s:/usr/lib/python2.7/dist-packages/twisted/spread/publish.pytview_getStateToPublishscCs |jƒS(sCImplement me to special-case your state for a perspective. (tgetStateToPublish(RR ((s:/usr/lib/python2.7/dist-packages/twisted/spread/publish.pyR #scCstd|jƒ‚dS(sKImplement me to return state to copy as part of the publish phase. s%s.getStateToPublishForN(tNotImplementedErrort __class__(R((s:/usr/lib/python2.7/dist-packages/twisted/spread/publish.pyR(scCsf|r!|j}|jƒj}n d}d}itj||ƒd6|jd6|d6|d6|jd6S(s?Get all necessary metadata to keep a clientside cache. tNonetremoteRR tserviceR (tperspectiveNamet getServicet serviceNameRt ViewPointRR (RR tobservertpnametsname((s:/usr/lib/python2.7/dist-packages/twisted/spread/publish.pytgetStateToCacheAndObserveFor-s  ( t__name__t __module__t__doc__RRR R RR(((s:/usr/lib/python2.7/dist-packages/twisted/spread/publish.pyRs     tRemotePublishedcBsSeZdZdZdZdd„Zd„Zd„Zd„Zd„Z d„Z RS( s;The local representation of remote Publishable object. itpubcCs#d|j|jt|jƒ|fS(Ns %s-%s-%s.%s(RR tstrR(Rtext((s:/usr/lib/python2.7/dist-packages/twisted/spread/publish.pyt getFileNameBscCsÎ|jj|ƒg|_y/t|jƒdƒ}|jƒ}|jƒWntk rad}n+Xtj t j |ƒƒ}|j |j k}|r®|j |jƒd|_n|jjdƒj|j ƒdS(NtrbiiR(t__dict__tupdatet_activationListenerstfileR#treadtclosetIOErrorRtunjellyRtdecodeR t _cbGotUpdatet_wasCleanWhenLoadedRt callRemotet addCallbacks(RtstatetdataFiletdatatrecenttnewself((s:/usr/lib/python2.7/dist-packages/twisted/spread/publish.pytsetCopyableStateFs     cCs6|jjƒ}|d=|d=|d=|d=|d=|S(NtbrokerRtluidR't isActivated(R%tcopy(Rtother((s:/usr/lib/python2.7/dist-packages/twisted/spread/publish.pyt __getstate__XscCsŒ|jj|ƒd|_x|jD]}||ƒq#Wg|_|jƒt|jƒdƒ}|jtj t j |ƒƒƒ|j ƒdS(Nitwb( R%R&R:R't activatedR(R#twriteRtencodeRR*(RtnewStatetlistenerR3((s:/usr/lib/python2.7/dist-packages/twisted/spread/publish.pyR.cs   cCsdS(snImplement this method if you want to be notified when your publishable subclass is activated. N((R((s:/usr/lib/python2.7/dist-packages/twisted/spread/publish.pyR?pscCs*|jr||ƒn|jj|ƒdS(scExternally register for notification when this publishable has received all relevant data. N(R:R'tappend(Rtcallback((s:/usr/lib/python2.7/dist-packages/twisted/spread/publish.pytcallWhenActivatedus  ( RRRR:R/R#R7R=R.R?RF(((s:/usr/lib/python2.7/dist-packages/twisted/spread/publish.pyR=s   cCs,tjƒ}|jt|jd|fƒ|S(sD Wrap a deferred returned from a pb method in another deferred that expects a RemotePublished as a result. This will allow you to wait until the result is really available. Idiomatic usage would look like:: publish.whenReady(serverObject.getMeAPublishable()).addCallback(lookAtThePublishable) t callbackArgs(RtDeferredR1t _pubReadyterrback(tdtd2((s:/usr/lib/python2.7/dist-packages/twisted/spread/publish.pyt whenReady}s  cCs|j|jƒdS(s (internal)N(RFRE(tresultRL((s:/usr/lib/python2.7/dist-packages/twisted/spread/publish.pyRIŒs(RR ttwisted.internetRttwisted.spreadRRRt CacheableRt RemoteCacheRRMRI(((s:/usr/lib/python2.7/dist-packages/twisted/spread/publish.pyt s *@