t.s.j._Jellier : class documentation

Part of twisted.spread.jelly View Source View In Hierarchy

(Internal) This class manages state for a call to jelly()
Method __init__ Initialize.
Method prepare (internal) Create a list for persisting an object to. This will allow backreferences to be made internal to the object. (circular references).
Method preserve (internal) Mark an object's persistent list for later referral.
Method jelly Undocumented
Method jelly_decimal Jelly a decimal object.
Method unpersistable (internal) Returns an sexp: (unpersistable "reason"). Utility method for making note that a particular object could not be serialized.
Method _cook (internal) Backreference an object.
Method _checkMutable Undocumented
Method _jellyIterable Jelly an iterable object.
def __init__(self, taster, persistentStore, invoker): (source)
Initialize.
def _cook(self, object): (source)

(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
def prepare(self, object): (source)

(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]].
def preserve(self, object, sexp): (source)
(internal) Mark an object's persistent list for later referral.
def _checkMutable(self, obj): (source)
Undocumented
def jelly(self, obj): (source)
Undocumented
def _jellyIterable(self, atom, obj): (source)
Jelly an iterable object.
Parametersatomthe identifier atom of the object. (type: str )
objany iterable object. (type: iterable )
Returnsa generator of jellied data. (type: generator )
def jelly_decimal(self, d): (source)
Jelly a decimal object.
Parametersda decimal object to serialize. (type: decimal.Decimal )
Returnsjelly for the decimal object. (type: list )
def unpersistable(self, reason, sxp=None): (source)
(internal) Returns an sexp: (unpersistable "reason"). Utility method for making note that a particular object could not be serialized.
API Documentation for Twisted, generated by pydoctor at 2011-10-27 16:17:34.