[Zope] rendering a complete HTML file

Pieter Claassen Pieter Claassen" <pieter@openauth.co.uk
Tue, 28 Jan 2003 14:36:05 -0000


Hi Pablo,

Here is my two cents. If I understand correctly, you are trying to pass an
id reference of a document (object) that you actually want to display, to an
existing document (object) and will then in your existing document pull the
new one to be displayed in and render it as a dtml-var?

If that is what you are trying to do, then you (I recently spend around 8
hours to solve this problem and the light came on at 2 am!!) should rethink
your design.

The problem lies in the design of OO software. You are trying to implement a
display method in a container that takes the id of an obect to display which
it then has to pull in and render. Can be done, but messy (especially in
Zope because these are not real objects and more).

What you should do is build a display method that will display any object
whose ID it is given, as long as it can find the object in the namespace.
Create a new dtml_method called "display" in a container. This method is
very very simple and should only render the id of the document that is top
in the namespace (something like <dtml-var id>).
Then you call the object that you want to display directly through the web.
Let me see if I can explain this by example.

You had a link: http://url/object?object_to_be_display_id=id
and you wanted to render that object_to_be_displayed in object?
Now you should have a link:
http://url/object/object_to_be_displayed_id/display (the subfolder is just
to make sure it inherits the "display" method from the container above.But
you can create this method custom in each folder where
object_to_be_displayed is)

If you are cunning then you could build a structure like inherrits the
display method from a high level container so you only create it once and it
can be called on any object beneath it.

IMHO this is one of the important parts of OO design, but sadly it is not
that clearly documented in Zope docs.

Hope this helps.
Pieter

www.openauth.co.uk





----- Original Message -----
From: "Pablo Gomez" <pgomezg@fastmail.fm>
To: <zope@zope.org>
Sent: Tuesday, January 28, 2003 10:15 AM
Subject: [Zope] rendering a complete HTML file


> Hello zopers!
>
> I am new at this list (hello everybody!) and quite new at Zope. After my
> first steps in using Zope, I am developing a small simple app that
> should show the content of a HTML file to the user.
>
> I have met a problem that might be easy for others but leaves me stucked.
>
> This is the explanation. There is a DTML-method (arbol_html) that includes
>
> <dtml-in expr="objectValues('File')">
> <a href="showdoc_html?htmldoc=&dtml-id;" ><dtml-var title_or_id></a>
> </dtml-in>
>
> As you can see it invokes showdoc_html that should render the HTML file
> content. I have tried several methods but none is satisfactory. Of
> course I am opened to the idea of changing the URL calling method.
> Perhaps it's time to use python scripts yet I still feel myself
> uncomfortable with python :-(
>
> Any help is valuable. Thanks in advance
>
> Pablo Gomez
>
>
>
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope-dev )
>
>