[Zope] "subforlder" question - on Guest Book example (ZopeBook)

Luca Manini Luca Manini AgeLav <manini@agenzialavoro.tn.it>
Fri, 25 May 2001 10:02:50 +0200


Hi,=20

I'm trying my first stuff with Zope, following the ZopeBook's
examples. Now I'm trying the obviously important feature of letting
(Anonymous) users add and list "messages", so I'm studing the Guest
Book example that has a simple index_html (with the natural loop on
the users' messages), and the standard Form + Action + Script stuff
for adding messages.=20

Users' messages are added in the same folder where the "machinery" is,
but I would prefere to have them in a "Entries" subforder.=20

My question is: how should I do that. The solution I've found is to
change the original add Script (to be found at this message's end) to
accept and additional parameter (the subfolder) and to change all the
references to "context" to that parameter.

That works, but I feel I can (and should?) get the same effect just by
rearranging the way the GusetFolder is organized and let acquisition
do the magic of having the subfolder to be "passed" as context.

   Any hint? TIA, Luca.=20

-------------------- addEntryAction (DTML Method)

<dtml-var standard_html_header>

      <dtml-call expr=3D"addEntry(guest_name, comments)">

      <h1>Thanks for signing our guest book!</h1>

      <p><a href=3D"<dtml-var URL1>">Return</a>
      to the guest book.</p>

      <dtml-var standard_html_footer>

-------------------- addEntry (Script)

      """
      Create a guest book entry.
      """
      # create a unique document id
      id=3D'entry_%d' % len(context.objectIds())

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

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