[Zope-book] RE: [Zope] New version of book uploaded

M. Adam Kendall akendall at devis.com
Thu Dec 7 21:07:26 EST 2000


Ok, in chapter 8 you talk of Python Scripts, and you
also make sure you call them scripts.  For instance:

--Start--
One interesting function of the whrandom module is the choice function that
returns a random selection from a sequence of objects. Here's an example of
how to use this function in a Python Script called randomImage:

            """
            When called on a Folder that contains Image objects this
            script returns a random image.
            """
            import whrandom
            return whrandom.choice(context.objectValues('Image'))

Suppose you had a Folder named Images that contained a number images. You
could display a random image from the folder in DTML like so:

        <dtml-with Images>
          <dtml-var randomImage>
        </dtml-with>

This DTML calls the randomImage script on the Images folder. The result is a
HTML IMG tag that references a random image in the Images Folder.
--End--
Notice, you say, "calls the randomImage script"
But in chapter 12, you get a bit backtracked, and
call a script a method like so:
--Start--
First create a new Folder named exhibitTemplate in your Product. This will
serve as a template for exhibits. Also in the Product folder create a DTML
Method named addForm, and Python Script named add. These methods will create
new exhibit instances. Now go back to your Factory and change it so that the
Add list name is Zoo Exhibit and the method is addForm.

So what's going to happen is that when someone chooses Zoo Exhibit from the
product add list, the addForm method will run. This method should collect
information about the id and title of the exhibit. When the user clicks Add
it should call the add method that will copy the exhibitTemplate folder into
the calling folder and will rename it to have the specified id.
--End--
Notice, they should be calling the add script, not add method if you want to
get technical
about your name calling.

--
M. Adam Kendall         |       Got Linux?
Internetworking &       |         We do.
 Security Architect     |
akendall at devis.com      |  http://www.devis.com





More information about the Zope-book mailing list