Your IP : 172.28.240.42


Current Path : /usr/lib/python2.7/dist-packages/twisted/persisted/
Upload File :
Current File : //usr/lib/python2.7/dist-packages/twisted/persisted/styles.pyc


igNc@sdZddlZddlZddlZddlZddlZyddlZWnek
rqddlZnXddl	m
Z
ddl	mZiZdZ
dZejeje
edZdZejejeed	Zd
Zeedr"ejejeendZd
Zeedr\ejejeendddYZiaiadZdZdZ dddYZ!dS(s(
Different styles of persisted objects.
iN(tlog(treflectcCst|jj|j|jffS(s3support function for copy_reg to pickle method refs(tunpickleMethodtim_funct__name__tim_selftim_class(tmethod((s</usr/lib/python2.7/dist-packages/twisted/persisted/styles.pytpickleMethod scCsy?t||}|dkr"|Stj|j||}|SWntk
rtjd|d||dk	s}tdt|j	|}tjd||dkr|Stj|j||j	}|SXdS(s5support function for copy_reg to unpickle method refstMethodsnot on classs'No recourse: no instance to guess from.sAttempting fixup withN(
tgetattrtNonettypest
MethodTypeRtAttributeErrorRtmsgtAssertionErrort	__class__(tim_nameRRtunboundtbound((s</usr/lib/python2.7/dist-packages/twisted/persisted/styles.pyR&s
cCst|jffS(s3support function for copy_reg to pickle module refs(tunpickleModuleR(tmodule((s</usr/lib/python2.7/dist-packages/twisted/persisted/styles.pytpickleModuleAscCsMtj|r:tjd|t|}tj|nt|iidS(s5support function for copy_reg to unpickle module refssModule has moved: %stx(t
oldModulesthas_keyRRt
__import__(tname((s</usr/lib/python2.7/dist-packages/twisted/persisted/styles.pyREs

cCst|j|jffS(s<support function for copy_reg to pickle StringIO.OutputTypes(tunpickleStringOtgetvaluettell(tstringo((s</usr/lib/python2.7/dist-packages/twisted/persisted/styles.pyt
pickleStringORscCs*tj}|j||j||S(N(tStringIOtwritetseek(tvaltsekR((s</usr/lib/python2.7/dist-packages/twisted/persisted/styles.pyRVs

t
OutputTypecCst|j|jffS(N(tunpickleStringIRR(tstringi((s</usr/lib/python2.7/dist-packages/twisted/persisted/styles.pyt
pickleStringIascCs tj|}|j||S(N(R"R$(R%R&R((s</usr/lib/python2.7/dist-packages/twisted/persisted/styles.pyR(ds
t	InputTypet	EphemeralcBs eZdZdZdZRS(sh
    This type of object is never persisted; if possible, even references to it
    are eliminated.
    cCsvtjd|ddl}dtjkrrt|ddrrx.|j|D]}tjd|fqNWqrndS(Ns!WARNING: serializing ephemeral %sit__pypy__t
get_referrerss referred to by %s(RRtgctsystbuiltin_module_namesR
RR.(tselfR/tr((s</usr/lib/python2.7/dist-packages/twisted/persisted/styles.pyt__getstate__uscCs!tjd|jt|_dS(Ns#WARNING: unserializing ephemeral %s(RRRR,(R2tstate((s</usr/lib/python2.7/dist-packages/twisted/persisted/styles.pyt__setstate__~s(Rt
__module__t__doc__R4R6(((s</usr/lib/python2.7/dist-packages/twisted/persisted/styles.pyR,os		cCs1xtjD]}t|q
WiaiadS(N(tversionedsToUpgradetvaluestrequireUpgradetupgraded(t	versioned((s</usr/lib/python2.7/dist-packages/twisted/persisted/styles.pyt	doUpgradescCs@t|}|tkr<|tkr<dt|<|j|SdS(sDRequire that a Versioned instance be upgraded completely first.
    iN(tidR9R<tversionUpgrade(tobjtobjID((s</usr/lib/python2.7/dist-packages/twisted/persisted/styles.pyR;s


cCsY|tg}xBtj|D]1}||krt|tr|j|qqW|dS(s4
    Get all of the parent classes of C{c}, not including C{c} itself, which are
    strict subclasses of L{Versioned}.

    The name comes from "all your base are belong to us", from the deprecated
    L{twisted.python.reflect.allYourBase} function.

    @param c: a class
    @returns: list of classes
    i(t	Versionedtinspecttgetmrot
issubclasstappend(tctltb((s</usr/lib/python2.7/dist-packages/twisted/persisted/styles.pyt_aybabtus

RCcBs8eZdZdZdZdZddZdZRS(s
    This type of object is persisted with versioning information.

    I have a single class attribute, the int persistenceVersion.  After I am
    unserialized (and styles.doUpgrade() is called), self.upgradeToVersionX()
    will be called for each version upgrade I must undergo.

    For example, if I serialize an instance of a Foo(Versioned) at version 4
    and then unserialize it when the code is at version 9, the calls::

      self.upgradeToVersion5()
      self.upgradeToVersion6()
      self.upgradeToVersion7()
      self.upgradeToVersion8()
      self.upgradeToVersion9()

    will be made.  If any of these methods are undefined, a warning message
    will be printed.
    icCs|tt|<||_dS(N(R9R?t__dict__(R2R5((s</usr/lib/python2.7/dist-packages/twisted/persisted/styles.pyR6scCstj|p|j}t|j}|j|j|jx|D]w}|jjdrx-|jD]}|j|rj||=qjqjWn|jjdrH|j|dt	j
|<qHqHW|S(sAGet state, adding a version number to it on its way out.
        tpersistenceForgetstpersistenceVersions%s.persistenceVersion(tcopyRLRKRtreverseRGRRMRNRtqual(R2tdicttdcttbasestbasetslot((s</usr/lib/python2.7/dist-packages/twisted/persisted/styles.pyR4s

!c
	Cst|j}|j|j|j|jjdr|jd}|jd=d}d	}xG|D]?}|jjdsqen|j|kre|}|j}qeqeW|r||jdtj	|<qnx-|D]%}t
|jkr|jjdrqn|j}dtj	|}|jj|p4d}|rJ|j|=n||ksbt
dx||kr|d}|jjd|d	}	|	rtjdtj	|tj	|jt||f|	|qetjd||fqeWqWd	S(
s)(internal) Do a version upgrade.
        RNis%s.persistenceVersions"Sorry, can't go backwards in time.isupgradeToVersion%ss'Upgrading %s (of %s @ %s) to version %ss(Warning: cannot upgrade %s to version %sN(RKRRPRGRLRRRNRRQRCt	__bases__tgetRRRR?(
R2RTtpverthighestVersionthighestBaseRUtcurrentVerstpverNametpersistVersR((s</usr/lib/python2.7/dist-packages/twisted/persisted/styles.pyR@sB




 
	

8
(N(	RR7R8RNRMR6RR4R@(((s</usr/lib/python2.7/dist-packages/twisted/persisted/styles.pyRCs	((("R8Rtcopy_regRORDR0t	cStringIOR"tImportErrorttwisted.pythonRRRRRtpickleR
RRt
ModuleTypeR!RthasattrR'R*R(R+R,R9R<R>R;RKRC(((s</usr/lib/python2.7/dist-packages/twisted/persisted/styles.pyt<module>	sR