HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //proc/thread-self/root/lib/python3/dist-packages/twisted/spread/__pycache__/publish.cpython-38.pyc
U


W[��@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�8/usr/lib/python3/dist-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)�
(internal))�getStateToPublishFor�r�perspectiverrr
�view_getStateToPublish!sz"Publishable.view_getStateToPublishcCs|��S)zCImplement me to special-case your state for a perspective.
        )�getStateToPublishrr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
)rZextrrr
�getFileNameDs�zRemotePublished.getFileNamec	Cs�|j�|�g|_z&t|��d��}|��}W5QRXWntk
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�dataZrecentZnewselfr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	Csh|j�|�d|_|jD]}||�qg|_|��t|��d��}|�t�	t
�
|���W5QRXdS)Nr'�wb)r(r)r6r*�	activatedr+r%�writer�encoder)rZnewStateZlistenerr3r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)r6r*�append)r�callbackrrr
�callWhenActivatedus
z!RemotePublished.callWhenActivatedN)r#)rrr r!r6r0r%r5r9r/r;r@rrrr
r"?s
r"cCs 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)rZDeferredr1�	_pubReadyZerrback)�d�d2rrr
�	whenReady}s


�rDcCs|�|j�dS)rN)r@r?)�resultrCrrr
rA�srA)r!Z
__future__rrrZtwisted.internetrZtwisted.spreadrrrZ	CacheablerZRemoteCacher"rDrArrrr
�<module>s*>