Go to the latest version of this document.

# ``twisted`.`persisted`.`styles``

module documentation
(source)

Different styles of persisted objects.

Class | `Ephemeral` | This type of object is never persisted; if possible, even references to it are eliminated.
Class | `Versioned` | This type of object is persisted with versioning information.
Function | `doUpgrade` | Undocumented
Function | `pickleMethod` | support function for copy_reg to pickle method refs
Function | `pickleModule` | support function for copy_reg to pickle module refs
Function | `pickleStringI` | Reduce the given cStringI.
Function | `pickleStringO` | Reduce the given cStringO.
Function | `requireUpgrade` | Require that a Versioned instance be upgraded completely first.
Function | `unpickleMethod` | Support function for copy_reg to unpickle method refs.
Function | `unpickleModule` | support function for copy_reg to unpickle module refs
Function | `unpickleStringI` | Convert the output of `pickleStringI` into an appropriate type for the current Python version.
Function | `unpickleStringO` | Convert the output of `pickleStringO` into an appropriate type for the current python version. This may be called on Python 3 and will convert a cStringIO into an `io.StringIO`.
Variable | `oldModules` | Undocumented
Variable | `upgraded` | Undocumented
Variable | `versionedsToUpgrade` | Undocumented
Function | `_aybabtu` | Get all of the parent classes of `c`, not including `c` itself, which are strict subclasses of `Versioned`.
Function | `_methodFunction` | Retrieve the function object implementing a method name given the class it's on and a method name.
Function | `_pickleFunction` | Reduce, in the sense of `pickle`'s `object.__reduce__` special method, a function object into its constituent parts.
Function | `_unpickleFunction` | Convert a function name into a function by importing it.

def doUpgrade(): (source)

Undocumented

def pickleMethod(method): (source)

support function for copy_reg to pickle method refs

def pickleModule(module): (source)

support function for copy_reg to pickle module refs

def pickleStringI(stringi): (source)

Reduce the given cStringI.

This is only called on Python 2, because the cStringIO module only exists on Python 2.

Parameters
stringi:`cStringIO.InputType` | The string input to pickle.

Returns
2-tuple of (function, (bytes, int)) | a 2-tuple of (`unpickleStringI`, (bytes, pointer))

def pickleStringO(stringo): (source)

Reduce the given cStringO.

This is only called on Python 2, because the cStringIO module only exists on Python 2.

Parameters
stringo:`cStringIO.OutputType` | The string output to pickle.

def requireUpgrade(obj): (source)

Require that a Versioned instance be upgraded completely first.

def unpickleMethod(im_name, im_self, im_class): (source)

Support function for copy_reg to unpickle method refs.

Parameters
im_name:native `str` | The name of the method.
im_self:`object` | The instance that the method was present on.
im_class:`type` or `None` | The class where the method was declared.

def unpickleModule(name): (source)

support function for copy_reg to unpickle module refs

def unpickleStringI(val, sek): (source)

Convert the output of `pickleStringI` into an appropriate type for the current Python version.

This may be called on Python 3 and will convert a cStringIO into an `io.StringIO`.

Parameters
val:`bytes` | The content of the file.
sek:`int` | The seek position of the file.

Returns
`cStringIO.OutputType` on Python 2, `io.StringIO` on Python 3. | a file-like object which you can read bytes from.

def unpickleStringO(val, sek): (source)

Convert the output of `pickleStringO` into an appropriate type for the current python version. This may be called on Python 3 and will convert a cStringIO into an `io.StringIO`.

Parameters
val:`bytes` | The content of the file.
sek:`int` | The seek position of the file.

Returns
`cStringIO.OutputType` on Python 2, `io.StringIO` on Python 3. | a file-like object which you can write bytes to.

oldModules: `dict[str, types.ModuleType]` = (source)

Undocumented

upgraded: `dict` = (source)

Undocumented

versionedsToUpgrade: `dict[int, Versioned]` = (source)

Undocumented

def _aybabtu(c): (source)

Get all of the parent classes of `c`, not including `c` itself, which are strict subclasses of `Versioned`.

Parameters
c | a class

Returns
list of classes

def _methodFunction(classObject, methodName): (source)

Retrieve the function object implementing a method name given the class it's on and a method name.

Parameters
classObject:`type` | A class to retrieve the method's function from.
methodName:native `str` | The name of the method whose function to retrieve.

Returns
`types.FunctionType` | the function object corresponding to the given method name.

def _pickleFunction(f): (source)

Reduce, in the sense of `pickle`'s `object.__reduce__` special method, a function object into its constituent parts.

Parameters
f:`types.FunctionType` | The function to reduce.

Returns
2-tuple of `callable, native string` | a 2-tuple of a reference to `_unpickleFunction` and a tuple of its arguments, a 1-tuple of the function's fully qualified name.

def _unpickleFunction(fullyQualifiedName): (source)

Convert a function name into a function by importing it.

This is a synonym for `twisted.python.reflect.namedAny`, but imported locally to avoid circular imports, and also to provide a persistent name that can be stored (and deprecated) independently of `namedAny`.

Parameters
fullyQualifiedName:native `str` | The fully qualified name of a function.

Returns
`types.FunctionType` | A function object imported from the given location.