Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Using pylons - colander for xml deserialization
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
saurabh prakash  
View profile  
 More options Aug 21 2012, 11:37 am
From: saurabh prakash <saurabhpres...@gmail.com>
Date: Tue, 21 Aug 2012 08:37:01 -0700 (PDT)
Local: Tues, Aug 21 2012 11:37 am
Subject: Using pylons - colander for xml deserialization

How should colander(http://docs.pylonsproject.org/projects/colander/en/latest/?awesome) be used for xml deserialization? Docs say that it can even be used for xml deserialization and validation, but I didn't find any good examples for that in docs or on the web!

If anyone has used colander for xml deserialization can you just put a snippet here on its usage? It would be very helpful.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tres Seaver  
View profile   Translate to Translated (View Original)
 More options Aug 22 2012, 12:27 pm
From: Tres Seaver <tsea...@palladion.com>
Date: Wed, 22 Aug 2012 12:27:24 -0400
Local: Wed, Aug 22 2012 12:27 pm
Subject: Re: Using pylons - colander for xml deserialization
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 08/21/2012 11:37 AM, saurabh prakash wrote:

> How should colander
> (http://docs.pylonsproject.org/projects/colander/en/latest/?awesome)
> be used for xml deserialization? Docs say that it can even be used for
> xml deserialization and validation, but I didn't find any good
> examples for that in docs or on the web!

colander's job in deserialization is to validate the "cstruct" (a Python
data structure extracted from whatever format, usually consisting of
sequences or mappings of strings) against a schema, converting it (if
validation succeeds) into an "appstruct" (a loosely equivalent data
structure, but with values massaged into their "canonical" form.

> If anyone has used colander for xml deserialization can you just put
> a snippet here on its usage? It would be very helpful.

E.g., for the example here:
http://docs.pylonsproject.org/projects/colander/en/latest/basics.html...
a corresponding XML document might be::

 <person>
  <name>keith</name>
  <age>20</age>
  <friends>
   <friend>
    <id>1</id>
    <name>jim<name>
   </friend>
   <friend>
    <id>1</id>
    <name>jim<name>
   </friend>
   <friend>
    <id>1</id>
    <name>jim<name>
   </friend>
   <friend>
    <id>1</id>
    <name>jim<name>
   </friend>
  </friends>
  <phones>
   <phone>
    <location>home</location>
    <number>555-1212</number>
   </phone>
   <phone>
    <location>work</location>
    <number>555-8989</number>
   </phone>
  </phones>
 <person>

Your code would be responsible for converting the XML document into the
'cstruct' (which the linked example generates imperatively), before
passing the 'cstruct' to the 'schema.deserialize' method, from which it
would get back the 'appstruct'.  You are free to use whatever tools you
like for parsing the XML and constructing the appstruct.  I would be
likely to use lxml.

Hope this helps,

Tres.
- --
===================================================================
Tres Seaver          +1 540-429-0999          tsea...@palladion.com
Palladion Software   "Excellence by Design"    http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAlA1CGUACgkQ+gerLs4ltQ4FiQCcDQ6Iz/Qt6PG9PFkNrBcu8tLY
N9wAnRD/mGoSvXyMWy3K/3Rmk09nrwSW
=fT/7
-----END PGP SIGNATURE-----


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »