Would you mind writing a trac/wiki page on this?

Thanks!

Cheers,
Simon

Sean Jamieson wrote:
> Hmm, either nobody is interested, or everybody is to busy...
> I'm going to assume the latter, for the sake of my own ego :-)
> 
> Just to recap, XMLModel allows you to expressively define an XML document,
> using native python classes, you can then access the elements of the XML 
> through
> a tree of native python objects.
> 
> In the future, I'm hoping to write a parser that can take a given model, 
> and fill in the data from an XML document. I don't imagine this being 
> too dificult, as a lot of the work is done by the model itself (it 
> defines what data to look for).
> 
> Here is an example of how XMLModel is used:
> 
> #!/usr/bin/env python
> from xmlmodel.main import *
> from xmlmodel.xmlvalues import *
> from datetime import datetime
> 
> 
> class rss( XMLModel ):
>     class XMLAttrs:
>         version = '2.0'
>    
>     class channel( XMLNode ):
>         title = XMLValue('test')
>         description = XMLValue('something')
>         link = XMLValue('http://here')
>         lastBuildDate = XMLDateTime( format = "%a, %d %b %Y %H:%M:%S EST" )
>         generator = XMLValue()
>         docs = XMLValue()
>        
>         class item( XMLNodeList ):
>             title = XMLValue()
>             link = XMLValue()
>             description = XMLValue()
>             category = XMLList()
>             pubDate = XMLDateTime( format = "%a, %d %b %Y %H:%M:%S EST" )
> 
> feed = rss()
> 
> feed.channel.title = 'Latest Headlines'
> feed.channel.description = 'Most Recent Headlines'
> feed.channel.generator = 'XMLModel 0.1a'
> feed.channel.lastBuildDate = datetime( 2006, 5, 10, 8, 24, 30 )
> 
> # Normally we would loop this ;-)
> item = feed.channel.item.new()
> item.title = 'foo'
> item.link = 'http://foo'
> item.description = 'foo bar'
> item.category.append( 'foo' )
> item.category.append( 'bar' )
> item.pubDate = datetime( 2005, 1, 2, 3, 4, 5 )
> 
> item = feed.channel.item.new()
> item.title = 'bar'
> item.link = 'http://bar'
> item.description = 'bar baz'
> item.category.append( 'bar' )
> item.category.append( 'baz' )
> item.pubDate = datetime( 2006, 2, 3, 4, 5, 6 )
> 
> print feed
> 
> # or this would be ever so slightly faster
> # (it made a one second difference, when generating 2.5MB of XML, on my 
> laptop)
> 
> # for buf in feed.toxml(): # toxml() is a generator
> #     print buf
> 
> Any comments, suggestions, or bug reports are welcome.
> 
> Sean
> 
> Sean Jamieson wrote:
> 
>> Well, it was a bit painfull, and I ran head first into several walls.
>> But here is the 0.1 alpha version of XMLModel.
>> if the attachment didn't work, here is a temporary link:
>>
>> http://www.barriescene.com/xmlmodel.tar.gz
>>
>>
>> Try it, let me know what you think, or of any bugs (patches welcome)
>>
>> I'll figure out an SVN for it later on.
>>
>> Sean
>> P.S. I just joined www.linkedin.com feel free to invite me using this 
>> address :-)
>>  
>>
> 
> 
> > 
> 

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/turbogears
-~----------~----~----~----~------~----~------~--~---

Reply via email to