pyxser-users Mailing List for Python XML Serialization (Page 2)
Brought to you by:
damowe
You can subscribe to this list here.
2010 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(8) |
Jun
|
Jul
|
Aug
(18) |
Sep
|
Oct
|
Nov
(2) |
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2011 |
Jan
|
Feb
|
Mar
(2) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Max S. <ms...@gm...> - 2010-05-05 05:20:33
|
Hi, Daniel. I've tested version from svn trunk. It segfaults now when working with unicode dictionaries keys. This is a console session to reproduce an error: >>> import pyxser >>> import inspect >>> selector = lambda o: dict(filter(lambda (name,value): not (name.startswith('_') or callable(value)), inspect.getmembers(o))) # not unicode key and value >>> class T: ... def __init__(self, d): ... self.d = d ... >>> t = T({'hehe':'lala'}) >>> t.d {'hehe': 'lala'} >>> s = pyxser.serialize(obj=t,enc='utf-8',selector=selector) >>> print s <?xml version="1.0" encoding="utf-8"?> <pyxs:obj xmlns:pyxs="http://projects.coder.cl/pyxser/model/" version="1.0" type="T" module="pylons-admin" objid="id-33308472"> <pyxs:col type="dict" name="d"> <pyxs:prop type="str" name="hehe">lala</pyxs:prop> </pyxs:col> </pyxs:obj> Seems ok. Now with unicode string as a key: >>> t = T({u'хехе': 'hehe'}) # Russian cyrillic in the dict key >>> t.d {u'\xd1\x85\xd0\xb5\xd1\x85\xd0\xb5': 'hehe'} >>> s = pyxser.serialize(obj=t,enc='utf-8',selector=selector) Segmentation Fault Oops. But it works fine with non-unicode based dictionary keys and values: >>> t = T({'хехе': 'ололо!'}) # Russian cyrillic in the key and value >>> t.d {'\xd1\x85\xd0\xb5\xd1\x85\xd0\xb5': '\xd0\xbe\xd0\xbb\xd0\xbe\xd0\xbb\xd0\xbe!'} >>> s = pyxser.serialize(obj=t,enc='utf-8',selector=selector) >>> print s <?xml version="1.0" encoding="utf-8"?> <pyxs:obj xmlns:pyxs="http://projects.coder.cl/pyxser/model/" version="1.0" type="T" module="pylons-admin" objid="id-33308400"> <pyxs:col type="dict" name="d"> <pyxs:prop type="str" name="хехе">ололо!</pyxs:prop> </pyxs:col> </pyxs:obj> It works with unicode-based dictionary values too. The problem is only with unicode keys. Best regards, Max Sinelnikov. |
From: Daniel M. W. <dm...@co...> - 2010-05-04 14:06:54
|
On Tuesday 04 May 2010, Max Sinelnikov <ms...@gm...> wrote: > Hi! Hello again! :) > Thank you for your work on this module! I'm writing web-application > using Pylons and XSLT as a template system. That's why I really need > for something that can serialize python objects to XML. Thanks again for your feedback. > Pyxser seems to be good for solving my problem, but when I've tried to > serialize SQLAlchemy-based object I got invalid XML with strange > values of atrributes named "name": OK, that problem is caused because dictionary keys are build on top of unicode strings, so, I think that I've fixed it on the trunk version of pyxser, if you can test it from the trunk revision, it would be cool, here is the repository address: https://pyxser.svn.sourceforge.net/svnroot/pyxser/trunk/pyxser Just do a checkout with: svn co repository_address pyxser In your favourite shell... > > <pyxs:obj xmlns:pyxs="http://projects.coder.cl/pyxser/model/" > version="1.0" type="Company" module="unigineportal.model.company" > objid="id-33378896"> > <pyxs:col type="InstrumentedList" name="users"> > <pyxs:obj type="User" name="users" > module="unigineportal.model.user" objid="id-33410320"> > <pyxs:prop type="str" > name=";^A@Hpìû^A">sha1$4qQ1s$00f0c6fe031b3cd7900e158fb1ef8133dd4f5fdc</py > xs:prop> <pyxs:col type="InstrumentedList" name="roles"/> > <pyxs:prop type="str" name="^Pat²Ðéû^A">User1</pyxs:prop> > <pyxs:prop type="str" name="^[2=ñp^Kþ^A">UU</pyxs:prop> > <pyxs:obj module="unigineportal.model.company" type="Company" > name="company" objref="id-33378896"/> > <pyxs:prop type="long" name="vV^ð0çû^A">1</pyxs:prop> > <pyxs:prop type="long" name="ÝQ<9f>Ûð^Lþ^A">1</pyxs:prop> > <pyxs:prop type="str" name="Ê·Ûà@^Kþ^A">user1</pyxs:prop> > <pyxs:prop type="str" > name="password">sha1$4qQ1s$00f0c6fe031b3cd7900e158fb1ef8133dd4f5fdc</pyxs > :prop> <pyxs:prop type="str" name="'©Fü^P^Nþ^A">u1...@c1...</pyxs:prop> > <pyxs:col type="list" name="permissions"/> > </pyxs:obj> > <pyxs:obj type="User" name="permissions" > module="unigineportal.model.user" objref="id-33410192"/> > </pyxs:col> > > > Sometimes attribute's value is valid(<pyxs:col type="InstrumentedList" > name="roles"/>), sometimes not(<pyxs:prop type="str" > name=";^A@Hpìû^A">. I use 1.4.2r version. Do you have any ideas why it > happens and what to do with? OK, can you test it?, I've made some tests here, but if bring me your feedback you will get a release this week with the proper solution ;) > > [SNIP] Best regards, -- Daniel Molina Wegener <dmw [at] coder [dot] cl> Software Architect, System Programmer & Web Developer Phone: +56 (2) 979-0277 | Blog: http://coder.cl/ |
From: Daniel M. W. <dm...@co...> - 2010-05-04 13:13:56
|
On Tuesday 04 May 2010, Max Sinelnikov <ms...@gm...> wrote: > Hi! Hello Max, > Thank you for your work on this module! I'm writing web-application > using Pylons and XSLT as a template system. That's why I really need > for something that can serialize python objects to XML. OK, no problem with that. > Pyxser seems to be good for solving my problem, but when I've tried to > serialize SQLAlchemy-based object I got invalid XML with strange > values of atrributes named "name": The 'name' attribute stands for the name of the object attributes. Seems that your application have some 'unicode' names in your attribute names, so pyxser is using them as normal python strings, and not unicode names, let me check if those names are unicode for the next release. For example if your application have an object name obj with an attribute names "hòlá", pyxser will not serialise the name properly since it handles attribute names as normal strings, that's because you have all that garbage. This week I will release a new version of pyxser (1.4.4r), so you will get this week a new revision of it ;) > > <pyxs:obj xmlns:pyxs="http://projects.coder.cl/pyxser/model/" > version="1.0" type="Company" module="unigineportal.model.company" > objid="id-33378896"> >  <pyxs:col type="InstrumentedList" name="users"> >   <pyxs:obj type="User" name="users" > module="unigineportal.model.user" objid="id-33410320"> >    <pyxs:prop type="str" > name=";^A@Hpìû^A">sha1$4qQ1s$00f0c6fe031b3cd7900e158fb1ef8133dd4f5fdc</ > pyxs:prop>    <pyxs:col type="InstrumentedList" name="roles"/> >    <pyxs:prop type="str" name="^Pat²Ãéû^A">User1</pyxs:prop> >    <pyxs:prop type="str" name="^[2=ñp^Kþ^A">UU</pyxs:prop> >    <pyxs:obj module="unigineportal.model.company" type="Company" > name="company" objref="id-33378896"/> >    <pyxs:prop type="long" name="vV^ð0çû^A">1</pyxs:prop> >    <pyxs:prop type="long" name="ÃQ<9f>Ãð^Lþ^A">1</pyxs:prop> >    <pyxs:prop type="str" name="÷Ãà @^Kþ^A">user1</pyxs:prop> >    <pyxs:prop type="str" > name="password">sha1$4qQ1s$00f0c6fe031b3cd7900e158fb1ef8133dd4f5fdc</pyxs > :prop>    <pyxs:prop type="str" > name="'©Fü^P^Nþ^A">u1...@c1...</pyxs:prop>    <pyxs:col type="list" > name="permissions"/> >   </pyxs:obj> >   <pyxs:obj type="User" name="permissions" > module="unigineportal.model.user" objref="id-33410192"/> >  </pyxs:col> > > > Sometimes attribute's value is valid(<pyxs:col type="InstrumentedList" > name="roles"/>), sometimes not(<pyxs:prop type="str" > name=";^A@Hpìû^A">. I use 1.4.2r version. Do you have any ideas why it > happens and what to do with? I see... let me try some examples like that here, and fix it. You will get a new release this week ;) Thank you very much for your feedback... > > [SNIP] > Best regards, -- Daniel Molina Wegener <dmw [at] coder [dot] cl> Software Architect, System Programmer & Web Developer Phone: +56 (2) 979-0277 | Blog: http://coder.cl/ |
From: Max S. <ms...@gm...> - 2010-05-04 08:15:10
|
Hi! Thank you for your work on this module! I'm writing web-application using Pylons and XSLT as a template system. That's why I really need for something that can serialize python objects to XML. Pyxser seems to be good for solving my problem, but when I've tried to serialize SQLAlchemy-based object I got invalid XML with strange values of atrributes named "name": <pyxs:obj xmlns:pyxs="http://projects.coder.cl/pyxser/model/" version="1.0" type="Company" module="unigineportal.model.company" objid="id-33378896"> <pyxs:col type="InstrumentedList" name="users"> <pyxs:obj type="User" name="users" module="unigineportal.model.user" objid="id-33410320"> <pyxs:prop type="str" name=";^A@Hpìû^A">sha1$4qQ1s$00f0c6fe031b3cd7900e158fb1ef8133dd4f5fdc</pyxs:prop> <pyxs:col type="InstrumentedList" name="roles"/> <pyxs:prop type="str" name="^Pat²Ðéû^A">User1</pyxs:prop> <pyxs:prop type="str" name="^[2=ñp^Kþ^A">UU</pyxs:prop> <pyxs:obj module="unigineportal.model.company" type="Company" name="company" objref="id-33378896"/> <pyxs:prop type="long" name="vV^ð0çû^A">1</pyxs:prop> <pyxs:prop type="long" name="ÝQ<9f>Ûð^Lþ^A">1</pyxs:prop> <pyxs:prop type="str" name="Ê·Ûà@^Kþ^A">user1</pyxs:prop> <pyxs:prop type="str" name="password">sha1$4qQ1s$00f0c6fe031b3cd7900e158fb1ef8133dd4f5fdc</pyxs:prop> <pyxs:prop type="str" name="'©Fü^P^Nþ^A">u1...@c1...</pyxs:prop> <pyxs:col type="list" name="permissions"/> </pyxs:obj> <pyxs:obj type="User" name="permissions" module="unigineportal.model.user" objref="id-33410192"/> </pyxs:col> Sometimes attribute's value is valid(<pyxs:col type="InstrumentedList" name="roles"/>), sometimes not(<pyxs:prop type="str" name=";^A@Hpìû^A">. I use 1.4.2r version. Do you have any ideas why it happens and what to do with? |