[Zope3-Users] How to create/remove content objects in Application
Code
Frank Burkhardt
fbo2 at gmx.net
Thu Mar 2 05:56:58 EST 2006
Hi,
On Thu, Mar 02, 2006 at 09:03:25AM +0000, Reinhold Strobl wrote:
> Hi,
>
> i am searching for a possibility to create and remove content objects in Python
> Code.
> Thanks for replies,
user at host > bin/zopectl debug # creating folder...
>>> root=debugger.root()
>>> from zope.app.folder.folder import Folder
>>> root['mytestfolder']=Folder()
>>> import transaction
>>> transaction.commit()
>>> ^D
user at host > bin/zopectl debug # removing folder...
>>> root=debugger.root()
>>> from zope.app.folder.folder import Folder
>>> root.__delitem__('mytestfolder')
>>> import transaction
>>> transaction.commit()
This is how to do it from a shell. Just use self.context['folder']=Folder()
if you are e.g. in a view.
Regards,
Frank
More information about the Zope3-users
mailing list