[Zope] StructuredDocuments

Jeff Hoffman jeff@goingv.com
Wed, 16 Feb 2000 22:23:33 -0500 (EST)


Hey, guys.

For what it's worth, I got a simple StructuredDocument ZClass to work,
even when used as index_html. Here's how:

I created a Python product called StructuredDocumentBase that included a
class of the same name. This class is defined as follows:

from OFS.DTMLDocument import DTMLDocument
from StructuredText.StructuredText import html_with_references

class StructuredDocumentBase:
    """Mix-in for StructuredDocument ZClass."""
    def __call__(self, client = None, REQUEST = {}, RESPONSE = None,
                 **kw):
        """Render the document given a client object, REQUEST mapping,
           response, and keyword arguments."""
        header = apply(self.standard_html_header.__call__,
                       (client, REQUEST),
                       kw)
        body = html_with_references(apply(DTMLDocument.__call__,
                                          (self, client, REQUEST),
                                          kw))
        footer = apply(self.standard_html_footer.__call__,
                       (client, REQUEST),
                       kw)
        return '%s%s%s' % (header, body, footer)

Then, I created another product called StructuredDocument, this time
through the web. In this product, I created a ZClass called
StructuredDocument, which inherits first from StructuredDocumentBase and
then from DTMLDocument.

Then, I placed an instance in a folder, navigated to the URL, and it
worked.

I would package it up and upload it as a product, but a part of it is
broken--I can't rename the instance. This has nothing to do (AFAICT) with
the __call__ voodoo above, but seems to be due to my inheriting from
DTMLDocument; I created a simple ZClass that did nothing except inherit
from DTMLDocument and it exhibited the same behavior.

Anyways, Tres (or anyone using Tres's product), if you want to take this
idea and integrate it into your STX_Document class that'd be cool. If not,
I'll make a more complete (and tested) implementation when I can find the
time.

Hope this helps,

--Jeff

---
Jeff K. Hoffman                                         704.849.0731 x108
Chief Technology Officer                                mailto:jeff@goingv.com
Going Virtual, L.L.C.                                   http://www.goingv.com/