<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
<title></title>
</head>
<body text="#000000" bgcolor="#ffffff">
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
<title></title>
<h3> Creating Methods on your ZClass</h3>
The text reads (as corrected by various readers): <br>
<br>
Create a new DTML Method on the <em>Methods</em> tab of your <em>ZooExhibit</em>
ZClass called <em>index_html</em>.<br>
... Put the following DTML in the <em>index_html</em> Method you just
created:
<blockquote><dtml-var standard_html_header><br>
<br>
<h1><dtml-var animal></h1><br>
<br>
<p><dtml-var description></p><br>
<br>
<p>The <dtml-var animal> caretakers are:<br><br>
<dtml-in caretakers><br>
<dtml-var sequence-item><br><br>
</dtml-in><br>
</p><br>
</blockquote>
<pre class="simple_example"><dtml-var standard_html_footer>
</pre>
At this point this returns an error, because <font color="#3333ff">"animal"
is not found in the Propertysheets</font>.<br>
<br>
The text continues, suggesting a test be entered in your browser: <em><a
class="moz-txt-link-freetext"
href="http://www.zopezoo.org/Exhibits/FangedRabbits/">http://www.zopezoo.org/Exhibits/FangedRabbits/</a>.
<font color="#3333ff"><i>This site does not exist. Therefore, the test
flops.</i></font></em><br>
<br>
"To create the <em>isHungry</em>
method, <br>
a) first create two new properties in the <em>ExhibitProperties</em>
property sheet <br>
named "last_meal_time" that is of the type <em>date</em> (<span
style="font-family: monospace;">enter a date on the last_meal_time
property in the following format: 2002/08/20 13:00:00 GMT+9)and<br>
b)"isDangerous" that is of the type boolean.<br>
<br>
The above </span> <em>isHungry </em><span
style="font-family: monospace;">text is no longer problematical. It
continues, however, with:<br>
<br>
</span> Here is an example of an implementation of the <em>isHungry</em>
method in Python: <br>
<br>
<blockquote>## Script (Python) "isHungry"<br>
##<br>
"""<br>
Returns true if the animal hasn't eaten in over 8 hours<br>
"""<br>
from DateTime import DateTime<br>
if (DateTime().timeTime() <br>
- container.last_meal_time.timeTime() > 60 * 60 * 8):<br>
return 1<br>
else:<br>
</blockquote>
<pre class="simple_example"> return 0</pre>
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:<br>
a) Return to your Product folder ZooExhibit (the container, as the text
points out).<br>
b) From the add list select DTML Method<br>
c) Name it <span style="font-style: italic;">isHungry and save it<br>
</span>d) Click on<span style="font-style: italic;"> isHungry<br>
</span>e) Copy the Python script from the text box and save it.<br>
<br>
This cannot be tested alone, because it merely checks the time and
passes on a parameter to another script. Thus, the text continues:<br>
You could call this method from your <em>index_html</em> display
method using this snippet of DTML:<br>
<blockquote><dtml-if isHungry><br>
<p><dtml-var animal> is hungry</p><br>
</blockquote>
<blockquote>
<pre class="simple_example"></dtml-if></pre>
</blockquote>
<font color="#3333ff">"animal" does not exist</font> anywhere.<br>
<br>
I do not know what to do with the "animal". Should this call be
something like:<br>
<p><dtml-var animal> is hungry</p><br>
<br>
<br>
</body>
</html>