[Zope] Creating objects within a dynamic folder

Doug Hellmann doug@hellfly.net
Thu, 3 Oct 2002 15:18:51 -0400


The first thing I would suggest is to forget about trying to do this in DTML. 
 Write a Script for it, so you can code your logic in Python.

You might also want to take a look at the CMFNewsFeed from the collective 
project on SourceForge (http://sourceforge.net/projects/collective/).  The 
code there runs as a ZEO client, but you could do much of the same thing in 
your product.

Doug

On Thursday 03 October 2002 9:24 am, Paul Smith wrote:
> 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
>
>
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope-dev )