Search
Code Directory
 ASP
 ASP.NET
 C/C++
 CFML
 CGI/PERL
 Delphi
 Development
 Flash
 HTML
 Java
 JavaScript
 Pascal
 PHP
 Python
 SQL
 Tools
 Visual Basic & VB.NET
 XML
New Code
Rapid PHP 2018 15.5
IBDAC 6.4
Online Course Booking Script 1.3.3
Database Workbench Pro 5.6.4
Job Portal Script 1.3.2
The C# PDF Library 5.2
PostgreSQL Data Access Components 6.0
Virtual Data Access Components 11.0
HTMLPad 2018 15.5
WeBuilder 2018 15.5
SentiMask SDK Trial 2.0.0
Track Order For Magento 2 1.0.0
Calendar 365 For Dynamics CRM 4.0
Scimbo 1.2
Odoo Furnito Theme 1.0
Top Code
Hotel Management System Restaurant Version 5.25
Azizi search engine script PHP 4.1.10
Travel Booking script 1.0.4
Chessgra 1.1
Keno Game 1.I
VChess 6.x-1.x-dev
Killer Guestbook Script 1.1
RLS Algorithm Demo 1.0
PHP MLM Software 2.0.1
College Management System Script 1.0.4
Spider(rader) Chart for Multi Data 1.0
Simple Radar_system_simulation 1.0
The Spherical K-means algorithm 1.0
Discrete Frechet Distance 1.0
AJ Matrix v2.6
Top Rated
VisualNEO Web 2018.12.15
Azizi search engine script PHP 4.1.10
Paste phpSoftPro 1.4.1
Extreme Injector 3.7
Deals and Discounts Website Script 1.0.2
ADO.NET Provider for ExactTarget 1.0
Solid File System OS edition 5.1
Classified Ad Lister 1.0
Aglowsoft SQL Query Tools 8.2
Invoice Manager by PHPJabbers 3.0
ICPennyBid Penny Auction Script 4.0
PHP Review Script 1.0
ATN Resume Finder 2.0
ATN Site Builder 3.0
Availability Booking Calendar PHP 1.0
dexml 0.4.0
File ID: 105668






dexml 0.4.0
Download dexml 0.4.0http://www.rfk.id.auReport Error Link
License: Freeware
File Size: 20.5 KB
Downloads: 2
Submit Rating:
dexml 0.4.0 Description
Description: a dead-simple Object-XML mapper for Python

dexml: a dead-simple Object-XML mapper for Python

Let's face it: xml is a fact of modern life. I'd even go so far as to say that it's good at what is does. But that doesn't mean it's easy to work with and it doesn't mean that we have to like it. Most of the time, XML just needs to get the hell out of the way and let you do some actual work instead of writing code to traverse and manipulate yet another DOM.

The dexml module takes the obvious mapping between XML tags and Python objects and lets you capture that as cleanly as possible. Loosely inspired by Django's ORM, you write simple class definitions to define the expected structure of your XML document. Like so:

>>> import dexml
>>> from dexml import fields
>>> class Person(dexml.Model):
... name = fields.String()
... age = fields.Integer(tagname='age')

Then you can parse an XML document into an object like this:

>>> p = Person.parse("<Person name='Foo McBar'><age>42</age></Person>")
>>> p.name
u'Foo McBar'
>>> p.age
42

And you can render an object into an XML document like this:

>>> p = Person(name="Handsome B. Wonderful",age=36)
>>> p.render()
'<?xml version="1.0" ?><Person name="Handsome B. Wonderful"><age>36</age></Person>'

Malformed documents will raise a ParseError:

>>> p = Person.parse("<Person><age>92</age></Person>")
Traceback (most recent call last):
...
ParseError: required field not found: 'name'

Of course, it gets more interesting when you nest Model definitions, like this:

>>> class Group(dexml.Model):
... name = fields.String(attrname="name")
... members = fields.List(Person)
...
>>> g = Group(name="Monty Python")
>>> g.members.append(Person(name="John Cleese",age=69))
>>> g.members.append(Person(name="Terry Jones",age=67))
>>> g.render(fragment=True)
'<Group name="Monty Python"><Person name="John Cleese"><age>69</age></Person><Person name="Terry Jones"><age>67</age></Person></Group>'

License: Freeware

Related: gtgtgt, dexml, Class, Document, definitions, Import, parseerror, deadsimple, Object, objectxml, mapper, it039s, doesn, raise, Recent, Found, Field, required, Documents

O/S:BSD, Linux, Solaris, Mac OS X

File Size: 20.5 KB

Downloads: 2



User Review for dexml
- required fields
     

Please enter text on the image