On 03/23/2012 10:37, lars van gemerden wrote:
Hi Julian,

Thanks, I am looking into it and it looks interesting. Have you done much testing yet? How do you (plan to; haven't looked at too much detail yet) check for circular references (like backrefs)?


circular references aren't handled yet .. at the moment all what you can do is something like:

>>> a = Page.query.get(454)

>>> SAMappedSerializer(a).json(exclude_columns=('body', ), include_relations=('type', 'tags')) '{"updated": "2012-03-21T16:52:43Z", "added": "2009-10-16T14:23:24Z", "description": "The Belgian Biodiversity Platform", "effective": null, "tags": [{"description": null, "id": 26, "name": "Belspo"}, {"description": null, "id": 29, "name": "Belgian Biodiversity Platform"}], "icon_content_id": null, "count_children": 0, "customized": false, "weight": 23, "owner_id": 1, "content_id": 454, "expiration": null, "polymorphic_loading": null, "state_id": 3, "title": "About us", "exclude_nav": false, "type": {"description": null, "icon": "page.png", "id": 2, "name": "page"}, "id": 454, "container_id": 1, "content_type_id": 2}'

>>> SAMappedSerializer(a).xml(exclude_columns=('body', ), include_relations=('type', 'tags')) <content><updated>2012-03-21T16:52:43Z</updated><added>2009-10-16T14:23:24Z</added><description>The Belgian Biodiversity Platform</description><effective /><tags><tags_0><description /><id>26</id><name>Belspo</name></tags_0><tags_1><description /><id>29</id><name>Belgian Biodiversity Platform</name></tags_1></tags><icon_content_id /><count_children>0</count_children><customized>False</customized><weight>23</weight><owner_id>1</owner_id><content_id>454</content_id><expiration /><polymorphic_loading /><state_id>3</state_id><title>About us</title><exclude_nav>False</exclude_nav><type><description /><icon>page.png</icon><id>2</id><name>page</name></type><id>454</id><container_id>1</container_id><content_type_id>2</content_type_id></content>

etc

Cheers, Lars

On Thursday, March 22, 2012 11:36:41 AM UTC+1, lars van gemerden wrote:

    Hi,

    I am looking for a way to convert SQLalchemy objects to XML and
    back, in order to support a webapplication. I made a mixin class
    that does a decent job on 'normal' python objects (basically works
    for in the same cases as pickle, though more testing is required).
    I would prefer to have a simple mixin interface with something like:

    def toXML():
        'convert attributes to xml'
        return xmlstring

    def fromXML(xmlstring)
        'update attributes from xml'

    The most simple case would be that the web user request indicates
    the primary key of the object, gets the corrsponding xml string in
    return, changes fields in the xml string and posts it back, which
    leads to an update of the object.

    I have formulated a couple of initial questions:

    -  what attributes should be converted to and from xml?
    -  how do i handle foreign keys on the 'other' side?

    Note that the object remains in memory during the user
    interaction, so it does not have to be reinitialized from scratch.

    Cheers, Lars

--
You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To view this discussion on the web visit https://groups.google.com/d/msg/sqlalchemy/-/QNBLxpPxDBgJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.


--
No trees were killed in the creation of this message.
However, many electrons were terribly inconvenienced.

--
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

<<attachment: jcigar.vcf>>

Reply via email to