[Twisted-web] Doing pure XML with stan

Gwenaël Rémond gwenael.remond at gmail.com
Tue Jul 12 02:02:09 MDT 2005

> 1.) Can't see an easy way to specify that a tag is a single, i.e <bug/>

I don't use directly the prototype class as you do, but when I
customize my tag list in nevow.tags, it clearly allows any kind of
singleton, for example :

from nevow import loaders
import tags as T
doc = loaders.stan(T.toto)
from nevow.flat.ten import flatten
print flatten(doc)

# and the result is : 
# <toto />

I use nevow-0.4.1 and it is weird to notice that there is actually an
allowSingleton  variable in the nevow.flat.flatstan module, obviously
any kind of tag  is allowed, but it's good news...

2005/7/6, Michael M <m.milvo at gmail.com>:
> Hi all,
> Firstly what I want to do is produce a well formatted xml document
> using stan. I worked out that adding the follow to the
> stan.py->Proto() class
>     def __getattr__(self, name):
>         return Tag(name)
> allows me to do
> T = Proto()
> T.hairy[
>     T.dog(lice='yes')[T.smells(status=True)]
> ]
> In other words I can create arbitary tags with same ease as with the
> tags module. Two problems stand in my way of producing pure xml
> documents using stan.
> 1.) Can't see an easy way to specify that a tag is a single, i.e <bug/>
> 2.) Don't know where to look to see if I can code a solution to the
> xml presentation problem. If this isn't already solved, could somebody
> point in the direction of where I should look to solve this. I solved
> this problem with my own code by using a position variable to be
> incremented, decremented as tags are rendered. Tags then can simply
> call getSpace() and get some whitespace to pad themselves with. Any
> way of doing this with stan, if it hasn't already been done of course.
> Example of what I want :)
> <prettyxml>
>     <morexml>
>         Looks nice and pretty.
>     </morexml>
> </prettyxml>
> Thanks in advance
> _______________________________________________
> Twisted-web mailing list
> Twisted-web at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web

More information about the Twisted-web mailing list