
~Mc        %   @   sW  d  Z  d d l Z d d l Z d d l Z d d l m Z m Z d d l m Z m	 Z	 m
 Z
 d d l m Z d d l m Z d d l m Z d d l m Z m Z d d	 l m Z d d
 l m Z m Z d d l m Z m Z d d l m Z d d l m Z d d l m  Z  m! Z! d d l" m# Z# m$ Z$ m% Z% d d l& m' Z' d d l( m) Z) d d l( m* Z* m+ Z+ d d l( m, Z, m- Z- d d l( m. Z. d d l( m/ Z/ d d l( m0 Z0 d d l( m1 Z1 d d l( m2 Z2 d d l( m3 Z3 d d l( m4 Z4 d d l( m5 Z5 d d l( m6 Z6 d d l( m7 Z7 d d l( m8 Z8 d d l( m9 Z9 d d  l( m: Z: d d! l( m; Z; d d" l( m< Z< d# Z= d$ Z> d% e? f d&     YZ@ d' e@ f d(     YZA d) e? f d*     YZB d+ f  d,     YZC d-   ZD e e d. d/ d0 d1   eD  ZD d2 e? f d3     YZE d4   ZF e e d. d/ d0 d1   eF  ZF d5 e f d6     YZG d7 f  d8     YZH d9 e* f d:     YZI d; e) e jJ f d<     YZK e7 d= eK  d> f  d?     YZL d@ e	 jM e0 f dA     YZN dB e3 e	 jM f dC     YZO e7 eN eO  d1 dD  ZP dE e' jQ f dF     YZR dG   ZS dH   ZT dI e jU f dJ     YZV dK e jW f dL     YZX dM e f dN     YZY dO f  dP     YZZ e eZ e e-  dQ f  dR     YZ[ dS e* e[ f dT     YZ\ dU e* e[ f dV     YZ] dW dX dY dZ d[ d\ d] d^ d_ d` da db dc dd de df dg dh di d% d' d) d2 d+ d5 d7 d9 d; d@ dB dj dE dk dl dI dK dM g% Z^ d S(m   s  
Perspective Broker

"This isn't a professional opinion, but it's probably got enough
internet to kill you." --glyph

Introduction
============

This is a broker for proxies for and copies of objects.  It provides a
translucent interface layer to those proxies.

The protocol is not opaque, because it provides objects which represent the
remote proxies and require no context (server references, IDs) to operate on.

It is not transparent because it does I{not} attempt to make remote objects
behave identically, or even similiarly, to local objects.  Method calls are
invoked asynchronously, and specific rules are applied when serializing
arguments.

To get started, begin with L{PBClientFactory} and L{PBServerFactory}.

@author: Glyph Lefkowitz
iN(   t
   implementst	   Interface(   t   logt   failuret   reflect(   t   Version(   t
   deprecated(   t   md5(   t   defert   protocol(   t   Portal(   t
   IAnonymoust   ICredentials(   t   IUsernameHashedPasswordt	   Anonymous(   t   styles(   t   registerAdapter(   t
   IJellyablet   IUnjellyable(   t   jellyt   unjellyt   globalSecurity(   t   banana(   t   Serializable(   t   Referenceablet   NoSuchMethod(   t   Roott   IPBRoot(   t	   ViewPoint(   t   Viewable(   t   Copyable(   t	   Jellyable(   t	   Cacheable(   t
   RemoteCopy(   t   RemoteCache(   t   RemoteCacheObserver(   t   copyTags(   t   setUnjellyableForClass(   t   setUnjellyableFactoryForClass(   t   setUnjellyableForClassTree(   t   setCopierForClass(   t   setFactoryForClass(   t   setCopierForClassTreei   iS"  t   ProtocolErrorc           B   s   e  Z d  Z RS(   sN   
    This error is raised when an invalid protocol statement is received.
    (   t   __name__t
   __module__t   __doc__(    (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyR+   P   s   t   DeadReferenceErrorc           B   s   e  Z d  Z RS(   sx   
    This error is raised when a method is called on a dead reference (one whose
    broker has been disconnected).
    (   R,   R-   R.   (    (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyR/   U   s   t   Errorc           B   s   e  Z d  Z RS(   s   
    This error can be raised to generate known error conditions.

    When a PB callable method (perspective_, remote_, view_) raises
    this error, it indicates that a traceback should not be printed,
    but instead, the string representation of the exception should be
    sent.
    (   R,   R-   R.   (    (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyR0   [   s   t   RemoteMethodc           B   s2   e  Z d  Z d   Z d   Z d   Z d   Z RS(   s9   This is a translucent reference to a remote message.
    c         C   s   | |  _  | |  _ d S(   sK   Initialize with a L{RemoteReference} and the name of this message.
        N(   t   objt   name(   t   selfR2   R3   (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyt   __init__h   s    	c         C   s   t  |  j |  j f |  S(   N(   t   cmpR2   R3   (   R4   t   other(    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyt   __cmp__n   s    c         C   s   t  |  j |  j f  S(   N(   t   hashR2   R3   (   R4   (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyt   __hash__q   s    c         O   s1   |  j  j j d |  j  j |  j  j |  j | |  S(   s/   Asynchronously invoke a remote method.
        t    (   R2   t   brokert   _sendMessaget   perspectivet   luidR3   (   R4   t   argst   kw(    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyt   __call__t   s    (   R,   R-   R.   R5   R8   R:   RB   (    (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyR1   e   s
   			c          O   s   d S(   s}   
    Do nothing.

    Neque porro quisquam est qui dolorem ipsum quia dolor sit amet,
    consectetur, adipisci velit...
    N(    (   R@   RA   (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyt   noOperation{   s    t   twistedi   i   i    t   PBConnectionLostc           B   s   e  Z RS(    (   R,   R-   (    (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyRE      s   c         C   s   t  j d  t  j |   d S(   s9   
    Print a traceback (string) to the standard log.
    s   Perspective Broker Traceback:N(   R   t   msg(   t   tb(    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyt   printTraceback   s    t   IPerspectivec           B   s   e  Z d  Z d   Z RS(   s  
    per*spec*tive, n. : The relationship of aspects of a subject to each
    other and to a whole: 'a perspective of history'; 'a need to view
    the problem in the proper perspective'.

    This is a Perspective Broker-specific wrapper for an avatar. That
    is to say, a PB-published view on to the business logic for the
    system's concept of a 'user'.

    The concept of attached/detached is no longer implemented by the
    framework. The realm is expected to implement such semantics if
    needed.
    c         C   s   d S(   s  
        This method is called when a network message is received.

        @arg broker: The Perspective Broker.

        @type message: str
        @arg message: The name of the method called by the other end.

        @type args: list in jelly format
        @arg args: The arguments that were passed by the other end. It
                   is recommend that you use the `unserialize' method of the
                   broker to decode this.

        @type kwargs: dict in jelly format
        @arg kwargs: The keyword arguments that were passed by the
                     other end.  It is recommended that you use the
                     `unserialize' method of the broker to decode this.

        @rtype: A jelly list.
        @return: It is recommended that you use the `serialize' method
                 of the broker on whatever object you need to return to
                 generate the return value.
        N(    (   R<   t   messageR@   t   kwargs(    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyt   perspectiveMessageReceived   s    (   R,   R-   R.   RL   (    (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyRI      s   t   Avatarc           B   s!   e  Z d  Z e e  d   Z RS(   s  
    A default IPerspective implementor.

    This class is intended to be subclassed, and a realm should return
    an instance of such a subclass when IPerspective is requested of
    it.

    A peer requesting a perspective will receive only a
    L{RemoteReference} to a pb.Avatar.  When a method is called on
    that L{RemoteReference}, it will translate to a method on the
    remote perspective named 'perspective_methodname'.  (For more
    information on invoking methods on other objects, see
    L{flavors.ViewPoint}.)
    c         C   s   | j  | |   } | j  | |   } t |  d |  } y | | |   } Wn. t k
 rz t j d | | | f    n X| j | |  | | |  S(   si  
        This method is called when a network message is received.

        This will call::

            self.perspective_%(message)s(*broker.unserialize(args),
                                         **broker.unserialize(kw))

        to handle the method; subclasses of Avatar are expected to
        implement methods using this naming convention.
        s   perspective_%ss   %s didn't accept %s and %s(   t   unserializet   getattrt	   TypeErrorR   RF   t	   serialize(   R4   R<   RJ   R@   RA   t   methodt   state(    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyRL      s    (   R,   R-   R.   R    RI   RL   (    (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyRM      s   
t   AsReferenceablec           B   s   e  Z d  Z d d  Z RS(   s6   
    A reference directed towards another object.
    t   remotec         C   s   t  | | d  |  _ d  S(   Nt   MessageReceived(   RO   t   remoteMessageReceived(   R4   t   objectt   messageType(    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyR5      s    (   R,   R-   R.   R5   (    (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyRT      s   t   RemoteReferencec           B   s{   e  Z d  Z e e  d   Z d   Z d   Z d   Z d   Z	 d   Z
 d   Z d   Z d	   Z d
   Z d   Z RS(   s]  
    A translucent reference to a remote object.

    I may be a reference to a L{flavors.ViewPoint}, a
    L{flavors.Referenceable}, or an L{IPerspective} implementor (e.g.,
    pb.Avatar).  From the client's perspective, it is not possible to
    tell which except by convention.

    I am a "translucent" reference because although no additional
    bookkeeping overhead is given to the application programmer for
    manipulating a reference, return values are asynchronous.

    See also L{twisted.internet.defer}.

    @ivar broker: The broker I am obtained through.
    @type broker: L{Broker}
    c         C   s1   | |  _  | |  _ | |  _ | |  _ g  |  _ d S(   s   (internal) Initialize me with a broker and a locally-unique ID.

        The ID is unique only to the particular Perspective Broker
        instance.
        N(   R?   R<   t
   doRefCountR>   t   disconnectCallbacks(   R4   R>   R<   R?   R[   (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyR5   	  s
    				c         C   sQ   t  |  s t  |  j j |  t |  j  d k rM |  j j |  j  n  d S(   s   Register a callback to be called if our broker gets disconnected.

        This callback will be called with one argument, this instance.
        i   N(   t   callablet   AssertionErrorR\   t   appendt   lenR<   t   notifyOnDisconnectt   _disconnected(   R4   t   callback(    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyRa     s    c         C   s3   |  j  j |  |  j  s/ |  j j |  j  n  d S(   s>   Remove a callback that was registered with notifyOnDisconnect.N(   R\   t   removeR<   t   dontNotifyOnDisconnectRb   (   R4   Rc   (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyRe     s    	c         C   s+   x |  j  D] } | |   q
 Wd |  _  d S(   s<   Called if we are disconnected and have callbacks registered.N(   R\   t   None(   R4   Rc   (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyRb   %  s    c         C   s9   | j  r1 |  j | j  k s$ t d  d |  j f Sd Sd S(   sZ   If I am being sent back to where I came from, serialize as a local backreference.
        s6   Can't send references to brokers other than their own.t   localt   unpersistables   References cannot be serializedN(   Rh   s   References cannot be serialized(   t   invokerR<   R^   R?   (   R4   t   jellier(    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyt   jellyFor+  s    	c         C   s'   |  j  | j j | j | d d  |  S(   Ni   (   R5   Ri   t   unserializingPerspective(   R4   t	   unjelliert   unjellyList(    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyt
   unjellyFor4  s    #c         O   s%   |  j  j d |  j |  j | | |  S(   s  Asynchronously invoke a remote method.

        @type _name:   C{string}
        @param _name:  the name of the remote method to invoke
        @param args: arguments to serialize for the remote function
        @param kw:  keyword arguments to serialize for the remote function.
        @rtype:   L{twisted.internet.defer.Deferred}
        @returns: a Deferred which will be fired when the result of
                  this remote call is received.
        R;   (   R<   R=   R>   R?   (   R4   t   _nameR@   RA   (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyt
   callRemote8  s    c         C   s   t  |  |  S(   s,   Get a L{RemoteMethod} for this key.
        (   R1   (   R4   t   key(    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyt   remoteMethodJ  s    c         C   sG   t  | t  r7 | j |  j k r7 t |  j | j  Sn  t |  j |  S(   s4   Compare me [to another L{RemoteReference}].
        (   t
   isinstanceRZ   R<   R6   R?   (   R4   R7   (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyR8   O  s    c         C   s   |  j  S(   s   Hash me.
        (   R?   (   R4   (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyR:   W  s    c         C   s#   |  j  r |  j j |  j  n  d S(   s;   Do distributed reference counting on finalization.
        N(   R[   R<   t
   sendDecRefR?   (   R4   (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyt   __del__\  s    	(   R,   R-   R.   R    R   R5   Ra   Re   Rb   Rk   Ro   Rq   Rs   R8   R:   Rv   (    (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyRZ      s   
		
									RU   t   Localc           B   s5   e  Z d  Z d d  Z d   Z d   Z d   Z RS(   s.   (internal) A reference to a local object.
    c         C   s   | |  _  | |  _ d |  _ d S(   s   Initialize.
        i   N(   RX   R>   t   refcount(   R4   RX   R>   (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyR5   h  s    		c         C   s   d |  j  |  j f S(   Ns   <pb.Local %r ref:%s>(   RX   Rx   (   R4   (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyt   __repr__o  s    c         C   s   |  j  d |  _  |  j  S(   s1   Increment and return my reference count.
        i   (   Rx   (   R4   (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyt   increfr  s    c         C   s   |  j  d |  _  |  j  S(   s1   Decrement and return my reference count.
        i   (   Rx   (   R4   (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyt   decrefx  s    N(   R,   R-   R.   Rf   R5   Ry   Rz   R{   (    (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyRw   d  s
   		t   CopyableFailurec           B   s   e  Z d  Z d Z d   Z RS(   s}   
    A L{flavors.RemoteCopy} and L{flavors.Copyable} version of
    L{twisted.python.failure.Failure} for serialization.
    i    c         C   s   |  j  j   } d | d <g  | d <g  | d <t |  j t j  r^ t |  j |  j  | d <n t	 |  j  | d <t |  j
 t	  r |  j
 | d <n t j |  j
  | d <|  j r |  j   | d <n
 d | d <| S(	   s   
        Collect state related to the exception which occurred, discarding
        state which cannot reasonably be serialized.
        RG   t   framest   stackt   valuet   typet	   tracebacks   Traceback unavailable
N(   t   __dict__t   copyRf   Rt   R   R   t   Failuret   failure2Copyablet   unsafeTracebackst   strR   R   t   qualt   getTraceback(   R4   RS   (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyt   getStateToCopy  s    


	
(   R,   R-   R.   R   R   (    (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyR|     s   t   CopiedFailurec           B   s&   e  Z d d  d d  Z e Z e Z RS(   i    t   defaultc         C   s9   | d  k r t j } n  | j d  | j |  j  d  S(   Ns   Traceback from remote host -- (   Rf   R   t   logfilet   writeR   (   R4   t   filet   elideFrameworkCodet   detail(    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyRH     s    N(   R,   R-   Rf   RH   t   printBriefTracebackt   printDetailedTraceback(    (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyR     s   c         C   s"   t  j t |  j  } | | _ | S(   N(   t   newt   instanceR|   R   R   (   t   failR   t   f(    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyR     s    	t   Brokerc           B   s  e  Z d  Z d Z d0 Z d0 Z d e d  Z d   Z	 d   Z
 d   Z d   Z d   Z d	   Z d
   Z d   Z d   Z d   Z d0 Z d   Z d   Z d   Z d   Z d   Z d   Z d Z d   Z d   Z d   Z d d  Z d   Z d   Z  d   Z! d   Z" d0 d0 d0 d0 d  Z# d0 d  Z$ d   Z% d    Z& d!   Z' d"   Z( d#   Z) d$   Z* d%   Z+ d&   Z, d'   Z- d(   Z. d)   Z/ d*   Z0 d+   Z1 d,   Z2 d-   Z3 d.   Z4 d/   Z5 RS(1   s   I am a broker for objects.
    i   i   c         C   s   t  j j |  |  d |  _ g  |  _ g  |  _ g  |  _ i  |  _ | |  _ g  |  _	 d |  _
 d |  _ d  |  _ i  |  _ i  |  _ i  |  _ i  |  _ i  |  _ i  |  _ d  S(   Ni    (   R   t   BananaR5   t   disconnectedt   disconnectst   failurest   connectst   localObjectst   securityt   pageProducerst   currentRequestIDt   currentLocalIDRf   Rl   t   luidst   remotelyCachedObjectst   remotelyCachedLUIDst   locallyCachedObjectst   waitingForAnswerst   _localCleanup(   R4   t   isClientR   (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyR5     s"    															c         C   sw   xW t  t |  j  d d d  D]6 } |  j | } | j   | j   s  |  j | =q  q  W|  j ss |  j j   n  d S(   sD   Called when the consumer attached to me runs out of buffer.
        i   iN(   t   xrangeR`   R   t   sendNextPaget   stillPagingt	   transportt   unregisterProducer(   R4   t   pageridxt   pager(    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyt   resumeProducing  s    &
	c         C   s   d  S(   N(    (   R4   (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyt   pauseProducing  s    c         C   s   d  S(   N(    (   R4   (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyt   stopProducing  s    c         C   s?   |  j  j |  t |  j   d k r; |  j j |  d  n  d  S(   Ni   i    (   R   R_   R`   R   t   registerProducer(   R4   R   (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyt   registerPageProducer  s    c         C   sr   t  | t j  rb | d } d | } t |  | d  } | rO | | d   qn |  j d |  n t d   d S(   s1   Evaluate an expression as it's received.
        i    s   proto_%si   t   didNotUnderstands   Non-list expression received.N(   Rt   t   typest   ListTypeRO   Rf   t   sendCallR+   (   R4   t   sexpt   commandt
   methodNameRR   (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyt   expressionReceived  s    

c         C   s/   | |  j  k r+ t d |  j  | f   n  d S(   s   Protocol message: (version version-number)

        Check to make sure that both ends of the protocol are speaking
        the same version dialect.
        s   Version Incompatibility: %s %sN(   t   versionR+   (   R4   t   vnum(    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyt   proto_version
  s    c         G   s   |  j  |  d S(   sR   Utility method to send an expression to the other side of the connection.
        N(   t   sendEncoded(   R4   t   exp(    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyR     s    c         C   s   t  j d |  d S(   s   Respond to stock 'C{didNotUnderstand}' message.

        Log the command that was not understood and continue. (Note:
        this will probably be changed to close the connection or raise
        an exception in the future.)
        s   Didn't understand command: %rN(   R   RF   (   R4   R   (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyt   proto_didNotUnderstand  s    c         C   so   |  j  d |  j  x0 |  j D]% } y |   Wq t j   q Xq Wd |  _ |  j rk |  j j |   n  d S(   s=   Initialize. Called after Banana negotiation is done.
        R   N(   R   R   R   R   t   deferrRf   t   factoryt   clientConnectionMade(   R4   t   notifier(    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyt   connectionReady#  s    		c         C   s@   x0 |  j  D]% } y |   Wq
 t j   q
 Xq
 Wd  |  _  d  S(   N(   R   R   R   Rf   (   R4   R   (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyt   connectionFailed0  s    c         C   sL  d |  _  d |  _ |  j rl xN |  j j   D]: } y  | j t j t |    Wq+ t	 j
   q+ Xq+ Wn  x] |  j j   D]L } | j } | j } y  | j | t |  | |   Wq| t	 j
   q| Xq| Wx1 |  j D]% } y |   Wq t	 j
   q Xq Wd |  _ d |  _ d |  _ d |  _ d |  _ d |  _ d |  _ d |  _ d S(   s!   The connection was lost.
        i   N(   R   Rf   R   R   t   valuest   errbackR   R   RE   R   R   R   RX   R>   t   stoppedObservingR#   R   t   localSecurityt   remoteSecurityR   R   R   (   R4   t   reasont   dt   lobjt	   cacheableR>   R   (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyt   connectionLost;  s8    			 		 							c         C   s&   t  |  s t  |  j j |  d S(   s4   Call the given callback when the Broker disconnects.N(   R]   R^   R   R_   (   R4   R   (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyRa   _  s    c         C   s&   t  |  s t  |  j j |  d S(   s7   Call the given callback if the Broker fails to connect.N(   R]   R^   R   R_   (   R4   R   (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyt   notifyOnFaild  s    c         C   sW   t  |  s t  |  j d k rC y |   WqS t j   qS Xn |  j j |  d S(   s1   Call the given callback when the Broker connects.N(   R]   R^   R   Rf   R   t   errR_   (   R4   R   (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyt   notifyOnConnecti  s    c         C   s,   y |  j  j |  Wn t k
 r' n Xd S(   s4   Remove a callback from list of disconnect callbacks.N(   R   Rd   t
   ValueError(   R4   R   (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyRe   t  s    c         C   s)   |  j  j |  } | d k r" d S| j S(   s   
        Get a local object for a locally unique ID.

        @return: An object previously stored with L{registerReference} or
            C{None} if there is no object which corresponds to the given
            identifier.
        N(   R   t   getRf   RX   (   R4   R?   t   lob(    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyt   localObjectForID{  s    i    c         C   s   | d k	 s t  | j   } |  j j |  } | d k r t |  j  t k r |  j d |  _ |  j d k r |  j	 j
   t d   n  t d   n  |  j   } t |  |  j | <| |  j | <n |  j | j   | S(   s   Get an ID for a local object.

        Store a persistent reference to a local object and map its id()
        to a generated, session-unique ID and return that ID.
        i   i   s.   Maximum PB reference count exceeded.  Goodbye.s$   Maximum PB reference count exceeded.N(   Rf   R^   t   processUniqueIDR   R   R`   R   t   MAX_BROKER_REFSt   maxBrokerRefsViolationsR   t   loseConnectionR0   t
   newLocalIDRw   Rz   (   R4   RX   t   puidR?   (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyt   registerReference  s    c         C   s)   | d k	 s t  t |  |  j | <d S(   s   Store a special (string) ID for this object.

        This is how you specify a 'base' set of objects that the remote
        protocol can connect to.
        N(   Rf   R^   Rw   R   (   R4   R3   RX   (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyt   setNameForLocal  s    c         C   s   t  d |  | d  S(   s   Returns an object from the remote name mapping.

        Note that this does not check the validity of the name, only
        creates a translucent reference for it.
        i    N(   RZ   Rf   (   R4   R3   (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyt   remoteForName  s    c         C   sH   | j    } |  j j |  } | d k	 rD | rD |  j | j   n  | S(   sb   Returns an ID that says what this instance is cached as remotely, or C{None} if it's not.
        N(   R   R   R   Rf   R   Rz   (   R4   R   Rz   R   R?   (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyt   cachedRemotelyAs  s
    c         C   s   |  j  | j S(   sF   Returns an instance which is cached remotely, with this LUID.
        (   R   RX   (   R4   R?   (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyt   remotelyCachedForLUID  s    c         C   s   | j    } |  j   } t |  j  t k rw |  j d |  _ |  j d k rh |  j j   t d   n  t d   n  | |  j	 | <t
 | |  j  |  j | <| S(   s   
        XXXi   i   s*   Maximum PB cache count exceeded.  Goodbye.s    Maximum PB cache count exceeded.(   R   R   R`   R   R   R   R   R   R0   R   Rw   t   serializingPerspective(   R4   R   R   R?   (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyt   cacheRemotely  s    c         C   s   | |  j  | <d S(   sL   (internal)

        Store a non-filled-out cached instance locally.
        N(   R   (   R4   t   cidR   (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyt   cacheLocally  s    c         C   s   |  j  | } | S(   N(   R   (   R4   R   R   (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyt   cachedLocallyAs  s    c         C   s   t  | t j  rN | j |  j d   d i | d 6| d 6| d 6| d 6| S| |  _ | |  _ | |  _ | |  _ z t	 | |  j
 d |   SWd d |  _ d |  _ d |  _ d |  _ Xd S(   sP   Jelly an object according to the remote security rules for this broker.
        c         S   s   |  S(   N(    (   t   x(    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyt   <lambda>  s    t   callbackKeywordsR>   RR   R@   RA   N(   Rt   R   t   Deferredt   addCallbacksRQ   R   t   jellyMethodt	   jellyArgst   jellyKwR   R   Rf   (   R4   RX   R>   RR   R@   RA   (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyRQ     s$    								c         C   s4   | |  _  z t | |  j d |   SWd d |  _  Xd S(   sO   Unjelly an sexp according to the local security rules for this broker.
        N(   Rl   R   R   Rf   (   R4   R   R>   (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyRN     s    	c         C   s   |  j  d |  _  |  j  S(   s   Generate a new LUID.
        i   (   R   (   R4   (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyR     s    c         C   s   |  j  d |  _  |  j  S(   s#   Generate a new request ID.
        i   (   R   (   R4   (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyt   newRequestID  s    c      
   C   s  d  } d  } d }	 | j d  r5 | d } | d =n  | j d  rX | d } | d =n  | j d  r | ru | s~ t d  | d }	 | d =n  |  j r t d   n  y: |  j | d | d | }
 |  j | d | d | } Wn t j t j	    SX|  j
   } |	 rXt j   } | |  j | <| s5| r^t j d	  | j | |  q^n d  } |  j | d
 | | | |	 |
 |  | S(   Ni   t
   pbcallbackt	   pberrbackt   pbanswers*   You can't specify a no-answer requirement.s   Calling Stale BrokerR>   RR   s&   warning! using deprecated "pbcallback"RJ   (   Rf   t   has_keyR^   R   R/   RQ   R   R   R   R   R   R   R   R   RF   R   R   (   R4   t   prefixR>   t   objectIDRJ   R@   RA   t   pbct   pbet   answerRequiredt   netArgst   netKwt	   requestIDt   rval(    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyR=     s<    





	#c         C   s&   |  j  |  j | | | | | |  d  S(   N(   t   _recvMessageR   (   R4   R   R   RJ   R   R   R   (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyt   proto_message:  s    c         C   s&   |  j  |  j | | | | | |  d  S(   N(   R  R   (   R4   R   R   RJ   R   R   R   (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyt   proto_cachemessage<  s    c         C   sQ  yC | |  } | d k r* t d   n  | j |  | | |  }	 Wn t k
 r }
 | rMt |
 t  s |  j j |
 j  r |  j |
 |  q |  j t	 |
  |  qMn | r t
 j d d t t	   } |  j | |  n  t
 j   nZ X| rMt |	 t j  r:| f } |	 j |  j |  j d | d | qM|  j |	 |  n  d S(   s   Received a message-send.

        Look up message based on object, unserialize the arguments, and
        invoke it with args, and send an 'answer' or 'error' response.
        s   Invalid Object IDs)   Peer will receive following PB traceback:t   isErrort   callbackArgst   errbackArgsN(   Rf   R0   RW   Rt   R   R   t   isClassAllowedt	   __class__t
   _sendErrorR|   R   RF   t   TrueR   R   R   R   t   _sendAnswert   _sendFailureOrError(   R4   t   findObjMethodR   R   RJ   R   R   R   RX   t	   netResultt   eR   R@   (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyR  ?  s,    $		c         C   s   |  j  d | |  d S(   s@   (internal) Send an answer to a previously sent message.
        t   answerN(   R   (   R4   R  R   (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyR  i  s    c         C   s1   |  j  | } |  j  | =| j |  j |   d S(   sv   (internal) Got an answer to a previously sent message.

        Look up the appropriate callback and call it.
        N(   R   Rc   RN   (   R4   R   R  R   (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyt   proto_answern  s    
c         C   s<   | j  t  d k r( |  j | |  n |  j | |  d S(   s   
        Call L{_sendError} or L{_sendFailure}, depending on whether C{fail}
        represents an L{Error} subclass or not.
        N(   t   checkR0   Rf   t   _sendFailureR	  (   R4   R   R   (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyR  z  s    c         C   s.   t  j d  t  j |  |  j | |  d S(   s   Log error and then send it.s)   Peer will receive following PB traceback:N(   R   RF   R   R	  (   R4   R   R   (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyR    s    c         C   s   t  | t j  rr t  | j t  s< |  j j | j j  rH | j } qr t  | t  sr t	 | |  j
 j  } qr n  t  | t  r |  j
 j | _ n  |  j d | |  j |   d S(   s@   (internal) Send an error for a previously sent message.
        t   errorN(   Rt   R   R   R   R   R   R  R  R|   R   R   R   R   RQ   (   R4   R   R   (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyR	    s    c         C   s1   |  j  | } |  j  | =| j |  j |   d S(   s'   (internal) Deal with an error.
        N(   R   R   RN   (   R4   R   R   R   (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyt   proto_error  s    
c         C   s   |  j  d |  d S(   s,   (internal) Send a DECREF directive.
        R{   N(   R   (   R4   R   (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyRu     s    c         C   si   |  j  | j   } | d k re |  j  | j j   } |  j | =|  j  | =|  j j | d      n  d S(   s   (internal) Decrement the reference count of an object.

        If the reference count is zero, it will free the reference to this
        object.
        i    c           S   s   d  S(   N(   Rf   (    (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyR     s    N(   R   R{   RX   R   R   R   t   pop(   R4   R   t   refsR   (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyt   proto_decref  s    

c         C   s   |  j  d |  d S(   s-   (internal) Send a DECACHE directive.
        t   decacheN(   R   (   R4   R   (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyt   decCacheRef  s    c         C   s   |  j  | j   } | d k r |  j  | } | j } | j } y  | j | t |  | |   Wn t j   n X| j   } |  j	 | =|  j  | =|  j
 d |  n  d S(   s   (internal) Decrement the reference count of a cached object.

        If the reference count is zero, free the reference, then send an
        'uncached' directive.
        i    t   uncacheN(   R   R{   RX   R>   R   R#   R   R   R   R   R   (   R4   R   R  R   R   R>   R   (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyt   proto_decache  s    		 

c         C   s$   |  j  | } d | _ |  j  | =d S(   sF   (internal) Tell the client it is now OK to uncache an object.
        N(   R   Rf   R<   (   R4   R   R2   (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyt   proto_uncache  s    	N(6   R,   R-   R.   R   Rf   t   usernameR   R   R5   R   R   R   R   R   R   R   R   R   R   R   R   Ra   R   R   Re   R   R   R   R   R   R   R   R   R   R   RQ   RN   R   R   R=   R  R  R  R  R  R  R  R	  R  Ru   R  R  R  R  (    (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyR     sd   '													$									
				!
			!			*										c         C   sU   t    } | j |  | j   } t    } | j |  | j |   | j   } | S(   sW   Respond to a challenge.

    This is useful for challenge/response authentication.
    (   R   t   updatet   digest(   t	   challenget   passwordt   mt   hashedPasswordt   doubleHashedPassword(    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyt   respond  s    		c          C   s[   d }  x< t  t j d d   D]" } |  t t j d d   }  q Wt |   j   }  |  S(   s   I return some random data.R;   i   i   iA   iZ   (   t   ranget   randomt	   randranget   chrt   randintR   R   (   t   crapR   (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyR!    s
     t   PBClientFactoryc           B   s   e  Z d  Z e Z e Z e e d  Z d   Z	 d   Z
 d   Z d   Z d d  Z d   Z d	   Z d
   Z d   Z d   Z d   Z d d  Z RS(   s   
    Client factory for PB brokers.

    As with all client factories, use with reactor.connectTCP/SSL/etc..
    getPerspective and getRootObject can be called either before or
    after the connect.
    c         C   s    | |  _  | |  _ |  j   d S(   sE  
        @param unsafeTracebacks: if set, tracebacks for exceptions will be sent
            over the wire.
        @type unsafeTracebacks: C{bool}

        @param security: security options used by the broker, default to
            C{globalSecurity}.
        @type security: L{twisted.spread.jelly.SecurityOptions}
        N(   R   R   t   _reset(   R4   R   R   (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyR5     s    
		c         C   s(   |  j  d t d |  j  } |  | _ | S(   sP   
        Build the broker instance, passing the security options to it.
        R   R   (   R	   R
  R   R   (   R4   t   addrt   p(    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyt   buildProtocol  s    	c         C   s   g  |  _  d  |  _ d  |  _ d  S(   N(   t   rootObjectRequestsRf   t   _brokert   _root(   R4   (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyR.    s    		c         C   s5   |  j  } |  j   x | D] } | j |  q Wd  S(   N(   R2  R.  R   (   R4   R   t	   deferredsR   (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyt   _failAll$  s    	
c         C   s   |  j  |  d  S(   N(   R6  (   R4   t	   connectorR   (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyt   clientConnectionFailed*  s    i    c         C   s,   | r d |  _ d |  _ n |  j |  d S(   s8   Reconnecting subclasses should call with reconnecting=1.N(   Rf   R3  R4  R6  (   R4   R7  R   t   reconnecting(    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyt   clientConnectionLost-  s    	c         C   sR   | |  _  | j d  |  _ |  j } g  |  _ x | D] } | j |  j  q4 Wd  S(   Nt   root(   R3  R   R4  R2  Rc   (   R4   R<   t   dsR   (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyR   7  s    			c         C   sF   |  j  r& |  j  j r& t j |  j  St j   } |  j j |  | S(   s\   Get root object of remote PB server.

        @return: Deferred of the root object.
        (   R3  R   R   t   succeedR4  R   R2  R_   (   R4   R   (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyt   getRootObject?  s
    c         C   s    |  j  r |  j  j j   n  d S(   s   If the factory is connected, close the connection.

        Note that if you set up the factory to reconnect, you will need to
        implement extra logic to prevent automatic reconnection after this
        is called.
        N(   R3  R   R   (   R4   (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyt
   disconnectJ  s    	c         C   s"   | j  d |  j |  j | |  S(   Nt   login(   Rq   t   addCallbackt   _cbResponse(   R4   R;  R  R"  t   client(    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyt   _cbSendUsernameT  s    c         C   s(   | \ } } | j  d t | |  |  S(   NR&  (   Rq   R&  (   R4   t   .1R"  RC  R!  t
   challenger(    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyRB  X  s    	c         C   s   | j  d |  S(   sb  
        Attempt an anonymous login on the given remote root object.

        @type root: L{RemoteReference}
        @param root: The object on which to attempt the login, most likely
            returned by a call to L{PBClientFactory.getRootObject}.

        @param client: A jellyable object which will be used as the I{mind}
            parameter for the login attempt.

        @rtype: L{Deferred}
        @return: A L{Deferred} which will be called back with a
            L{RemoteReference} to an avatar when anonymous login succeeds, or
            which will errback if anonymous login fails.
        t   loginAnonymous(   Rq   (   R4   R;  RC  (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyt   _cbLoginAnonymous\  s    c         C   sT   |  j    } t j |  r1 | j |  j |  n | j |  j | j | j |  | S(   s  
        Login and get perspective from remote PB server.

        Currently the following credentials are supported::

            L{twisted.cred.credentials.IUsernamePassword}
            L{twisted.cred.credentials.IAnonymous}

        @rtype: L{Deferred}
        @return: A L{Deferred} which will be called back with a
            L{RemoteReference} for the avatar logged in to, or which will
            errback if login fails.
        (   R>  R   t
   providedByRA  RH  RD  R  R"  (   R4   t   credentialsRC  R   (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyR@  o  s    N(   R,   R-   R.   R   R	   t   FalseR   R   R5   R1  R.  R6  R8  R:  R   R>  R?  RD  RB  RH  Rf   R@  (    (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyR-    s    					
			
			t   PBServerFactoryc           B   s;   e  Z d  Z e Z e Z e e d  Z d   Z	 d   Z
 RS(   s  
    Server factory for perspective broker.

    Login is done using a Portal object, whose realm is expected to return
    avatars implementing IPerspective. The credential checkers in the portal
    should accept IUsernameHashedPassword or IUsernameMD5Password.

    Alternatively, any object providing or adaptable to L{IPBRoot} can be
    used instead of a portal to provide the root object of the PB server.
    c         C   s%   t  |  |  _ | |  _ | |  _ d S(   s  
        @param root: factory providing the root Referenceable used by the broker.
        @type root: object providing or adaptable to L{IPBRoot}.

        @param unsafeTracebacks: if set, tracebacks for exceptions will be sent
            over the wire.
        @type unsafeTracebacks: C{bool}

        @param security: security options used by the broker, default to
            C{globalSecurity}.
        @type security: L{twisted.spread.jelly.SecurityOptions}
        N(   R   R;  R   R   (   R4   R;  R   R   (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyR5     s    	c         C   sD   |  j  d t d |  j  } |  | _ | j d |  j j |   | S(   sT   
        Return a Broker attached to the factory (as the service provider).
        R   R   R;  (   R	   RK  R   R   R   R;  t
   rootObject(   R4   R/  t   proto(    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyR1    s    	c         C   s   d  S(   N(    (   R4   R	   (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyR     s    (   R,   R-   R.   RK  R   R   R	   R   R5   R1  R   (    (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyRL    s   
		t   IUsernameMD5Passwordc           B   s    e  Z d  Z d   Z d   Z RS(   sb  
    I encapsulate a username and a hashed password.

    This credential is used for username/password over PB. CredentialCheckers
    which check this kind of credential must store the passwords in plaintext
    form or as a MD5 digest.

    @type username: C{str} or C{Deferred}
    @ivar username: The username associated with these credentials.
    c         C   s   d S(   s  
        Validate these credentials against the correct password.

        @type password: C{str}
        @param password: The correct, plaintext password against which to
            check.

        @rtype: C{bool} or L{Deferred}
        @return: C{True} if the credentials represented by this object match the
            given password, C{False} if they do not, or a L{Deferred} which will
            be called back with one of these values.
        N(    (   R"  (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyt   checkPassword  s    c         C   s   d S(   s  
        Validate these credentials against the correct MD5 digest of the
        password.

        @type password: C{str}
        @param password: The correct MD5 digest of a password against which to
            check.

        @rtype: C{bool} or L{Deferred}
        @return: C{True} if the credentials represented by this object match the
            given digest, C{False} if they do not, or a L{Deferred} which will
            be called back with one of these values.
        N(    (   R"  (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyt   checkMD5Password  s    (   R,   R-   R.   RP  RQ  (    (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyRO    s   
	t   _PortalRootc           B   s*   e  Z d  Z e e  d   Z d   Z RS(   s%   Root object, used to login to portal.c         C   s   | |  _  d  S(   N(   t   portal(   R4   RS  (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyR5     s    c         C   s   t  |  j |  S(   N(   t   _PortalWrapperRS  (   R4   R<   (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyRM    s    (   R,   R-   R.   R    R   R5   RM  (    (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyRR    s   
	t   _JellyableAvatarMixinc           B   s   e  Z d  Z d   Z RS(   sk   
    Helper class for code which deals with avatars which PB must be capable of
    sending to a peer.
    c            sr   | \ } }  t  j |  s0 t | d  } n  | j   }    f d   } |   j j | <  j j   | S(   s   
        Ensure that the avatar to be returned to the client is jellyable and
        set up disconnection notification to call the realm's logout object.
        R>   c              s     j  j      d  S(   N(   R<   Re   (    (   R4   t   logout(    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyt   dereferenceLogout  s    (   R   RI  RT   R   R<   R   Ra   (   R4   RE  t	   interfacet   avatarRV  R   RW  (    (   R4   RV  s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyt   _cbLogin  s    (   R,   R-   R.   RZ  (    (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyRU    s   RT  c           B   s)   e  Z d  Z d   Z d   Z d   Z RS(   s=   
    Root Referenceable object, used to login to portal.
    c         C   s   | |  _  | |  _ d  S(   N(   RS  R<   (   R4   RS  R<   (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyR5     s    	c         C   s(   t    } | t |  j |  j | |  f S(   s3   
        Start of username/password login.
        (   R!  t   _PortalAuthChallengerRS  R<   (   R4   R  t   c(    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyt   remote_login  s    	c         C   s/   |  j  j t   | t  } | j |  j  | S(   sU  
        Attempt an anonymous login.

        @param mind: An object to use as the mind parameter to the portal login
            call (possibly None).

        @rtype: L{Deferred}
        @return: A Deferred which will be called back with an avatar when login
            succeeds or which will be errbacked if login fails somehow.
        (   RS  R@  R   RI   RA  RZ  (   R4   t   mindR   (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyt   remote_loginAnonymous#  s    (   R,   R-   R.   R5   R]  R_  (    (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyRT    s   		R[  c           B   s?   e  Z d  Z e e e  d   Z d   Z d   Z d   Z	 RS(   s5   
    Called with response to password challenge.
    c         C   s(   | |  _  | |  _ | |  _ | |  _ d  S(   N(   RS  R<   R  R!  (   R4   RS  R<   R  R!  (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyR5   :  s    			c         C   s5   | |  _  |  j j |  | t  } | j |  j  | S(   N(   t   responseRS  R@  RI   RA  RZ  (   R4   R`  R^  R   (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyt   remote_respondA  s    	c         C   s   |  j  t |  j    S(   N(   RQ  R   R   (   R4   R"  (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyRP  I  s    c         C   s?   t    } | j |  | j |  j  | j   } |  j | k S(   N(   R   R  R!  R   R`  (   R4   t   md5Passwordt   mdt   correct(    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyRQ  N  s
    	(
   R,   R-   R.   R    R   RO  R5   Ra  RP  RQ  (    (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyR[  4  s   			R   R   R   R   R   R   R   R   R   R    R!   R"   R#   R$   R%   R&   R'   R   t   portnoR   R&  R!  (_   R.   R(  R   R   t   zope.interfaceR    R   t   twisted.pythonR   R   R   t   twisted.python.versionsR   t   twisted.python.deprecateR   t   twisted.python.hashlibR   t   twisted.internetR   R	   t   twisted.cred.portalR
   t   twisted.cred.credentialsR   R   R   R   t   twisted.persistedR   t   twisted.python.componentsR   t   twisted.spread.interfacesR   R   t   twisted.spread.jellyR   R   R   t   twisted.spreadR   t   twisted.spread.flavorsR   R   R   R   R   R   R   R   R   R    R!   R"   R#   R$   R%   R&   R'   R(   R)   R*   R   Re  t	   ExceptionR+   R/   R0   R1   RC   RE   RH   RI   RM   RT   t	   EphemeralRZ   Rw   R   R|   R   R   R   R   R&  R!  t   ClientFactoryR-  t   ServerFactoryRL  RO  RR  RU  RT  R[  t   __all__(    (    (    s5   /usr/lib/python2.7/dist-packages/twisted/spread/pb.pyt   <module>   s   
	!	!*+n 
  2			1*#$