Zope cannot find the tutorial examples. You should install the tutorial examples before continuing. Choose "Zope Tutorial" from the product add list in the Zope management screen to install the examples.
If you have already installed the tutorial, you can either follow along manually, or reinstall the tutorial examples. Note: make sure that you have cookies turned on in your browser.People who come to your site want a personal relationship with Elvis. You can provide this by tailoring your site to the needs and preferences of your viewers. Let's add the ability to bring new Elvis sightings to the attention of site visitors. This way when a visitor comes to your site they'll immediately know which sightings are new since they last visited.
sightings.htmltemplate to edit it.
Testtab to view it.
All the sightings should be marked as new.
Now none of the sightings should be marked as new. This is because you've already seen them.
sightingsFolderfolder to enter it.
Filefrom the "Select type to add..." list.
Seattlefor the id.
<p>6/1/2003 -- Seattle</p> <p>Elvis spotted spare changing on Broadway. He denied being the King.</p>
Now you've created a new sighting. Let's see if it is marked as new by the sightings page.
sightings.htmlpage in the
Sure enough our new sighting is marked new.
How does this work? It uses HTTP Cookies. When you visit the
sightings.html page a cookie is set that records the current
time. Then each time you return to the page sightings that are newer
than the cookie will be marked as new.
Let's look at how this works.
sightings.htmltemplate to view its contents.
Notice that the page uses the tal:define statement to defines a
lastVisit variable. It is defined by calling the
script. This variable holds the time that the user last visited the
page as recorded in a cookie.
Later in the template this time is compared to the modification time
of each sighting object. If the sighting is new then it is marked as
such by including a bold tag. The bold tag uses the tal:condition
statement to optionally include its contents. In this case the
condition checks to see whether the
the sighting is newer than the last visit. This strangely named
method keeps track of the last modification date of Zope objects.
Now let's examine the
lastVisit.pyscript to view it.
Notice how it includes comments explaining its functioning. Comments begin with a number sign. The script does two things: it retrieves a cookie from the request, and it sets a new cookie using the response.
bobobase_modification_datemethod returns the last modification time of an object.
In the next lesson you'll learn how to create a mail feedback form.