[Zope] Formatted Documents

Amos Latteier amos@aracnet.com
Wed, 29 Sep 1999 23:45:22 -0700


At 10:58 AM 9/30/99 +1000, Grant Street wrote:

>I noticed that when you log in to the Zope site you can add
>a "Formatted Document". 
>Is this product available ? I looked in bothe Zope sites and I'm feeling a
>bit confused?
>I've been looking for somthing like this for a while. 

Formatted Document is not currently available. You could whip one up pretty
easily, using Z Classes, just like I did.

Basically define a couple properties, say 'content' of type 'text', and
'format' of type 'string'. One property will hold the content of the
document, and one will specify the formatting. Then in the index_html
method of the ZClass do something like this,

<dtml-var standard_html_header>
<dtml-if "format=='structured-text'">
<dtml-var content fmt="structured-text">
</dtml-if>
<dtml-if "format=='html'">
<dtml-var content>
</dtml-if>
<dtml-var standard_html_footer>

You can add any other formatting options you want.

The way I allowed for acquired formatting methods is like so,

<dtml-if "format=='acquired'>
<dtml-var "_.getitem(format_method,0)(this(),REQUEST)">
</dtml-if>

This says to get the object whose name is given by the variable
'format_method' then call it with two arguments: this(), which is the
formatted document, and the REQUEST.

BTW, this is a rather low performance solution to a multiply formattable
document. You should look at developing a full Zope Product that is a lot
smarter if you care about high performance formatting.

Good luck!

-Amos