-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 08/21/2012 11:37 AM, saurabh prakash wrote:
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-----