Dear pyxser users, I’m pleased to announce that I’ve released pyxser-1.3r. The current ChangeLog for this release is as follows (Update: There was bug in the pyxser-1.3r release, it is patched and working in pyxser-1.3r-p1):
1.3r (2009.11.30): Daniel Molina Wegener <dmw@coder.cl> * pyxser_tools.c: Removed bug concerning deserialization of collection elements; pyxser now can handle extension declared classes, such as boost::python ones --- thanks to the suggestions made by Daniel Filonik. * pyxser.c: Added /selector/ as optional argument used as callback to select object attributes to being serialized. * pyxser_string.c: Removed bug concerning unicode serialization. Thanks pyxser users for your feedback...
I want to bring special thanks to Daniel Filonik for his feedback.
First, thank you for a great Python module, I believe it has a lot of potential! I was never quite happy with pickle because of its cryptic format. The XML schema you use is so much nicer to read.
the selector callback
An interesting feature requested by Daniel Filonik is to allow the user to select the object attributes to being serialized. So I’ve added the attribute selector callback as optional argument called selector. As he suggest:
PyObject *selector = (PyObject *)NULL; /* ... */ static char *kwlist[] = {"obj", "enc", "depth", "selector ", NULL}; /* ... */ ok = PyArg_ParseTupleAndKeywords(args, keywds, "Os|iO", kwlist, &input, &in_enc, &py_depth, &selector); /* ... */ sargs.selector = &selector;
Then, I use the selector callback in pyxser to obtain a list of the required attributes for the serialization process, and the callback is applied to the given object to being serialized.
if (PYTHON_IS_NONE(select)) { lstItems = PyObject_GetAttrString(o, pyxser_attr_dict); } else { /* selector must return NULL if there are errors... */ arglist = Py_BuildValue("(O)", o); lstItems = PyObject_CallObject(select, arglist); Py_XDECREF(arglist); }
And I’ve implemented the proper method to allow the instantiation of classes which are defined in Python extensions, such as boost::python, by replacing PyInstance_NewRaw() call by the default empty constructor for Python objects:
#ifdef OLDCODE PyObject *ndict = (PyObject *)NULL; /* ... */ ndict = PyDict_New(); unser = PyInstance_NewRaw(ct, ndict); Py_XDECREF(ndict); #else int ctrl = 0; unser = PyObject_CallFunctionObjArgs(ct, NULL); attr_name = pyxser_ExtractPropertyName(pyxser_xml_attr_name, ron); #endif /* !OLDCODE */
I hope that pyxser is neat serializing extension and it is usefull for your transparent and interoperable communications with other platforms in Python.
Nice work daniel, i will be working with pyxser in the next week so i can suggest you more details.