Package twisted :: Package spread :: Module jelly

[show private | hide private]
[frames | no frames]

## Module twisted.spread.jelly

Classes
`DummySecurityOptions` | DummySecurityOptions() -> insecure security options Dummy security options -- this class will allow anything.
`Jellyable` | Inherit from me to Jelly yourself directly.
`SecurityOptions` | This will by default disallow everything, except for 'none'.
`Unjellyable` | Inherit from me to Unjelly yourself directly.
`Unpersistable` | This is an instance of a class that comes back when something couldn't be persisted.

Exceptions
`InsecureJelly` | This exception will be raised when a jelly is deemed `insecure'; e.g.

Function Summary
| ``getInstanceState`(inst, jellier)` Utility method to default to 'normal' state rules in serialization.
| ``jelly`(object, taster, persistentStore, invoker)` Serialize to s-expression.
| ``setInstanceState`(inst, unjellier, jellyList)` Utility method to default to 'normal' state rules in unserialization.
| ``setUnjellyableFactoryForClass`(classname, copyFactory)` Set the factory to construct a remote instance of a type:
| ``setUnjellyableForClass`(classname, unjellyable)` Set which local class will represent a remote type.
| ``setUnjellyableForClassTree`(module, baseClass, prefix)` Set all classes in a module derived from `baseClass`as copiers for a corresponding remote class.
| ``unjelly`(sexp, taster, persistentLoad, invoker)` Unserialize from s-expression.

Variable Summary
`string` | `__version__`
`None` | `BooleanType`
`string` | `class_atom`
`string` | `dereference_atom`
`string` | `dictionary_atom`
`tuple` | `DictTypes`
`string` | `function_atom`
`SecurityOptions` | `globalSecurity`
`string` | `instance_atom`
`string` | `list_atom`
`string` | `module_atom`
`string` | `None_atom`
`string` | `persistent_atom`
`string` | `reference_atom`
`string` | `tuple_atom`
`dictionary` | `unjellyableFactoryRegistry`
`dictionary` | `unjellyableRegistry`
`string` | `unpersistable_atom`

Function Details

### getInstanceState(inst, jellier)

Utility method to default to 'normal' state rules in serialization.

### jelly(object, taster=<twisted.spread.jelly.DummySecurityOptions instan..., persistentStore=None, invoker=None)

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.

### setInstanceState(inst, unjellier, jellyList)

Utility method to default to 'normal' state rules in unserialization.

### setUnjellyableFactoryForClass(classname, copyFactory)

Set the factory to construct a remote instance of a type:

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

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

Similar to `setUnjellyableForClass` except it uses a factory instead of creating an instance.

### setUnjellyableForClass(classname, unjellyable)

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', MyJellier).

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.

### setUnjellyableForClassTree(module, baseClass, prefix=None)

Set all classes in a module derived from `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 setCopierForClass 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 ''.

  Parameters:
    `module` - a module object from which to pull the Copied classes. (passing sys.modules[__name__] might be useful)
    `baseClass` - the base class from which all your Copied classes derive.
    `prefix` - the string prefixed to classnames to form the unjellyableRegistry.

### unjelly(sexp, taster=<twisted.spread.jelly.DummySecurityOptions instan..., persistentLoad=None, invoker=None)

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.

Variable Details

### __version__

  Type:
    `string`
  Value:

        '1.41'

### BooleanType

  Type:
    `None`
  Value:

        None

### class_atom

  Type:
    `string`
  Value:

        'class'

### dereference_atom

  Type:
    `string`
  Value:

        'dereference'

### dictionary_atom

  Type:
    `string`
  Value:

        'dictionary'

### DictTypes

  Type:
    `tuple`
  Value:

        (<type 'dictionary'>,)

### function_atom

  Type:
    `string`
  Value:

        'function'

### globalSecurity

  Type:
    `SecurityOptions`
  Value:

        <twisted.spread.jelly.SecurityOptions instance at 0x82dcf74>

### instance_atom

  Type:
    `string`
  Value:

        'instance'

### list_atom

  Type:
    `string`
  Value:

        'list'

### module_atom

  Type:
    `string`
  Value:

        'module'

### None_atom

  Type:
    `string`
  Value:

        'None'

### persistent_atom

  Type:
    `string`
  Value:

        'persistent'

### reference_atom

  Type:
    `string`
  Value:

        'reference'

### tuple_atom

  Type:
    `string`
  Value:

        'tuple'

### unjellyableFactoryRegistry

  Type:
    `dictionary`
  Value:

        {}

### unjellyableRegistry

  Type:
    `dictionary`
  Value:

        {'cached': <function unjellyCached at 0x8228c4c>,
         'lcache': <function unjellyLCache at 0x8239a34>,
         'local': <function unjellyLocal at 0x8239a6c>,
         'remote': <class twisted.spread.pb.RemoteReference at 0x843b3c4>,
         'twisted.spread.pb.CopyableFailure': <class twisted.spread.pb.CopiedF\
        ailure at 0x83acabc>,
         'twisted.web.server.Request': <class twisted.web.distrib.Request at 0\
        x89212cc>}

### unpersistable_atom

  Type:
    `string`
  Value:

        'unpersistable'

Generated by Epydoc 1.1 on Sat Feb 15 21:18:12 2003 | http://epydoc.sf.net