anyway I promise I'll soon make my patch work but I was reading Bruce Eckel blog, i'm not sure if you know him but he is a big guy in Java and recently has move to python a LOT, basically he did what your code does :) maybe you want to make a post there telling him of ur code.
http://www.artima.com/weblogs/viewpost.jsp?thread=163393
On 5/27/06, Sean Jamieson
<[EMAIL PROTECTED]> wrote:
Ok, so I started playing with your patch.
I made a couple changes to get it closer to working
(most of the diff makes formatting consistent, sorry)
The important changes are:
1. call _createTree through self
2. add an argument to _createTree, which is a reference to the
current node object (and Element doesnt have the XMLAttrs attribute ;-)
Line 76: self._createTree( rootNode, self )
Line 79: def _createTree( self, node, obj ):
Line 80: for attr, value in obj.XMLAttrs.iteritems ():
Line 83: if isinstance( v, XMLNode ) or inspect.isclass( v ) and
issubclass( v, XMLNode ):
Line 85: elif isinstance( v, XMLValue ):
But, for some reason, it is recursing infinitely (boy was that looooong
backtrace scrolling up my screen fun)
Unfortunately the message is useless, and I don't know anything about
ElementTree to understand the details of what your code does at the moment.
Sean
Jorge Vargas wrote:
> On 5/25/06, *Sean Jamieson* <[EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]>> wrote:
>
>
> Yep, working code is on pypi: http://www.python.org/pypi/xmlmodel
>
>
> nice /me goes to poke around.
>
> some comments
> ------------
> where does this comes from?
> from meta import TrackableTrackerMeta
> its failing in after easy_install
>
> >>> import xmlmodel
> Traceback (most recent call last):
> File "<stdin>", line 1, in ?
> File "build\bdist.win32\egg\xmlmodel\__init__.py", line 1, in ?
> File "build\bdist.win32\egg\xmlmodel\main.py", line 4, in ?
> ImportError: No module named meta
>
> and I have never heard of that module
> -------------
> I notice your using DictObj from
> http://trac.turbogears.org/turbogears/ticket/779
> I think it could be replace with Bunch, as TG did
> -------------
> one thing that let me wondering is where does _order comes from in XMLNode
> -------------
> I really love your generators for the XML very nice implementation
> ------------
> Now this will be funny even without getting it to compile I did an
> elementTree layout so as Linus ones said about a kernel
> If it works you should be double impress :)
>
> I added 2 methods to XMLModel which mimic what your toXML do, but
> since it's objects not a string I just made the recursive call there,
> since I couldn't run it I'm not sure I got the correct value for v
>
> Jorge Vargas wrote:
>
> > On 5/25/06, *Sean Jamieson* < [EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]>
> > <mailto:[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>>> wrote:
> >
> >
> > I was thinking about integrating cElementTree in the future,
> >
> >
> > I think that is the way to go, it gives everything you need and has
> > been tested a lot.
> >
> > but to make
> > a quick proof of concept, I just have my toxml() manually
> assembling a
> > string, using generators.
> >
> >
> > that's ok, but soon you'll need a nice backend :)
> >
> > you actually got workign code? if it's possible can I take a look?
> >
> > currently, XMLValue and it's subclasses are optional, with a
> > 'required'
> > bool keyword argument to __init__, also an XMLNodeList can
> have 0
> > items
> > (and therefore not appear)
> >
> > I could add another magic attribute parsed from XMLAttrs, like
> > _tagname,
> > called _required ...
> >
> >
> > I think there should be a general way (classes,fields) to tell the
> > engine which fields are optional and which aren't, so the render
> > function can detect a malform object, but this could turn into a
> huge
> > validation scheme which I'm not sure if you want. Although if
> you ever
> > generate some xml-based std, there should be a validation
> >
> > but generally if a tag has child tags, its going to be used.
> >
> >
> > yes that's the way it should
> >
> > I've seen hypy before, some months ago, it's yet another
> template
> > language;
> > It is an interesting idea though.
> >
> >
> > I like the indentation thing which is basically what your doing
> here,
> > what i don't like is the placeholder which you avoid with the class
> > structure.
> >
> > ------
> >
> > Sean
> >
> >
> > Jorge Vargas wrote:
> >
> > > On 4/28/06, *Sean Jamieson* < [EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]>
> > <mailto: [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>>
> > > <mailto:[EMAIL PROTECTED] <mailto: [EMAIL PROTECTED]>
> <mailto: [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>>>> wrote:
> > >
> > > Sorry for bringing this old topic up, but I was just
> playing with
> > > ElementTree yesterday and I made a link to this
> > > I believe your model can be implemented on top of
> ElementTree,
> > to give
> > > it a more friendly interface.
> > >
> > > class RSS2( XMLModel ):
> > > class XMLAttrs:
> > > _tagname = 'rss'
> > > version = ' 2.0'
> > >
> > > class channel( XMLNode ):
> > > title = XMLString()
> > > description = XMLString()
> > > link = XMLString()
> > > lastBuildDate = XMLDate( format = "%a, %d %b
> %Y %H:%M:%S
> > > EST" )
> > > generator = XMLString()
> > > docs = XMLString()
> > >
> > > class item( XMLNodeList ):
> > > title = XMLString()
> > > link = XMLString()
> > > description = XMLString()
> > > category = XMLList( type = XMLString() )
> > > pubDate = XMLDate( format = "%a, %d %b %Y
> > %H:%M:%S EST" )
> > >
> > >
> > > Based on your example
> > > all the helper classes extend the Element
> > > even XMLModel is an extension to the Element.
> > >
> > > So all that needs to be done is a render function that
> will take
> > your
> > > class and do some calls to SubElement
> > >
> > > One question, how will you manage optional elements in the
> template?
> > >
> > > how is that?
> > >
> > > on the other hand I remenber looking at
> > > http://manatlan.online.fr/hypy.php
> > > < http://manatlan.online.fr/hypy.php> it's something
> similar but
> > based
> > > on indentation no classes.
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

