Your IP : 216.73.216.196


Current Path : /opt/alt/python37/lib64/python3.7/site-packages/twisted/spread/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib64/python3.7/site-packages/twisted/spread/__pycache__/publish.cpython-37.pyc

B

:��]��@stdZddlmZmZddlZddlmZddlmZm	Z	m
Z
Gdd�de
j�ZGdd	�d	e
j
�Zd
d�Zdd
�ZdS)z]
Persistently cached objects for PB.

Maintainer: Glyph Lefkowitz

Future Plans: None known.
�)�absolute_import�divisionN)�defer)�banana�jelly�flavorsc@s@eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dS)�Publishablez;An object whose cached state persists across sessions.
    cCs|��||_dS)N)�	republish�publishedID)�selfr
�r�I/opt/alt/python37/lib64/python3.7/site-packages/twisted/spread/publish.py�__init__szPublishable.__init__cCst��|_dS)zFSet the timestamp to current and (TODO) update all observers.
        N)�time�	timestamp)rrrr
r	szPublishable.republishcCs
|�|�S)z
(internal))�getStateToPublishFor)r�perspectiverrr
�view_getStateToPublish!sz"Publishable.view_getStateToPublishcCs|��S)zCImplement me to special-case your state for a perspective.
        )�getStateToPublish)rrrrr
r%sz Publishable.getStateToPublishForcCstd|j��dS)zKImplement me to return state to copy as part of the publish phase.
        z%s.getStateToPublishForN)�NotImplementedError�	__class__)rrrr
r*szPublishable.getStateToPublishcCs:|r|j}|��j}nd}d}t�||�|j|||jd�S)z?Get all necessary metadata to keep a clientside cache.
        �None)�remoter
r�servicer)ZperspectiveNameZ
getServiceZserviceNamerZ	ViewPointr
r)rrZobserverZpnameZsnamerrr
�getStateToCacheAndObserveFor/s
z(Publishable.getStateToCacheAndObserveForN)
�__name__�
__module__�__qualname__�__doc__rr	rrrrrrrr
rsrc@sJeZdZdZdZdZddd�Zdd�Zdd	�Zd
d�Z	dd
�Z
dd�ZdS)�RemotePublishedz;The local representation of remote Publishable object.
    r�pubcCsd|j|jt|j�|fS)Nz%s-%s-%s.%s)rr�strr
)r�extrrr
�getFileNameDszRemotePublished.getFileNamec	Cs�|j�|�g|_y&t|��d��}|��}WdQRXWntk
rPd}YnXt�t	�
|��}|j|jk}|r�|�|j�d|_
n|j�d��|j�dS)N�rbr�r)�__dict__�update�_activationListeners�openr#�read�IOErrorrZunjellyr�decoder�_cbGotUpdate�_wasCleanWhenLoadedrZ
callRemote�addCallbacks)r�state�dataFile�dataZrecent�newselfrrr
�setCopyableStateHs
z RemotePublished.setCopyableStatecCs,|j��}|d=|d=|d=|d=|d=|S)NZbrokerrZluidr(�isActivated)r&�copy)r�otherrrr
�__getstate__Ys
zRemotePublished.__getstate__c	Csl|j�|�d|_x|jD]}||�qWg|_|��t|��d��}|�t�	t
�
|���WdQRXdS)Nr%�wb)r&r'r5r(�	activatedr)r#�writer�encoder)rZnewStateZlistenerr1rrr
r-dszRemotePublished._cbGotUpdatecCsdS)znImplement this method if you want to be notified when your
        publishable subclass is activated.
        Nr)rrrr
r:pszRemotePublished.activatedcCs |jr||�n|j�|�dS)zcExternally register for notification when this publishable has received all relevant data.
        N)r5r(�append)r�callbackrrr
�callWhenActivatedus
z!RemotePublished.callWhenActivatedN)r )rrrrr5r.r#r4r8r-r:r?rrrr
r?s
rcCs t��}|jt|j|fd�|S)aD
    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)
    )ZcallbackArgs)rZDeferredr/�	_pubReadyZerrback)�d�d2rrr
�	whenReady}s


rCcCs|�|j�dS)z
(internal)N)r?r>)�resultrBrrr
r@�sr@)r�
__future__rrrZtwisted.internetrZtwisted.spreadrrrZ	CacheablerZRemoteCacherrCr@rrrr
�<module>s*>