[Twisted-web] Doing pure XML with stan

Michael M m.milvo at gmail.com
Tue Jul 5 23:56:54 MDT 2005


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



More information about the Twisted-web mailing list