[Zope-dev] implementing structured text alternative w/in Zope

Joachim Werner joe@iuveno.de
Fri, 07 Mar 2003 19:20:25 +0100


Toby Bologna schrieb:
> Hi,
> 
> I'm a programmer but new to Zope. I'm developing a text markup language
> like Structured Text that better suits my needs outside the Zope/Python
> world. Would I be able to incorporate it within Zope, i.e., so I could
> edit the new format in the edit window and have it displayed as HTML by
> the server, handled as a Zope object, etc.?
> 
> I'd like to do it as transparently as (on the lowest level) possible,
> but if it turns out I have to do it as a feature of a product, that
> will be OK. Any tips for either scenario much appreciated.

Of course you can do that with Zope. You'll find quite a few examples of 
new markup languages for Zope if you browse the Products list on zope.org.

You definitely will have to write a product for this.

You need a basic method or document object (like DTMLMethod). Writing or 
adapting the over-the-web edit screens is simple. The harder part will 
be the parser that generates the HTML for you. But I guess you know how 
to do this.

There is one thing that might be trickier than you'd expect: If you want 
to have the same security features as in DTML or ZPT (i.e. checking for 
every method call and attribute if the viewer has the permissions to 
execute/view them) you will have to implement much of that on your own 
in the language parser.

Note that if you keep it as simple as structured text you won't need to 
care about the security issue. In structured text you don't call other 
code or attributes ...

The document object will have to implement a __call__() (or 
index_html()) method for it. This method has to take the code (that is 
stored in a property of the object) and render it. Then you just 
"return" the result at the end. It's really not that difficult, and if 
you take a similar product and look at the code it is relatively easy to 
understand.

Be sure that you read the Zope Developers Guide on zope.org first!

Joachim