[Zope] Adding zclass inside folder with python

Cliff Ford Cliff.Ford at ed.ac.uk
Wed May 18 05:55:25 EDT 2005


A couple of lines at the bottom show one way to create a folder and an 
object inside that folder...

Anthu Nguyen wrote:
> Hi,
> 
> I've tried everything I can think of and am probably missing something
> obvious - help...
> 
> I'm trying to (1) Create a folder, then (2) Add a new zclass inside that
> folder.
> Instead, the zclass is being added in the same space as the folder:
> 
> - What I want:
> 
> New Folder
>     New ZClass
> 
> - What's happening:
> 
> New Folder
> New ZClass
> 
> ===========
> The code that doesn't work:
> 
> request = context.REQUEST
> pbuildid = request.pbuildid
> 
> # Add a new folder with id=pbuildid
> context.manage_addFolder(id=pbuildid)
> 
> # Add a new instance of the ZClass inside new folder
> instance = context.pbuild.createInObjectManager(request['id'], request)
> instance.propertysheets.pbuild_properties.manage_editProperties(request)

context.manage_addProduct['OFSP'].manage_addFolder(REQUEST.Filename, 
REQUEST.Title)

# create an index_html DTML document
context[REQUEST.Filename].manage_addProduct['OFSP'].manage_addDTMLMethod('index_html',
title="", file="Initial content")

HTH

Cliff


More information about the Zope mailing list