Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #46597 > unrolled thread

Re: serialize a class to XML and back

Started bySchneider <js@globe.de>
First post2013-05-31 13:16 +0200
Last post2013-05-31 13:16 +0200
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: serialize a class to XML and back Schneider <js@globe.de> - 2013-05-31 13:16 +0200

#46597 — Re: serialize a class to XML and back

FromSchneider <js@globe.de>
Date2013-05-31 13:16 +0200
SubjectRe: serialize a class to XML and back
Message-ID<mailman.2489.1369999487.3114.python-list@python.org>
On 25.05.2013 07:54, dieter wrote:
> Schneider <js@globe.de> writes:
>
>> how can I serialize a python class to XML? Plus a way to get the class
>> back from the XML?
>>
>> My aim is to store instances of this class in a database.
> In case you want to describe the XML data via an XML-schema
> (e.g. to exchange it with other applications; maybe via
> WebServices), you may have a look at "PyXB".
>
>
> The approach of "PyXB" may be a bit different from yours:
>
>    It starts with an XML-schema description and from
>    it generates Python classes corresponding to the types
>    mentioned in the schema.
>
>    Instances of those classes can then be easily serialized
>    to XML and XML documents corresponding to types defined
>    in the schema can easily be converted into corresponding
>    class instances.
>
>    It is not too difficult to customize the classes
>    used for a given type - e.g. to give them special methods
>    related to your application.
>
>
> You may want to start with your (arbitrary) Python classes
> and get their instances serialized into an adequate XML document.
>
> This will not work in all cases: some things are very difficult
> to serialize (maybe even not serializable at all - e.g. locks).

I have just small classes containing text (strings)  numbers (as ids) 
and references to other classes of this type.

>
> If you plan to use anything already existing, then almost
> surely, this will impose restrictions of your classes.
>


-- 
GLOBE Development GmbH
Königsberger Strasse 260
48157 MünsterGLOBE Development GmbH
Königsberger Strasse 260
48157 Münster
0251/5205 390

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web