[Zope] python methods

Lee Reilly CS1997 lreilly@cs.strath.ac.uk
Thu, 23 Nov 2000 12:09:18 +0000


Hi,

I'm having problems with Python methods. I've followed the  instructions
for the guestbook example [1] to the letter but when I add the Python
method [2] is causes an error as follows:

Error Type: NameError
Error Value: context

TraceBack: Traceback (innermost last): File
/usr/local/Zope-2.1.6-src/lib/python/ZPublisher/Publish.py, line 165, in
publish File
/usr/local/Zope-2.1.6-src/lib/python/ZPublisher/mapply.py, line 160, in
mapply (Object: addEntryAction) File... etc. 

Can anyone offer any advice?

- Best regards,
Lee Reilly

[1] http://www.zope.org/Members/michel/ZB/SimpleExamples.html

[2] Python method
      """
      Create a guest book entry.
      """
      # create a unique document id
      id='entry_%d' % len(context.objectIds())

      # create the document
      context.manage_addProduct['OFSP'].manage_addDTMLDocument(id,
                                               title="", file=comments)

      # add a guest_name string property
      doc=getattr(context, id)
      doc.manage_addProperty('guest_name', guest_name, 'string')