[ZDP] Extending Zope - Repeating the steps outline in the text,
pointing out errors and asking questions
Tom Snell
tsnell at enervation.com
Fri Sep 26 12:39:31 EDT 2003
Extending Zope
Step
Action
Comment
Creating Zope Products
1
Product Management folder: Click on the Control_Panel in the root
folder and then click Products
Creating A Simple Product
2 click the Add Product button on the Product Management folder
(Product add form)
3
Enter the id "ZooExhibit" and click Generate. ( Product at
/Control_Panel/Products/ZooExhibit )
4 Select the ZooExhibit Product.
5
In the Contents View create a DTML Method named hello with these
contents: (insert code from text box)
6
Select Zope Factory from the product add list.
7
Give your Factory an id of myFactory
8
In the Add list name field enter Hello and in the Method selection,
choose hello. ( Zope Factory at
/Control_Panel/Products/ZooExhibit/MyFactory )
9
Go to the root folder and click the product add list. Notice that it
now includes an entry named Hello.
Choose Hello
10
create a new Folder named exhibitTemplate in your Product.
11
Also in the Product folder ( Product at
/Control_Panel/Products/ZooExhibit) create a DTML Method named addForm,
12
and Python Script named add.
13
go back to your Factory and change it so that the Add list name is Zoo
Exhibit and the method is addForm.
14
The next step is to edit the addForm method to have these contents:
(insert code from text box)
15
Now paste the following body into the add script: (If you paste in with
the first three '##' lines, you get an
error. Remove those lines and set the parameters in the 'Parameters'
form field above the window. Omit "Parameters=" and only insert "id
,title, REQUEST=None") Text not clear
16
Switch to the "Test" tab. This calls a view requesting values for the
parameters. Provide an "id" value and a "Title" value.
Missing totally
Creating ZClasses
17
rename the existing ZooExhibit Product in your Zope Products folder to
something else, like ZooTemplate so that it does not conflict with this
example. Done
18
create a new Product in the Product folder called ZooExhibit.
19
Go into the ZooExhibit Product you just created and elect ZClass from the add list of the
ZooExhibit Contents view and go to the ZClass add form.
20
For ID choose the name ZooExhibit
21
For Meta Type choose the name ZooExhibit
22
Constructor objects: leave this box checked.
23
persistent object base classes: leave this box checked.
24
Now click Add.
Click on the new ZClass and click on its Basic tab. (This step only
requires reading. No new object is created)
25
go to your root folder
26
select Folder from the add list and create a new folder with the id
"Exhibits"
27
click on the Exhibits folder you just created and
28
Go ahead and select ZooExhibit from the add list and create a new
Exhibit with the id "FangedRabbits".
29
select it by clicking on it. (No action is required here.)
Creating Views of Your ZClass
30 Go to your ZooExhibit ZClass and click on the Views tab. ( Z Class
at /Control_Panel/Products/ZooExhibit/ZooExhibit/propertysheets/views )
Note: The following sentence is incorrect: " The Method column on the
Methods view has select boxes that let you choose which method generates
which view. The method associated with a view can be either an object in
the Methods view, or a Property Sheet in the Property Sheets view." It
might better read: "The Method column on this view has drop down menues
which can be activated using the select boxes on the far left."
Paragraph.
"The method associated with a view can be either an object in the
Methods view, or a Property Sheet in the Property Sheets view."
Incorrect statement.
Separate paragraph recommended
Creating Properties on Your ZClass
31 Go to your ZooExhibit ZClass and click on the Property Sheets tab.
32
To create a new sheet, click Add Common Instance Property Sheet. This
will take you to the Property Sheet add form.
33
Call your new Property Sheet "ExhibitProperties" and click Add.
34
Click on the new sheet to manage it, as shown in [12-6]
<http://zope.org/Documentation/Books/ZopeBook/2_6Edition/CustomZopeObjects.stx/#ref12-6>.
35
Create three new properties on this sheet: animal (type string),
description (type text), caretakers (type lines)
36
return to the ZooExhibit ZClass and click on the Views tab.
create a new view with the name Edit
Associate it with the method propertysheets/ExhibitProperties/manage_edit.
37
Now, go back to your Exhibits folder and look at an existing
ZooExhibit "FangedRabbit" instance. a new view called Edit has been
added to your object, as shown in Figure [12-7]
<http://zope.org/Documentation/Books/ZopeBook/2_6Edition/CustomZopeObjects.stx/#ref12-7>.
(ZooExhibit at /Exhibits/FanggedRabbits/propertysheets/ExhibitProperties )
Note: Figure 12-7 contains a link which is not in comformance with the
text. The reader has been instructed to create an instance
"FangedRabbit", not "ZooExhibit". The "Edit" view can be found under
"View" in FangedRabbit.
Incorrect statement
Link wrong
38
on the Edit view for your ZooExhibit FangedRabbit instance (not the
class), enter
"Fanged Rabbit" for the animal property,
the description "Fanged, carnivorous rabbits plagued early medieval
knights. They are known for their sharp, pointy teeth." and
two caretakers, "Tim" and "Somebody Else".
Now click Save Changes.
Incorrect statement
39
Go back to the ZooExhibit ZClass and look at the ExhibitProperties
Property Sheet. (No action is required, the point is that the Z Class
was not effected by the changes made in the instance.)
40
provide default values for properties on a Property Sheet. enter the
text "Describe your exhibit in this box" in the description property of
the ZooExhibit ZClass. (in the text this is merely a suggestion, not an
instruction. However, if not followed the subsequent instructions do
not produce the desired results.)
Reformulate to make it an instruction
41
Click "Save changes" (this instruction is missing in the text).
Missing
42
go back to your Exhibits folder and
create a new , ZooExhibit object,
supply the ID "Elephant" or some other appropriate name (this
instruction is not contained in the text)
Save it (this instruction is not contained in the text)
click on it and (this instruction is not contained in the text)
click on its Edit view. superfluous comma (,),
Step omitted,
Step omitted,
Step omitted,
43
go back to your ZClass and
click on the Views tab and
check the box to change the "Edit" view to be the first view
by clicking the First button.
Step omitted,
Creating Methods on your ZClass
44
Go to your ZooExhibit ZClass and click on the Methods tab. ( Z Class
at /Control_Panel/Products/ZooExhibit./ZooExhibit/propertysheets/methods )
45
Create a new DTML Method on the Methods tab of your ZooExhibit ZClass
called index_html.
46
Put the following DTML in the index_html Method you just created:
(insert code from text box)
47
Save it.
TO THIS POINT EVERYTHING WORKS, IF THE READER CAN FIGURE OUT WHAT IS
MEANT.
HOWEVER, THERE IS NO EXPLANATION OF HOW TO USE index_html. THEREFORE,
THERE IS NO WAY TO LOOK AT FangedRabbits or my Elephant pages. SO THE
NET RESULT IS: NO PRODUCT!
THE FOLLOWING POINTS DO NOT WORK. 48 - 53
48
visit one of your ZooExhibit instances directly through the web, for
example, http://www.zopezoo.org/Exhibits/FangedRabbits/
Unfortunately this does not work, probably because the "Zoo" is not
available now at "www.zopezoo.org"
Mess. Does not work
49
To create the isHungry method, 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
"isDangerous" that is of the type boolean.
Half the points are in reader comments, not the text
50
implementation of the isHungry method in Python: (the text does not
spell out the steps here and leave the newbee in the lurch. Presumably
they are as follows:)
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
d) Click on isHungry
e) Copy the Python script from the text box.
Point 50 has been created by me.
51
Go to your index_html and click on it.
Point 51 has been created by me.
52
From the text box preceeded by the text "you could improve the hunger
display like so:" copy that text, then return to index_html and prepare
to insert it.
Point 52 has been created by me.
53
Insert the code in front of <dtml-var standard_html_footer>, then enter
a carriage return.
Save it.
Point 52 has been created by me.
It does not work
ObjectManager ZClasses
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.zope.org/pipermail/zdp/attachments/20030926/f90e3229/attachment-0001.html
More information about the ZDP
mailing list