1
<?xml version="1.0" encoding="iso-8859-1"?>
2
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
3
"DTD/xhtml1-transitional.dtd">
4
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
6
<title>twisted.spread.jelly</title>
7
<link rel="stylesheet" href="epydoc.css" type="text/css"></link>
9
<body bgcolor="white" text="black" link="blue" vlink="#204080"
12
<!-- =========== START OF NAVBAR =========== -->
13
<table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0">
15
<th class="navbar"> <a class="navbar" href="twisted.html">Home</a> </th>
16
<th class="navbar"> <a class="navbar" href="trees.html">Trees</a> </th>
17
<th class="navbar"> <a class="navbar" href="indices.html">Index</a> </th>
18
<th class="navbar"> <a class="navbar" href="help.html">Help</a> </th>
19
<th class="navbar" align="right" width="100%">
20
<table border="0" cellpadding="0" cellspacing="0">
21
<tr><th class="navbar" align="center">
23
<a class="navbar" target="_top" href="http://twistedmatrix.com/">Twisted 1.3.0rc1</a>
24
</p></th></tr></table>
28
<table width="100%" cellpadding="0" cellspacing="0">
31
<font size="-1"><b class="breadcrumbs">
32
<a href="twisted.html">Package twisted</a> ::
33
<a href="twisted.spread.html">Package spread</a> ::
37
<td><table cellpadding="0" cellspacing="0">
38
<tr><td align="right"><font size="-2">[<a href="frames.html"target="_top">frames</a> | <a href="twisted.spread.jelly.html" target="_top">no frames</a>]</font></td></tr>
42
<!-- =========== START OF MODULE DESCRIPTION =========== -->
43
<h2 class="module">Module twisted.spread.jelly</h2>
45
<p>S-expression-based persistence of python objects.</p>
46
<p>Stability: semi-stable</p>
47
<p>Future Plans: Optimization. Lots of optimization. No semantic
48
breakages should be necessary, but if small tweaks are required to gain
49
acceptable large-scale performance then they will be made. Although Glyph
50
is the maintainer, Bruce Mitchener will be supervising most of the
51
optimization work here.</p>
52
<p>I do something very much like <code>Pickle</code>; however, pickle's
53
main goal seems to be efficiency (both in space and time); jelly's main
54
goals are security, human readability, and portability to other
56
<p>This is how Jelly converts various objects to s-expressions:</p>
57
<p>Boolean: True --> ['boolean', 'true']</p>
58
<p>Integer: 1 --> 1</p>
59
<p>List: [1, 2] --> ['list', 1, 2]</p>
60
<p>String: "hello" --> "hello"</p>
61
<p>Float: 2.3 --> 2.3</p>
62
<p>Dictionary: {'a' : 1, 'b' : 'c'} --> ['dictionary', ['b', 'c'],
64
<p>Module: UserString --> ['module', 'UserString']</p>
65
<p>Class: UserString.UserString --> ['class', ['module',
66
'UserString'], 'UserString']</p>
67
<p>Function: string.join --> ['function', 'join', ['module',
69
<p>Instance: s is an instance of UserString.UserString, with a __dict__
70
{'data': 'hello'}: ["UserString.UserString", ['dictionary',
71
['data', 'hello']]]</p>
72
<p># ['instance', ['class', ['module', 'UserString'], 'UserString'],
73
['dictionary', ['data', 'hello']]]</p>
74
<p>Class Method: UserString.UserString.center: ['method', 'center',
75
['None'], ['class', ['module', 'UserString'], 'UserString']]</p>
76
Instance Method: s.center, where s is an instance of
77
UserString.UserString: ['method', 'center', ['instance', ['reference', 1,
78
['class', ['module', 'UserString'], 'UserString']], ['dictionary',
79
['data', 'd']]], ['dereference', 1]]
81
<p><b>Author:</b> <a href="mailto:glyph@twistedmatrix.com">Glyph Lefkowitz</a>
85
<!-- =========== START OF CLASSES =========== -->
86
<table class="summary" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white">
87
<tr bgcolor="#70b0f0" class="summary">
88
<th colspan="2">Classes</th></tr>
90
<b><a href="twisted.spread.jelly._Dummy.html"><code>_Dummy</code></a></b></td>
91
<td>(Internal) Dummy class, used for unserializing instances.</td></tr>
93
<b><a href="twisted.spread.jelly._Jellier.html"><code>_Jellier</code></a></b></td>
94
<td>(Internal) This class manages state for a call to jelly()</td></tr>
96
<b><a href="twisted.spread.jelly._Unjellier.html"><code>_Unjellier</code></a></b></td>
99
<b><a href="twisted.spread.jelly.DummySecurityOptions.html"><code>DummySecurityOptions</code></a></b></td>
100
<td>DummySecurityOptions() -> insecure security options Dummy security
101
options -- this class will allow anything.</td></tr>
103
<b><a href="twisted.spread.jelly.Jellyable.html"><code>Jellyable</code></a></b></td>
104
<td>Inherit from me to Jelly yourself directly with the `getStateFor'
105
convenience method.</td></tr>
107
<b><a href="twisted.spread.jelly.SecurityOptions.html"><code>SecurityOptions</code></a></b></td>
108
<td>This will by default disallow everything, except for 'none'.</td></tr>
110
<b><a href="twisted.spread.jelly.Unjellyable.html"><code>Unjellyable</code></a></b></td>
111
<td>Inherit from me to Unjelly yourself directly with the `setStateFor'
112
convenience method.</td></tr>
114
<b><a href="twisted.spread.jelly.Unpersistable.html"><code>Unpersistable</code></a></b></td>
115
<td>This is an instance of a class that comes back when something couldn't
116
be persisted.</td></tr>
120
<!-- =========== START OF EXCEPTIONS =========== -->
121
<table class="summary" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white">
122
<tr bgcolor="#70b0f0" class="summary">
123
<th colspan="2">Exceptions</th></tr>
125
<b><a href="twisted.spread.jelly.InsecureJelly.html"><code>InsecureJelly</code></a></b></td>
126
<td>This exception will be raised when a jelly is deemed `insecure';
131
<!-- =========== START OF FUNCTION SUMMARY =========== -->
132
<table class="summary" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white">
133
<tr bgcolor="#70b0f0" class="summary">
134
<th colspan="2">Function Summary</th></tr>
135
<tr><td align="right" valign="top" width="15%"><font size="-1"> </font></td>
136
<td><code><a name="_maybeClass"></a><span class="summary-sig"><span class="summary-sig-name">_maybeClass</span>(<span class=summary-sig-arg>classnamep</span>)</span></code>
138
<tr><td align="right" valign="top" width="15%"><font size="-1"> </font></td>
139
<td><code><span class="summary-sig"><a href="twisted.spread.jelly.html#getInstanceState" class="summary-sig-name"><code>getInstanceState</code></a>(<span class=summary-sig-arg>inst</span>,
140
<span class=summary-sig-arg>jellier</span>)</span></code>
142
Utility method to default to 'normal' state rules in
143
serialization.</td></tr>
144
<tr><td align="right" valign="top" width="15%"><font size="-1"> </font></td>
145
<td><code><span class="summary-sig"><a href="twisted.spread.jelly.html#jelly" class="summary-sig-name"><code>jelly</code></a>(<span class=summary-sig-arg>object</span>,
146
<span class=summary-sig-arg>taster</span>,
147
<span class=summary-sig-arg>persistentStore</span>,
148
<span class=summary-sig-arg>invoker</span>)</span></code>
150
Serialize to s-expression.</td></tr>
151
<tr><td align="right" valign="top" width="15%"><font size="-1"> </font></td>
152
<td><code><span class="summary-sig"><a href="twisted.spread.jelly.html#setInstanceState" class="summary-sig-name"><code>setInstanceState</code></a>(<span class=summary-sig-arg>inst</span>,
153
<span class=summary-sig-arg>unjellier</span>,
154
<span class=summary-sig-arg>jellyList</span>)</span></code>
156
Utility method to default to 'normal' state rules in
157
unserialization.</td></tr>
158
<tr><td align="right" valign="top" width="15%"><font size="-1"> </font></td>
159
<td><code><span class="summary-sig"><a href="twisted.spread.jelly.html#setUnjellyableFactoryForClass" class="summary-sig-name"><code>setUnjellyableFactoryForClass</code></a>(<span class=summary-sig-arg>classname</span>,
160
<span class=summary-sig-arg>copyFactory</span>)</span></code>
162
Set the factory to construct a remote instance of a type:</td></tr>
163
<tr><td align="right" valign="top" width="15%"><font size="-1"> </font></td>
164
<td><code><span class="summary-sig"><a href="twisted.spread.jelly.html#setUnjellyableForClass" class="summary-sig-name"><code>setUnjellyableForClass</code></a>(<span class=summary-sig-arg>classname</span>,
165
<span class=summary-sig-arg>unjellyable</span>)</span></code>
167
Set which local class will represent a remote type.</td></tr>
168
<tr><td align="right" valign="top" width="15%"><font size="-1"> </font></td>
169
<td><code><span class="summary-sig"><a href="twisted.spread.jelly.html#setUnjellyableForClassTree" class="summary-sig-name"><code>setUnjellyableForClassTree</code></a>(<span class=summary-sig-arg>module</span>,
170
<span class=summary-sig-arg>baseClass</span>,
171
<span class=summary-sig-arg>prefix</span>)</span></code>
173
Set all classes in a module derived from <code>baseClass</code> as
174
copiers for a corresponding remote class.</td></tr>
175
<tr><td align="right" valign="top" width="15%"><font size="-1"> </font></td>
176
<td><code><span class="summary-sig"><a href="twisted.spread.jelly.html#unjelly" class="summary-sig-name"><code>unjelly</code></a>(<span class=summary-sig-arg>sexp</span>,
177
<span class=summary-sig-arg>taster</span>,
178
<span class=summary-sig-arg>persistentLoad</span>,
179
<span class=summary-sig-arg>invoker</span>)</span></code>
181
Unserialize from s-expression.</td></tr>
185
<!-- =========== START OF VARIABLE SUMMARY =========== -->
186
<table class="summary" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white">
187
<tr bgcolor="#70b0f0" class="summary">
188
<th colspan="2">Variable Summary</th></tr>
189
<tr><td align="right" valign="top" width="15%"><font size="-1"><code>str</code></font></td>
190
<td><b><a href="twisted.spread.jelly.html#__version__"><code>__version__</code></a></b> = <span title="'1.48'"><code><span class="variable-quote">'</span>1.48<span class="variable-quote">'</span> </code>
192
<tr><td align="right" valign="top" width="15%"><font size="-1"><a href="twisted.spread.jelly.SecurityOptions.html"
193
class="link"><code>SecurityOptions</code></a></font></td>
194
<td><b><a href="twisted.spread.jelly.html#globalSecurity"><code>globalSecurity</code></a></b> = <span title="<twisted.spread.jelly.SecurityOptions instance at 0x83e95d4>"><code><twisted.spread.jelly.SecurityOptions i<span class="variable-ellipsis">...</span></code>
196
<tr><td align="right" valign="top" width="15%"><font size="-1"><code>dict</code></font></td>
197
<td><b><a href="twisted.spread.jelly.html#unjellyableFactoryRegistry"><code>unjellyableFactoryRegistry</code></a></b> = <span title="{}"><code>{} </code>
199
<tr><td align="right" valign="top" width="15%"><font size="-1"><code>dict</code></font></td>
200
<td><b><a href="twisted.spread.jelly.html#unjellyableRegistry"><code>unjellyableRegistry</code></a></b> = <span title="{'twisted.web.server.Request': <class twisted.web.distrib.Request at 0x86f6b34>, 'remote': <class twisted.spread.pb.RemoteReference at 0x8535084>, 'cached': <function unjellyCached at 0x84628e4>, 'lcache': <function unjellyLCache at 0x846291c>, 'twisted.spread.pb.CopyableFailure': <class twisted.spread.pb.CopiedFailure at 0x8479924>, 'local': <function unjellyLocal at 0x85a807c>}"><code>{'twisted.web.server.Request': <cl<span class="variable-ellipsis">...</span></code>
205
<!-- =========== START OF FUNCTION DETAILS =========== -->
206
<table class="details" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white">
207
<tr bgcolor="#70b0f0" class="details">
208
<th colspan="2">Function Details</th></tr>
211
<a name="getInstanceState"></a>
212
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
213
<h3><span class="sig"><span class="sig-name">getInstanceState</span>(<span class=sig-arg>inst</span>,
214
<span class=sig-arg>jellier</span>)</span>
216
Utility method to default to 'normal' state rules in
223
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
224
<h3><span class="sig"><span class="sig-name">jelly</span>(<span class=sig-arg>object</span>,
225
<span class=sig-arg>taster</span>=<span class=sig-default><twisted.spread.jelly.DummySecurityOptions instance at 0x...</span>,
226
<span class=sig-arg>persistentStore</span>=<span class=sig-default>None</span>,
227
<span class=sig-arg>invoker</span>=<span class=sig-default>None</span>)</span>
229
<p>Serialize to s-expression.</p>
230
Returns a list which is the serialized representation of an object.
231
An optional 'taster' argument takes a SecurityOptions and will mark any
232
insecure objects as unpersistable rather than serializing them.
237
<a name="setInstanceState"></a>
238
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
239
<h3><span class="sig"><span class="sig-name">setInstanceState</span>(<span class=sig-arg>inst</span>,
240
<span class=sig-arg>unjellier</span>,
241
<span class=sig-arg>jellyList</span>)</span>
243
Utility method to default to 'normal' state rules in
249
<a name="setUnjellyableFactoryForClass"></a>
250
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
251
<h3><span class="sig"><span class="sig-name">setUnjellyableFactoryForClass</span>(<span class=sig-arg>classname</span>,
252
<span class=sig-arg>copyFactory</span>)</span>
254
Set the factory to construct a remote instance of a type:
255
<pre class="literalblock">
256
jellier.setFactoryForClass('module.package.Class', MyFactory)
258
<p>Call this at the module level immediately after its class
259
definition. <code>copyFactory</code> should return an instance or
260
subclass of <a href="twisted.spread.flavors.RemoteCopy.html"
261
class="link"><code>RemoteCopy</code></a>.</p>
263
href="twisted.spread.jelly.html#setUnjellyableForClass"
264
class="link"><code>setUnjellyableForClass</code></a> except it uses a
265
factory instead of creating an instance.
270
<a name="setUnjellyableForClass"></a>
271
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
272
<h3><span class="sig"><span class="sig-name">setUnjellyableForClass</span>(<span class=sig-arg>classname</span>,
273
<span class=sig-arg>unjellyable</span>)</span>
275
<p>Set which local class will represent a remote type.</p>
276
If you have written a Copyable class that you expect your client to
277
be receiving, write a local "copy" class to represent it,
279
<pre class="literalblock">
280
jellier.setUnjellyableForClass('module.package.Class', MyJellier).
282
<p>Call this at the module level immediately after its class
283
definition. MyCopier should be a subclass of RemoteCopy.</p>
284
<p>The classname may be a special tag returned by
285
'Copyable.getTypeToCopyFor' rather than an actual classname.</p>
286
This call is also for cached classes, since there will be no
287
overlap. The rules are the same.
292
<a name="setUnjellyableForClassTree"></a>
293
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
294
<h3><span class="sig"><span class="sig-name">setUnjellyableForClassTree</span>(<span class=sig-arg>module</span>,
295
<span class=sig-arg>baseClass</span>,
296
<span class=sig-arg>prefix</span>=<span class=sig-default>None</span>)</span>
298
<p>Set all classes in a module derived from <code>baseClass</code> as
299
copiers for a corresponding remote class.</p>
300
<p>When you have a heirarchy of Copyable (or Cacheable) classes on one
301
side, and a mirror structure of Copied (or RemoteCache) classes on the
302
other, use this to setCopierForClass all your Copieds for the
304
Each copyTag (the "classname" argument to
305
getTypeToCopyFor, and what the Copyable's getTypeToCopyFor returns) is
306
formed from adding a prefix to the Copied's class name. The prefix
307
defaults to module.__name__. If you wish the copy tag to consist of
308
solely the classname, pass the empty string ''.
310
<dl><dt><b>Parameters:</b></dt>
311
<dd><code><b>module</b></code> -
312
a module object from which to pull the Copied classes.
313
(passing sys.modules[__name__] might be useful)
314
<dd><code><b>baseClass</b></code> -
315
the base class from which all your Copied classes derive.
316
<dd><code><b>prefix</b></code> -
317
the string prefixed to classnames to form the
324
<a name="unjelly"></a>
325
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
326
<h3><span class="sig"><span class="sig-name">unjelly</span>(<span class=sig-arg>sexp</span>,
327
<span class=sig-arg>taster</span>=<span class=sig-default><twisted.spread.jelly.DummySecurityOptions instance at 0x...</span>,
328
<span class=sig-arg>persistentLoad</span>=<span class=sig-default>None</span>,
329
<span class=sig-arg>invoker</span>=<span class=sig-default>None</span>)</span>
331
<p>Unserialize from s-expression.</p>
332
Takes an list that was the result from a call to jelly() and
333
unserializes an arbitrary object from it. The optional 'taster'
334
argument, an instance of SecurityOptions, will cause an InsecureJelly
335
exception to be raised if a disallowed type, module, or class attempted
343
<!-- =========== START OF VARIABLE DETAILS =========== -->
344
<table class="details" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white">
345
<tr bgcolor="#70b0f0" class="details">
346
<th colspan="2">Variable Details</th></tr>
348
<table width="100%" class="var-details" bgcolor="#e0e0e0"><tr><td>
349
<a name="__version__"></a>
355
<dt><b>Type:</b></dt>
360
<span title="'1.48'"> <dt><b>Value:</b></dt>
362
<pre class="variable">
363
<span class="variable-quote">'</span>1.48<span class="variable-quote">'</span> </pre>
364
</td></tr></table></dd>
367
</dl></td></tr></table>
368
<table width="100%" class="var-details" bgcolor="#e0e0e0"><tr><td>
369
<a name="globalSecurity"></a>
370
<h3>globalSecurity</h3>
375
<dt><b>Type:</b></dt>
377
<a href="twisted.spread.jelly.SecurityOptions.html"
378
class="link"><code>SecurityOptions</code></a>
381
<span title="<twisted.spread.jelly.SecurityOptions instance at 0x83e95d4>"> <dt><b>Value:</b></dt>
383
<pre class="variable">
384
<twisted.spread.jelly.SecurityOptions instance at 0x83e95d4> </pre>
385
</td></tr></table></dd>
388
</dl></td></tr></table>
389
<table width="100%" class="var-details" bgcolor="#e0e0e0"><tr><td>
390
<a name="unjellyableFactoryRegistry"></a>
391
<h3>unjellyableFactoryRegistry</h3>
396
<dt><b>Type:</b></dt>
401
<span title="{}"> <dt><b>Value:</b></dt>
403
<pre class="variable">
405
</td></tr></table></dd>
408
</dl></td></tr></table>
409
<table width="100%" class="var-details" bgcolor="#e0e0e0"><tr><td>
410
<a name="unjellyableRegistry"></a>
411
<h3>unjellyableRegistry</h3>
416
<dt><b>Type:</b></dt>
421
<span title="{'twisted.web.server.Request': <class twisted.web.distrib.Request at 0x86f6b34>, 'remote': <class twisted.spread.pb.RemoteReference at 0x8535084>, 'cached': <function unjellyCached at 0x84628e4>, 'lcache': <function unjellyLCache at 0x846291c>, 'twisted.spread.pb.CopyableFailure': <class twisted.spread.pb.CopiedFailure at 0x8479924>, 'local': <function unjellyLocal at 0x85a807c>}"> <dt><b>Value:</b></dt>
423
<pre class="variable">
424
{'cached': <function unjellyCached at 0x84628e4>,
425
'lcache': <function unjellyLCache at 0x846291c>,
426
'local': <function unjellyLocal at 0x85a807c>,
427
'remote': <class twisted.spread.pb.RemoteReference at 0x8535084>,
428
'twisted.spread.pb.CopyableFailure': <class twisted.spread.pb.CopiedF<span class="variable-linewrap">\</span>
429
ailure at 0x8479924>,
430
'twisted.web.server.Request': <class twisted.web.distrib.Request at 0<span class="variable-linewrap">\</span>
432
</td></tr></table></dd>
435
</dl></td></tr></table>
439
<!-- =========== START OF NAVBAR =========== -->
440
<table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0">
442
<th class="navbar"> <a class="navbar" href="twisted.html">Home</a> </th>
443
<th class="navbar"> <a class="navbar" href="trees.html">Trees</a> </th>
444
<th class="navbar"> <a class="navbar" href="indices.html">Index</a> </th>
445
<th class="navbar"> <a class="navbar" href="help.html">Help</a> </th>
446
<th class="navbar" align="right" width="100%">
447
<table border="0" cellpadding="0" cellspacing="0">
448
<tr><th class="navbar" align="center">
450
<a class="navbar" target="_top" href="http://twistedmatrix.com/">Twisted 1.3.0rc1</a>
451
</p></th></tr></table>
456
<table border="0" cellpadding="0" cellspacing="0" width="100%">
458
<td align="left"><font size="-2">Generated by Epydoc 2.0 on Sat May 15 20:08:15 2004</font></td>
459
<td align="right"><a href="http://epydoc.sourceforge.net"
460
><font size="-2">http://epydoc.sf.net</font></a></td>