Doing some work on my z3 class generator - mrtopf.demrtopf.de

Doing some work on my z3 class generator

Some time ago I tried to learn a bit of XSL and as I also started doing Zope 3 via Philipp’s Book I started a project in which I tried to create the class, interfaces and zcml files automatically.

So I started out with some input XML file like this:

  <z3definitions>
  <type name="Person" description="a person">
      <field type="textline" name="Name" required="1" />
      <field type="CV" name="cv" />
      <field type="text" name="address" title="Adresse" description="enter your address" />
  </type>
  </z3definitions>

So from this input file I tried to create the class, the interface.py and the configure.zcml.

I did this using xsltproc and it worked after a while in general. What I noticed though was a lot of bloated XSL stylesheet as it get’s very verbose if you even just want to do a little advanced stuff, like capitalizing the class name or so.

So these days I was revisiting the project and converted it to lxml which gave me the opportunity to preprocess the XML tree before giving it to XSLT and using python to compute classnames and the like.

So now it seems basically working and I am planning to put it into SVN soon as maybe some other people might be interested. I am also planning to extend this to create the browser views also. All in all it would be a good starting point for one’s project without all this typing you’d have to do otherwise.

A last thing might be that I actually should test if these classes also do work with Zope3 ;-)

Kommentare sind geschlossen.