[Zope3-Users] automatically adding content container

Alen Stanisic alens at mbase.com.au
Tue May 24 04:57:33 EDT 2005


Hi all,

I am still in the process of learning zope3 and I must say so far it is
very impressive stuff.

I have hit a bit of a hurdle while trying to automatically add my
content's object container while adding the content object (i.e.
automatically add the parent container after form validation of my
content object).  Basically my container object does not have any
attributes (it will only have annotations) and its only purpose is to
hold my content objects, so no user input required for the container.  I
achieved this through my content object's AddView class in the update
method:

..
# create container
sample_obj = zapi.createObject(None, u"MyTestItemContainer")
self.context.__parent__['SampleContainer'] = sample_obj
# get content object
sample_item_obj = zapi.createObject(None, u"MyTestItem")
# data obtained from IMyTestItem add form using getWidgetsData
sample_item_obj.surname = data['surname']
sample_item_obj.firstName = data['firstName']
# place sample_item_obj in the container object
self.context.__parent__['SampleContainer']['SamplePerson'] =
sample_item_obj
..

Is there maybe another way of doing this?  I am concerned creating
object manually I might leave some security holes and I also understand
there are events I would manually have to trigger.

Thanks
Alen




More information about the Zope3-users mailing list