durusmail: durus-users: Pickling/exporting objects
Pickling/exporting objects
2005-03-02
2005-03-02
2005-03-02
2005-03-02
2005-03-02
2005-03-02
2005-03-02
2005-03-03
2005-03-03
2005-03-03
2005-03-03
2005-03-03
2005-03-04
2005-03-04
2005-03-04
2005-03-04
2005-03-04
2005-03-04
2005-03-05
Pickling/exporting objects
David Binger
2005-03-04
Okay, I really can pickle a Persistent instance now, even with
the C implementation of PersistentBase installed.  Note that
pickle protocol 2 is required.

$ diff
Index: _persistent.c
===================================================================
--- _persistent.c   (revision 26269)
+++ _persistent.c   (working copy)
@@ -132,7 +132,7 @@
  static PyTypeObject Persistent_Type = {
      PyObject_HEAD_INIT(0)
      0,                 /* ob_size */
-    "_persistent.PersistentBase",  /* tp_name */
+    "durus._persistent.PersistentBase",    /* tp_name */
      sizeof(PersistentObject),      /* tp_basicsize */
      0,                 /* tp_itemsize */
      0,                 /* tp_dealloc */

---
$ python
Python 2.4 (#1, Dec  9 2004, 17:05:40)
[GCC 2.95.4 20011002 (Debian prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
 >>> from durus.persistent import Persistent
 >>> from cPickle import dumps
 >>> dumps(Persistent(), 2)
'\x80\x02cdurus.persistent\nPersistent\nq\x01)\x81q\x02}q\x03b.'
 >>> dumps(Persistent())
Traceback (most recent call last):
   File "", line 1, in ?
   File "/www/plat/python2.4/lib/python2.4/copy_reg.py", line 69, in
_reduce_ex
     raise TypeError, "can't pickle %s objects" % base.__name__
TypeError: can't pickle PersistentBase objects
 >>>



reply