ZPublisher guestbook.py
I got stuck implementing the examples in "A Technical Introduction to Object Publishing with Zope" <http://www.zope.org/Documentation/Reference/ObjectPublishingIntro> with the stand-alone ZPublisher. In the "guestbook.py" example, what should be the URL invoked to show the form? The module is called guestbook.py, the class is GuestBook and the method is defined as "def guestbookForm(self)". I've been succesful installing and runnig the previous examples but in this case I don't know what should be the first URL called to run the Guestobook application. If I type: <http://localhost/cgi-bin/GuestBook.zcgi/GuestBook> I get this: -- GuestBook.GuestBook -- (The Guesbook __repr__?) If I type: <http://localhost/cgi-bin/GuestBook.zcgi/GuestBook/guestbookForm> I get: -- Sorry, an error occurred. Traceback (innermost last): File C:\Zope\lib\python\ZPublisher\Publish.py, line 879, in publish_module File C:\Zope\lib\python\ZPublisher\Publish.py, line 595, in publish (Info: /GuestBook/guestbookForm) TypeError: unbound method must be called with class instance 1st argument -- Thanks for any help. []s Luciano Ramalho -- MAGNET <http://magnet.com.br> Tecnologia em lĂngua de gente.
At 06:21 PM 2/15/99 -0300, Luciano Ramalho wrote:
I got stuck implementing the examples in "A Technical Introduction to Object Publishing with Zope" <http://www.zope.org/Documentation/Reference/ObjectPublishingIntro> with the stand-alone ZPublisher.
In the "guestbook.py" example, what should be the URL invoked to show the form? The module is called guestbook.py, the class is GuestBook and the method is defined as "def guestbookForm(self)".
I've been succesful installing and runnig the previous examples but in this case I don't know what should be the first URL called to run the Guestobook application.
The trick is to realize the ZPublisher publishes *instances*, not classes. It is not enough to define a class, you must create an instance of that class, and call the instance. Notice the last two lines of guestbook.py # Create an instance of a GuestBook myGuestBook=GuestBook('My GuestBook', 'guestbookdata.txt') This is the guestbook instance that you want to publish. So your URL will look something like this: http://localhost/cgi-bin/GuestBook.zcgi/myGuestBook Make sense? -Amos
At 12:55 15/02/99 -0800, Amos Latteier wrote:
The trick is to realize the ZPublisher publishes *instances*, not classes. It is not enough to define a class, you must create an instance of that class, and call the instance.
Notice the last two lines of guestbook.py
# Create an instance of a GuestBook myGuestBook=GuestBook('My GuestBook', 'guestbookdata.txt')
This is the guestbook instance that you want to publish.
So your URL will look something like this:
Actually, this points to the myGuestBook instance, which returns the memory position of the instance, because the GuestBook class does not implement an 'index_html' method. The full URL to start the GuestBook would be: http://localhost/cgi-bin/GuestBook.zcgi/myGuestBook/guestbookForm My mistake and your reply were great to clarify the issue. The insight about publishing *instances* is precious!!! []s Luciano Ramalho /"\ \ / CAMPANHA DA FITA ASCII - CONTRA MAIL HTML
X< ASCII RIBBON CAMPAIGN - AGAINST HTML MAIL / \
participants (3)
-
Amos Latteier -
Luciano Ramalho -
Luciano Ramalho