/usr/lib/python3/dist-packages/twisted/spread/__pycache__
Edit: /usr/lib/python3/dist-packages/twisted/spread/__pycache__/publish.cpython-310.pyc (4909B)
o
b, @ sd d Z ddlZddlmZ ddlmZmZmZ G dd dejZ G dd dej
Zd d
Zdd Z
dS )
z]
Persistently cached objects for PB.
Maintainer: Glyph Lefkowitz
Future Plans: None known.
N)defer)bananaflavorsjellyc @ s@ e Zd ZdZdd Zdd Zdd Zdd Zd
d Zdd
Z dS )Publishablez6An object whose cached state persists across sessions.c C s | || _d S )N) republishpublishedID)selfr r
8/usr/lib/python3/dist-packages/twisted/spread/publish.py__init__ s
zPublishable.__init__c C s t | _dS )z=Set the timestamp to current and (TODO) update all observers.N)time timestampr r
r
r r zPublishable.republishc C s
| |S )
(internal))getStateToPublishForr perspectiver
r
r view_getStateToPublish s
z"Publishable.view_getStateToPublishc C s | S )z:Implement me to special-case your state for a perspective.)getStateToPublishr r
r
r r # s z Publishable.getStateToPublishForc C s t d| j )zBImplement me to return state to copy as part of the publish phase.z%s.getStateToPublishFor)NotImplementedError __class__r r
r
r r ' r zPublishable.getStateToPublishc C s: |r|j }| j}nd}d}t|| | j||| jdS )z6Get all necessary metadata to keep a clientside cache.None)remoter r servicer )perspectiveName
getServiceserviceNamer ViewPointr r )r r observerpnamesnamer
r
r getStateToCacheAndObserveFor+ s
z(Publishable.getStateToCacheAndObserveForN)
__name__
__module____qualname____doc__r r r r r r# r
r
r
r r s r c @ sJ e Zd ZdZdZdZdddZdd Zdd Zd
d Z dd
Z
dd ZdS )RemotePublishedz6The local representation of remote Publishable object.r pubc C s d | j| jt| j|S )Nz{}-{}-{}.{})formatr r strr )r extr
r
r getFileNameC s zRemotePublished.getFileNamec C s | j | g | _zt| d}| }W d n1 s w Y W n ty1 d}Y nw tt
|}|j| jk}|rM| |j d| _
d S | jd| j d S )Nrbr r )__dict__update_activationListenersopenr- readOSErrorr unjellyr decoder _cbGotUpdate_wasCleanWhenLoadedr
callRemoteaddCallbacks)r statedataFiledatarecentnewselfr
r
r setCopyableStateK s
z RemotePublished.setCopyableStatec C s, | j }|d= |d= |d= |d= |d= |S )Nbrokerr luidr2 isActivated)r0 copy)r otherr
r
r __getstate__\ s
zRemotePublished.__getstate__c C s~ | j | d| _| jD ]}|| qg | _| t| d}|t t
| W d d S 1 s8w Y d S )Nr/ wb)r0 r1 rD r2 activatedr3 r- writer encoder )r newStatelistenerr= r
r
r r8 g s
"zRemotePublished._cbGotUpdatec C s dS )znImplement this method if you want to be notified when your
publishable subclass is activated.
Nr
r r
r
r rI r s zRemotePublished.activatedc C s" | j r || dS | j| dS )zZExternally register for notification when this publishable has received all relevant data.N)rD r2 append)r callbackr
r
r callWhenActivatedw s z!RemotePublished.callWhenActivatedN)r) )r$ r% r&