[ZDP] Extending Zope

Tom Snell tsnell at enervation.com
Mon Oct 6 04:18:52 EDT 2003


      Creating Methods on your ZClass

The text reads (as corrected by various readers):

Create a new DTML Method on the Methods tab of your ZooExhibit ZClass 
called index_html.
... Put the following DTML in the index_html Method you just created:

    <dtml-var standard_html_header>

    <h1><dtml-var animal></h1>

    <p><dtml-var description></p>

    <p>The <dtml-var animal> caretakers are:<br>
    <dtml-in caretakers>
    <dtml-var sequence-item><br>
    </dtml-in>
    </p>

<dtml-var standard_html_footer>

At this point this returns an error, because "animal" is not found in 
the Propertysheets.

The text continues, suggesting a test be entered in your browser: 
http://www.zopezoo.org/Exhibits/FangedRabbits/.  This site does not 
exist.  Therefore, the test flops.

"To create the isHungry method,
a) first create two new properties in the ExhibitProperties property sheet
named "last_meal_time" that is of the type date (enter a date on the 
last_meal_time property in the following format: 2002/08/20 13:00:00 
GMT+9)and
b)"isDangerous" that is of the type boolean.

The above isHungry text is no longer problematical.  It continues, 
however, with:

Here is an example of an implementation of the isHungry method in Python:

    ## Script (Python) "isHungry"
    ##
    """
    Returns true if the animal hasn't eaten in over 8 hours
    """
    from DateTime import DateTime
    if (DateTime().timeTime()
    - container.last_meal_time.timeTime() > 60 * 60 * 8):
    return 1
    else:

    return 0

The above comment is not an instruction to a student of Zope.  It says 
it is an example of code.  What should the instruction look like 
please?  I tried the following logic:
a) Return to your Product folder ZooExhibit (the container, as the text 
points out).
b) From the add list select DTML Method
c) Name it isHungry and save it
d) Click on isHungry
e) Copy the Python script from the text box and save it.

This cannot be tested alone, because it merely checks the time and 
passes on a parameter to another script.  Thus, the text continues:
You could call this method from your index_html display method using 
this snippet of DTML:

    <dtml-if isHungry>
    <p><dtml-var animal> is hungry</p>

</dtml-if>

"animal" does not exist anywhere.

I do not know what to do with the "animal".  Should this call be 
something like:
<p><dtml-var animal> is hungry</p>


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.zope.org/pipermail/zdp/attachments/20031006/43d1ddf6/attachment.html


More information about the ZDP mailing list