[gnosis/xml_pickle] How to unpickle nested objects? (

David Mertz mertz at gnosis.cx
Wed Dec 18 14:33:31 EST 2002


"F. GEIGER" <fgeiger at datec.at> wrote previously:
|Now I'd like to change from normal pickle format to XML format.  As I
|want to do this in a "painless" way, I tried xml_pickle from the gnosis
|pack 1.0.5.  This works fine until Contact contains an object of class
|say Address.  If Contact is unpickled now, there's no code executed
|similar to the above one:

Take a look at the document [...]/site-packages/gnosis/xml/doc/SECURITY.

By default, gnosis.xml.pickle is "paranoid" about restoring possibly
dangerous methods.  But you can change this.  From the document
mentioned:

+------------------------------------------------------------------+
| For the impatient, the following code will give decent security  |
| with the "expected" pickle behavior:                             |
|                                                                  |
|     from gnosis.xml.pickle.util import setParanoia               |
|     setParanoia(0)                                               |
+------------------------------------------------------------------+

Read the whole document for more details.

One reason it works the way it does is because gnosis.xml.pickle lets
you substitute one class for another during unpickling (if you want to).
For example, you might have a Bookkeeping object for financial records.
But your accountant might want to restore the data into an Audit object.
Same data, but maybe with a different collection of methods.  The
security setup of gnosis.xml.pickle lets you control when things like
this (are allowed to) happen.

Yours, David...

--
Keeping medicines from the bloodstreams of the sick; food from the bellies
of the hungry; books from the hands of the uneducated; technology from the
underdeveloped; and putting advocates of freedom in prisons.  Intellectual
property is to the 21st century what the slave trade was to the 16th.




More information about the Python-list mailing list