[Zope] Creating objects within a dynamic folder
Paul Smith
paul.smith@bristol.ac.uk
Thu, 03 Oct 2002 14:24:35 +0100
Dear all,
Apologies if this seems a dumb question, but I've developed Zope-blindness
from looking at this for a while now, and would appreciate someone pointing
me in the right direction...
I'm trying to create a simple product for adding News items to folders
within the ZODB. I am wanting to create the folder if it does not exist,
and the folder name is built from values passed through from the form
preceeding the constructor. Once the folder is created, or if it already
exists, a news item should be added within the folder. This is where I am
hitting a wall - I can't seem to create a namespace which allows me to
create an object within the folder... The following is working code which
creates a folder if needed, and the news item, but the next step is to
create a news item within the newly created / existing folder.
<dtml-call "REQUEST.set('folderdate', displayfrom_month + displayfrom_year)">
<dtml-if "_.hasattr(this(), folderdate )">
<p><dtml-var folderdate> exists.</p>
<dtml-with "newseventitem.createInObjectManager(REQUEST['id'], REQUEST)">
<dtml-call "propertysheets.newsevent.manage_editProperties(REQUEST)">
<dtml-call reindex_object>
</dtml-with>
<dtml-else>
<dtml-call "manage_addFolder(id=folderdate,title=folderdate)">
<dtml-with "newseventitem.createInObjectManager(REQUEST['id'], REQUEST)">
<dtml-call "propertysheets.newsevent.manage_editProperties(REQUEST)">
<dtml-call reindex_object>
</dtml-with>
<p><dtml-var folderdate> doesn't exist.</p>
<p>Item added</p>
</dtml-if>
[newseventitem is the ZClass, and newsevent is the propertysheet associated
with this ZClass]
If anyone can point me the right direction, or suggest a better way of
doing this, I would be most grateful.
Cheers
Paul
------------------------------------------------------------------------------------------------------------
Paul.Smith@bristol.ac.uk
Senior Technical Officer (Web Development),
Internet Development Group | RDN Virtual Training Suite
http://www.ilrt.bris.ac.uk/id/ | http://www.vts.rdn.ac.uk/
Institute for Learning and Research Technology,
University of Bristol, 8-10 Berkeley Square,
Bristol BS8 1HH, UK Tel: +44 (0)117 928 7192, Fax: +44 (0)117 928 7112