[ZDP] BackTalk to Document The Zope Book (2.5 Edition)/Creating Basic Zope Applications

webmaster@zope.org webmaster@zope.org
Thu, 17 Oct 2002 04:42:24 -0400

A comment to the paragraph below was recently added via http://www.zope.org/Documentation/Books/ZopeBook/current/SimpleExamples.stx#3-69


      The last remaining piece of the puzzle is to write the script that
      will create a file and sets its contents and properties. We'll do
      this in Python since it is much clearer than doing it in DTML. Create
      a Python-based Script in the *GuestBook* folder called *addEntry*
      with parameters *guest_name* and *comments*::

        ## Script (Python) "addEntry"
        ##parameters=guest_name, comments
        Create a guest book entry.
        # create a unique file id
        id='entry_%d' % len(context.objectIds())

        # create the file
                                                 title="", file=comments)

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

        % Anonymous User - May 22, 2002 11:06 am:
         Where does the ['OFSP'] come from?
         After digging around and doing a few searches,  I found it's a core part of
         Zope,   but no explainations.

        % Anonymous User - June 12, 2002 12:38 pm:
         I get an error that states:
         Error Type: TypeError
         Error Value: addEntry() takes no arguments (2 given)

         What did I do wrong?

        % Anonymous User - June 15, 2002 9:54 am:
         You forgot to include the parameters for the Python script in the Parameters field when pasting the script
         into a new Python Script object. You need to explicitly state what parameter your python 'function' takes
         when creating the script.

        % Anonymous User - Aug. 9, 2002 7:32 am:
         What`s 'OFSP'?pls include atleast single line explanations of new terms introduced in each chapter.

        % Anonymous User - Oct. 17, 2002 4:42 am:
         Does 'doc=getattr(context, id)' returns an instance of the file object class? What if there's another way of
         getting the instance of that object, can we use it to call the method 'doc.manage_addProperty'?