Your IP : 172.28.240.42


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


Nc@sdZddlZddlZddlZddlmZddlmZddlmZddlmZddlmZddlm	Z	dd	lm
Z
dd
lmZddlmZddlm
Z
dd
lmZddlmZddlmZddlmZddlZddlZddlmZyddlZWnek
r[eZnXy
eZWnek
reZnXz/ejddedddeddlZWdej j!Xddl"m#Z#ddl$m%Z%m&Z&ddl'm(Z(m)Z)m*Z*ddl'm+Z+m,Z,ddl'm-Z-ddl.m/Z/ddl0m1Z1m2Z2efZ3dZ4dZ5d Z6d!Z7d"Z8d#Z9d$Z:d%Z;d&Z<d'Z=d(Z>d)Z?d*Z@d+ZAiaBiaCeDZEeEd,ZFd-ZGd.ZHd/ZIed0ZJd1ZKd2ZLd3fd4YZMd5fd6YZNd7fd8YZOd9fd:YZPd;fd<YZQd=fd>YZRd?eDfd@YZSdAZTdBeUfdCYZVdDfdEYZWdFfdGYZXeXZYeYjZeWeedHZ[eWeedIZ\dS(Js
S-expression-based persistence of python objects.

It does something very much like L{Pickle<pickle>}; however, pickle's main goal
seems to be efficiency (both in space and time); jelly's main goals are
security, human readability, and portability to other environments.

This is how Jelly converts various objects to s-expressions.

Boolean::
    True --> ['boolean', 'true']

Integer::
    1 --> 1

List::
    [1, 2] --> ['list', 1, 2]

String::
    "hello" --> "hello"

Float::
    2.3 --> 2.3

Dictionary::
    {'a': 1, 'b': 'c'} --> ['dictionary', ['b', 'c'], ['a', 1]]

Module::
    UserString --> ['module', 'UserString']

Class::
    UserString.UserString --> ['class', ['module', 'UserString'], 'UserString']

Function::
    string.join --> ['function', 'join', ['module', 'string']]

Instance: s is an instance of UserString.UserString, with a __dict__
{'data': 'hello'}::
    ["UserString.UserString", ['dictionary', ['data', 'hello']]]

Class Method: UserString.UserString.center::
    ['method', 'center', ['None'], ['class', ['module', 'UserString'],
     'UserString']]

Instance Method: s.center, where s is an instance of UserString.UserString::
    ['method', 'center', ['instance', ['reference', 1, ['class',
    ['module', 'UserString'], 'UserString']], ['dictionary', ['data', 'd']]],
    ['dereference', 1]]

The C{set} builtin and the C{sets.Set} class are serialized to the same
thing, and unserialized to C{set} if available, else to C{sets.Set}. It means
that there's a possibility of type switching in the serialization process. The
solution is to always use C{set} if possible, and only use C{sets.Set} under
Python 2.3; this can be accomplished by using L{twisted.python.compat.set}.

The same rule applies for C{frozenset} and C{sets.ImmutableSet}.

@author: Glyph Lefkowitz
iN(t
StringType(tUnicodeType(tIntType(t	TupleType(tListType(tLongType(t	FloatType(tFunctionType(t
MethodType(t
ModuleType(tDictionaryType(tInstanceType(tNoneType(t	ClassType(tBooleanTypetignoretcategorytmessagesthe sets module is deprecatedtappend(t
implements(tnamedObjecttqual(tNotKnownt_Tuplet_InstanceMethod(t_DictKeyAndValuet_Dereference(t
_Container(treduce(t
IJellyabletIUnjellyabletNonetclasstmoduletfunctiontdereferencet
persistentt	referencet
dictionarytlisttsetttupletinstancet	frozensett
unpersistablecCsqt|tjsC|j|}|tk	rm|jj|qmn*|tk	rat||}nt|}|S(s
    Make a new instance of a class without calling its __init__ method.
    Supports both new- and old-style classes.

    @param state: A C{dict} used to update C{inst.__dict__} or C{_NO_STATE}
        to skip this part of initialization.

    @return: A new instance of C{cls}.
    (t
isinstancettypesR
t__new__t	_NO_STATEt__dict__tupdateR(tclststatetinst((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pyt_newInstances
cCsTytWntk
r!d}nXt|t}t|tsF|rPt|S|S(Ni(tobjectt	NameErrorR-ttypeR
R(t
classnameptisObject((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pyt_maybeClasss


cCs't|}|t|<tj|dS(st
    Set which local class will represent a remote type.

    If you have written a Copyable class that you expect your client to be
    receiving, write a local "copy" class to represent it, then call::

        jellier.setUnjellyableForClass('module.package.Class', MyCopier).

    Call this at the module level immediately after its class
    definition. MyCopier should be a subclass of RemoteCopy.

    The classname may be a special tag returned by
    'Copyable.getTypeToCopyFor' rather than an actual classname.

    This call is also for cached classes, since there will be no
    overlap.  The rules are the same.
    N(R<tunjellyableRegistrytglobalSecurityt
allowTypes(t	classnametunjellyable((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pytsetUnjellyableForClasss
cCs't|}|t|<tj|dS(s
    Set the factory to construct a remote instance of a type::

      jellier.setUnjellyableFactoryForClass('module.package.Class', MyFactory)

    Call this at the module level immediately after its class definition.
    C{copyFactory} should return an instance or subclass of
    L{RemoteCopy<pb.RemoteCopy>}.

    Similar to L{setUnjellyableForClass} except it uses a factory instead
    of creating an instance.
    N(R<tunjellyableFactoryRegistryR>R?(R@tcopyFactory((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pytsetUnjellyableFactoryForClasss
cCs|dkr|j}n|r+d|}nxdt|D]V}t||}t|tjkr8t||rtd||f|qq8q8WdS(s
    Set all classes in a module derived from C{baseClass} as copiers for
    a corresponding remote class.

    When you have a heirarchy of Copyable (or Cacheable) classes on one
    side, and a mirror structure of Copied (or RemoteCache) classes on the
    other, use this to setUnjellyableForClass all your Copieds for the
    Copyables.

    Each copyTag (the "classname" argument to getTypeToCopyFor, and
    what the Copyable's getTypeToCopyFor returns) is formed from
    adding a prefix to the Copied's class name.  The prefix defaults
    to module.__name__.  If you wish the copy tag to consist of solely
    the classname, pass the empty string ''.

    @param module: a module object from which to pull the Copied classes.
        (passing sys.modules[__name__] might be useful)

    @param baseClass: the base class from which all your Copied classes derive.

    @param prefix: the string prefixed to classnames to form the
        unjellyableRegistry.
    s%s.s%s%sN(	Rt__name__tdirtgetattrR9R.R
t
issubclassRB(R!t	baseClasstprefixtiti_((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pytsetUnjellyableForClassTrees
cCskt|dr|j}n	|j}|j|}|jt|j|j|g|j||S(sM
    Utility method to default to 'normal' state rules in serialization.
    t__getstate__(	thasattrROR1tpreparetextendRt	__class__tjellytpreserve(R5tjellierR4tsxp((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pytgetInstanceStates	%cCs?|j|d}t|dr2|j|n	||_|S(sO
    Utility method to default to 'normal' state rules in unserialization.
    it__setstate__(tunjellyRPRYR1(R5t	unjelliert	jellyListR4((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pytsetInstanceStates
	t
UnpersistablecBs eZdZdZdZRS(sd
    This is an instance of a class that comes back when something couldn't be
    unpersisted.
    cCs
||_dS(sY
        Initialize an unpersistable object with a descriptive C{reason} string.
        N(treason(tselfR_((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pyt__init__2scCsdt|jS(NsUnpersistable(%s)(treprR_(R`((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pyt__repr__9s(RFt
__module__t__doc__RaRc(((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pyR^,s	t	JellyablecBs*eZdZeedZdZRS(sc
    Inherit from me to Jelly yourself directly with the `getStateFor'
    convenience method.
    cCs|jS(N(R1(R`RV((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pytgetStateForEscCsM|j|}|jt|j|j|j|g|j||S(sH
        @see: L{twisted.spread.interfaces.IJellyable.jellyFor}
        (RQRRRRSRTRgRU(R`RVRW((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pytjellyForIs
(RFRdReRRRgRh(((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pyRf>s
	tUnjellyablecBs*eZdZeedZdZRS(sf
    Inherit from me to Unjelly yourself directly with the
    C{setStateFor} convenience method.
    cCs
||_dS(N(R1(R`R[R4((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pytsetStateFor\scCs'|j|d}|j|||S(s
        Perform the inverse operation of L{Jellyable.jellyFor}.

        @see: L{twisted.spread.interfaces.IUnjellyable.unjellyFor}
        i(RZRj(R`R[R\R4((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pyt
unjellyFor`s(RFRdReRRRjRk(((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pyRiUs
	t_JelliercBseZdZdZdZdZdZidej6dej	6dej
6dej6ZdZ
dZdZd	Zdd
ZRS(sC
    (Internal) This class manages state for a call to jelly()
    cCsC||_i|_i|_i|_d|_||_||_dS(s
        Initialize.
        iN(ttastert	preservedtcookedtcookert_ref_idtpersistentStoretinvoker(R`RmRrRs((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pyRaqs						cCsh|jt|}tj|}|j}|jd|_t||g|(t|g|jt|<|S(s
        (internal) Backreference an object.

        Notes on this method for the hapless future maintainer: If I've already
        gone through the prepare/preserve cycle on the specified object (it is
        being referenced after the serializer is "done with" it, e.g. this
        reference is NOT circular), the copy-in-place of aList is relevant,
        since the list being modified is the actual, pre-existing jelly
        expression that was returned for that object. If not, it's technically
        superfluous, since the value in self.preserved didn't need to be set,
        but the invariant that self.preserved[id(object)] is a list is
        convenient because that means we don't have to test and create it or
        not create it here, creating fewer code-paths.  that's why
        self.preserved is always set to a list.

        Sorry that this code is so hard to follow, but Python objects are
        tricky to persist correctly. -glyph
        i(RntidtcopyRqtreference_atomtdereference_atomRo(R`R7taListtnewListtrefid((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pyt_cooks	cCs*g|jt|<||jt|<gS(s]
        (internal) Create a list for persisting an object to.  This will allow
        backreferences to be made internal to the object. (circular
        references).

        The reason this needs to happen is that we don't generate an ID for
        every object, so we won't necessarily know which ID the object will
        have in the future.  When it is 'cooked' ( see _cook ), it will be
        assigned an ID, and the temporary placeholder list created here will be
        modified in-place to create an expression that gives this object an ID:
        [reference id# [object-jelly]].
        (RnRtRp(R`R7((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pyRQscCsYt||jkrB||jt|d<|jt|}n||jt|<|S(sQ
        (internal) Mark an object's persistent list for later referral.
        i(RtRoRn(R`R7tsexp((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pyRUs
icCsQt|}||jkr&|j|S||jkrM|j||j|SdS(N(RtRoRnR{(R`tobjtobjId((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pyt
_checkMutables
cCs_t|tr5|j|}|r(|S|j|St|}|jjt|r|tks|t	ks|t
ks|tkr|S|tkrd|j
j|j|j|j|jgStr|tkrd|jdgS|tkrdgS|tkr;|j}dttj||jd|gS|tkrTd|jgS|tkrvd|rod	prd
gS|tjkr|jrtdndd
|j|j|j |j!|j"|j#|j$fgS|tj%kr"|jrtdndd|j!|j"|j#|j$fgS|tj&krQdd|j|j|j fgS|tj'krdd|j(|j)|j*fgS|t+kst,|trdt|gSt-dk	r|t-j/kr|j0|S|j|}|r|S|j1|}|t2kr#|j3|j4t5|n|t6krK|j3|j4t7|n|t8kr|j9t:x|j;D]1\}}|j9|j||j|gqqWnat<dk	r|t=ks|t>j?kr|j3|j4t@|nt<dk	r|tAks|t>jBkr/|j3|j4tC|nt|jD}d}	|jErb|jE||}	n|	dk	r|j9tF|j9|	n|jjG|jDr|j9|tH|dr|jI}
n	|jJ}
|j9|j|
n|jKdt|jD||jL||Sn>|tMkrEtNd|jD|fntNd||fdS(NtmethodtunicodesUTF-8RR"t.R!tbooleanttruetfalses2Currently can't jelly datetime objects with tzinfotdatetimes%s %s %s %s %s %s %sttimes%s %s %s %stdates%s %s %st	timedeltaR ROs$instance of class %s deemed insecures%Class not allowed for instance: %s %ss"Type not allowed for object: %s %s(OR-RfRRhR9Rmt
isTypeAllowedRRRRRRtim_funcRFRTtim_selftim_classRtencodeRRtstrtpickletwhichmoduleR	RRttzinfotNotImplementedErrortyeartmonthtdaythourtminutetsecondtmicrosecondRRRtdaystsecondstmicrosecondsR
RItdecimalRtDecimalt
jelly_decimalRQRRRt_jellyIterablet	list_atomRt
tuple_atomt	DictTypesRtdictionary_atomtitemst_setR(t_setstSettset_atomR+tImmutableSettfrozenset_atomRSRrtpersistent_atomtisClassAllowedRPROR1R,RURt
InsecureJelly(R`R}tpreReftobjTypetnameRWtkeytvalt	classNameR$R4((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pyRTs
		
		 

,	

	ccs(|Vx|D]}|j|VqWdS(s
        Jelly an iterable object.

        @param atom: the identifier atom of the object.
        @type atom: C{str}

        @param obj: any iterable object.
        @type obj: C{iterable}

        @return: a generator of jellied data.
        @rtype: C{generator}
        N(RT(R`tatomR}titem((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pyR;s

cCsD|j\}}}td|}|r7|}nd||gS(s
        Jelly a decimal object.

        @param d: a decimal object to serialize.
        @type d: C{decimal.Decimal}

        @return: jelly for the decimal object.
        @rtype: C{list}
        cSs|d|S(Ni
((tlefttright((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pyt<lambda>XsR(tas_tupleR(R`tdtsigntgutstexponenttvalue((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pyRMs


cCs3|dkrg}n|jt|j||S(s
        (internal) Returns an sexp: (unpersistable "reason").  Utility method
        for making note that a particular object could not be serialized.
        N(RRtunpersistable_atom(R`R_RW((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pyR,^s
	

N(RFRdReRaR{RQRUR.RRRRt
constantTypesRRTRRRR,(((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pyRlls							g		t
_UnjelliercBseZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
dZd
ZdZdZdZdZdZdZdZdZdZdZdZdZdZRS(cCs1||_||_i|_g|_||_dS(N(RmtpersistentLoadt
referencest
postCallbacksRs(R`RmRRs((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pyRams
				cCs.|j|}x|jD]
}|qW|S(N(RZR(R`R}totm((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pytunjellyFulluscCst|tjk	r|S|d}|jj|sDt|ntj|}|dk	rt	|t
rt}||_|j
}n0t	|tr|j|}|j
}n|}|||}t|dr|jj|jn|Stj|}|dk	rW|j|d}||}t|drS|jj|jn|St|d|d}	|	dk	r|	|d}
n|jd}dj|d }|jj|std||fnt|}
|jj|
s
td|nt|
d	rHt|
}
|j|d}|
j|n"|j|d}t|
|}
t|
dr|jj|
jn|
S(
NitpostUnjellyis_unjelly_%sRis#Module %s not allowed (in type %s).sClass %s not allowed.RY(R9R.RRmRRR=tgetRR-R
t_DummyRSRkR/RPRRRRCRZRHtsplittjointisModuleAllowedRRR6RY(R`R}tjelTypetregClassR5RRt
regFactoryR4tthunktrett	nameSplittmodNametclz((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pyRZ|s\
		cCsdS(N(R(R`texp((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pyt
_unjelly_NonescCs0trt|ddStd|dfSdS(NisUTF-8sCould not unpersist unicode: %s(RRR^(R`R((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pyt_unjelly_unicodescCstdkr-td|dd|dfS|d}|d}|dkrVd}nd}tj|jd}tj|||fS(s}
        Unjelly decimal objects, if decimal is available. If not, return a
        L{Unpersistable} object instead.
        sCould not unpersist decimal: %sii
iN(RRR^RR(R`RRRRR((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pyt_unjelly_decimals

	cCsCtr*|ddkst|ddkStd|dfSdS(NiRRsCould not unpersist boolean: %s(struesfalse(RtAssertionErrorR^(R`R((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pyt_unjelly_booleanscCs tjtt|djS(Ni(RtmaptintR(R`R((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pyt_unjelly_datetimescCs tjtt|djS(Ni(RRRRR(R`R((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pyt
_unjelly_datescCs tjtt|djS(Ni(RRRRR(R`R((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pyt
_unjelly_timescCs>tt|dj\}}}tjd|d|d|S(NiRRR(RRRRR(R`RRRR((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pyt_unjelly_timedeltas"	cCs?|j|}t|tr1|j||n|||<|S(N(RZR-RtaddDependant(R`R}tloctjelR((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pytunjellyIntos

cCsI|d}|jj|}|dk	r,|St|}||j|<|S(Ni(RRRR(R`tlstRztxtder((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pyt_unjelly_dereferences

cCs|d}|d}|j|}|jj|}|dkrQ||j|<n>t|tr}|j|||j|<ndstd|S(Niis!Multiple references with same ID!(RZRRRR-RtresolveDependantsR(R`RRzRRtref((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pyt_unjelly_references


cCsrtt|}d}x9|D]1}t|j||||trd}qqW|rdt|St|SdS(Nii(trangetlenR-RRR)R(R`Rtltfinishedtelem((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pyt_unjelly_tuple	s
"

cCs>tt|}x%|D]}|j||||qW|S(N(RRR(R`RRR((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pyt
_unjelly_lists
cCs{tt|}t}x?|D]7}|j||||}t|trt}qqW|smt||S||SdS(s
        Helper method to unjelly set or frozenset.

        @param lst: the content of the set.
        @type lst: C{list}

        @param containerType: the type of C{set} to use.
        N(RRtTrueRR-RtFalseR(R`Rt
containerTypeRRRtdata((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pyt_unjellySetOrFrozensets	


cCs.tdk	rt}n	tj}|j||S(so
        Unjelly set using either the C{set} builtin if available, or
        C{sets.Set} as fallback.
        N(RRR(RRR(R`RR((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pyt_unjelly_set1s		cCs.tdk	rt}n	tj}|j||S(s
        Unjelly frozenset using either the C{frozenset} builtin if available,
        or C{sets.ImmutableSet} as fallback.
        N(RRR+RRR(R`RR((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pyt_unjelly_frozenset=s		cCsSi}xF|D]>\}}t|}|j|d||j|d|q
W|S(Nii(RR(R`RRtktvtkvd((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pyt_unjelly_dictionaryIscCso|d}t|tjkr.tdn|jj|sVtd|fnt|iid}|S(Nis5Attempted to unjelly a module with a non-string name.s$Attempted to unjelly module named %rR(R9R.RRRmRt
__import__(R`trestt
moduleNametmod((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pyt_unjelly_moduleRs
cCs|djd}dj|d }|jj|sKtd|nt|d}t|}|tjtj	fkrtd|d|fn|jj
|stdt|n|S(NiRismodule %s not alloweds6class %r unjellied to something that isn't a class: %rsclass not allowed: %s(RRRmRRRR9R.R
tTypeTypeRR(R`RtclistRtklausR((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pyt_unjelly_class^scCs_|djd}dj|d }|jj|sKtd|nt|d}|S(NiRisModule not allowed: %s(RRRmRRR(R`RtmodSplitRR"((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pyt_unjelly_functionnscCs1|jr#|j|d|}|StdSdS(NisPersistent callback not found(RR^(R`Rtpload((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pyt_unjelly_persistentxs	cCs|j|d}t|tjk	r7tdnt|drxt|i}|j|d}|j|n"|j|d}t||}t|dr|jj	|j
n|S(Nis$Instance found with non-class class.RYiR(RZR9R.R
RRPR6RYRRR(R`RRR5R4((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pyt_unjelly_instancescCstd|dfS(NsUnpersistable data: %si(R^(R`R((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pyt_unjelly_unpersistablescCs|d}|j|d}|j|d}t|tjk	rTtdn||jkr|dkrt||}qt|t	rt
|||}qt|j|||}ntd|S(s.
        (internal) Unjelly a method.
        iiis"Method found with non-class class.sinstance method changedN(
RZR9R.R
RR1RRHR-RRRt	TypeError(R`Rtim_nameRRtim((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pyt_unjelly_methods
(RFRdRaRRZRRRRRRRRRRRRRRRRRRR	RR
RRR(((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pyRks6			5										
											
			RcBseZdZRS(sC
    (Internal) Dummy class, used for unserializing instances.
    (RFRdRe(((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pyRst_DummyNewStylecBseZdZRS(s\
    (Internal) Dummy class, used for unserializing instances of new-style
    classes.
    (RFRdRe(((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pyRscCsCt|jtrt}n	t}|j|_|j|_|S(s
    Create a new instance like C{instance}.

    The new instance has the same class and instance dictionary as the given
    instance.

    @return: The new instance.
    (R-RSR9RRR1(R*tdummy((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pyt
_newDummyLikes		RcBseZdZRS(s
    This exception will be raised when a jelly is deemed `insecure'; e.g. it
    contains a type, class, or module disallowed by the specified `taster'
    (RFRdRe(((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pyRstDummySecurityOptionscBs)eZdZdZdZdZRS(s{
    DummySecurityOptions() -> insecure security options
    Dummy security options -- this class will allow anything.
    cCsdS(s
        DummySecurityOptions.isModuleAllowed(moduleName) -> boolean
        returns 1 if a module by that name is allowed, 0 otherwise
        i((R`R((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pyRscCsdS(s
        DummySecurityOptions.isClassAllowed(class) -> boolean
        Assumes the module has already been allowed.  Returns 1 if the given
        class is allowed, 0 otherwise.
        i((R`tklass((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pyRscCsdS(s
        DummySecurityOptions.isTypeAllowed(typeName) -> boolean
        Returns 1 if the given type is allowed, 0 otherwise.
        i((R`ttypeName((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pyRs(RFRdReRRR(((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pyRs			tSecurityOptionsc
BszeZdZddddddddd	d
g
ZdZdZd
ZdZdZdZ	dZ
dZRS(sF
    This will by default disallow everything, except for 'none'.
    R&R'R)R%R#R,R$tlong_inttlongtdictcCsidd6dd6dd6dd6dd6dd6dd6dd	6dd
6dd6dd6dd
6|_ttdr|d|jd<ntdk	rd|jd<nd|jd<d|jd<i|_i|_dS(s/
        SecurityOptions() initialize.
        iRtboolRtstringRRtfloatRRRRRRRRR(R+N(tallowedTypesRPR.RRtallowedModulestallowedClasses(R`((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pyRas(



	cCs|j|jdS(sz
        Allow all `basic' types.  (Dictionary and list.  Int, string, and float
        are implicitly allowed.)
        N(R?t
basicTypes(R`((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pytallowBasicTypesscGs@x9|D]1}t|ts+t|}nd|j|<qWdS(sg
        SecurityOptions.allowTypes(typeString): Allow a particular type, by its
        name.
        iN(R-RRR!(R`R.ttyp((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pyR?$s
cGse|j|jddddx>|D]6}|jt||j|jd|j|<q'WdS(s
        SecurityOptions.allowInstances(klass, klass, ...): allow instances
        of the specified classes

        This will also allow the 'instance', 'class' (renamed 'classobj' in
        Python 2.3), and 'module' types, as well as basic types.
        R*R tclassobjR!iN(R%R?RtallowModulesRdR#(R`tclassesR((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pytallowInstancesOf/s

cGsCx<|D]4}t|tjkr.|j}nd|j|<qWdS(s
        SecurityOptions.allowModules(module, module, ...): allow modules by
        name. This will also allow the 'module' type.
        iN(R9R.R	RFR"(R`tmodulesR!((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pyR(?s
cCs
||jkS(s
        SecurityOptions.isModuleAllowed(moduleName) -> boolean
        returns 1 if a module by that name is allowed, 0 otherwise
        (R"(R`R((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pyRJscCs
||jkS(s
        SecurityOptions.isClassAllowed(class) -> boolean
        Assumes the module has already been allowed.  Returns 1 if the given
        class is allowed, 0 otherwise.
        (R#(R`R((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pyRRscCs||jkpd|kS(s
        SecurityOptions.isTypeAllowed(typeName) -> boolean
        Returns 1 if the given type is allowed, 0 otherwise.
        R(R!(R`R((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pyR[s(RFRdReR$RaR%R?R*R(RRR(((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pyRs										cCst|||j|S(s
    Serialize to s-expression.

    Returns a list which is the serialized representation of an object.  An
    optional 'taster' argument takes a SecurityOptions and will mark any
    insecure objects as unpersistable rather than serializing them.
    (RlRT(R7RmRrRs((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pyRThs	cCst|||j|S(sU
    Unserialize from s-expression.

    Takes an list that was the result from a call to jelly() and unserializes
    an arbitrary object from it.  The optional 'taster' argument, an instance
    of SecurityOptions, will cause an InsecureJelly exception to be raised if a
    disallowed type, module, or class attempted to unserialize.
    (RR(R|RmRRs((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pyRZus
(]ReRR.twarningsRRRRRRRRRR	R
RRR
RuRRRtImportErrorRR(RR8tfilterwarningstDeprecationWarningRtsetsRtfilterstpoptzope.interfaceRttwisted.python.reflectRRttwisted.persisted.crefutilRRRRRRttwisted.python.compatRttwisted.spread.interfacesRRRt	None_atomt
class_atomtmodule_atomt
function_atomRwRRvRRRRt
instance_atomRRR=RCR7R0R6R<RBRERNRXR]R^RfRiRlRRRRt	ExceptionRRRR>R%RTRZ(((s8/usr/lib/python2.7/dist-packages/twisted/spread/jelly.pyt<module>?s





			
		&		
@	 l