Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'resulting': 0.04; 'sql.': 0.07; 'definition,': 0.09; 'url:github': 0.09; 'cc:addr:python- list': 0.11; 'python': 0.11; 'burak': 0.16; 'from:addr:arskom.com.tr': 0.16; 'from:addr:burak.arslan': 0.16; 'from:name:burak arslan': 0.16; 'message-id:@arskom.com.tr': 0.16; 'received:arskomhosting.com': 0.16; 'subject:XML': 0.16; 'subject:class': 0.16; 'url:py': 0.16; 'wrote:': 0.18; 'examples': 0.20; 'example': 0.22; 'cc:addr:python.org': 0.22; 'header:User- Agent:1': 0.23; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'xml': 0.29; "i'm": 0.30; 'code': 0.31; 'class': 0.32; 'instances': 0.36; 'doing': 0.36; 'hi,': 0.36; 'project': 0.37; 'list,': 0.38; 'called': 0.40; 'how': 0.40; 'subject:back': 0.60; "you're": 0.61; 'back': 0.62; 'save': 0.62; 'to/from': 0.84; 'url:master': 0.84 Date: Thu, 23 May 2013 14:16:34 +0300 From: Burak Arslan User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130410 Thunderbird/17.0.5 MIME-Version: 1.0 To: Schneider Subject: Re: serialize a class to XML and back References: <519DF151.1080405@globe.de> In-Reply-To: <519DF151.1080405@globe.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 22 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1369307794 news.xs4all.nl 15920 [2001:888:2000:d::a6]:34739 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:45797 On 05/23/13 13:37, Schneider wrote: > Hi list, > > 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. Hi, I'm working on a project called Spyne (http://spyne.io). With one object definition, you can serialize to/from xml and save to database via SQLAlchemy. The code generator on the site has examples for RPC and SQL. If you're not interested in doing RPC with the resulting document, here's an example for just the xml part: https://github.com/arskom/spyne/blob/master/examples/xml_utils.py Best regards, Burak