Skip to content. | Skip to navigation

Personal tools

Navigation

You are here: Home / Anderson Leeb Blog / Create objects in the Plone debugger

Create objects in the Plone debugger

Plone 4

(11/19/2012) Note: David Glick was kind enough to point out that there is now a much easier way of handling this, in the plone.recipe.zope2instance. See the examples on pypi.

Plone 3

Initialization code required before trying to create an object in the debugger:

from Testing import makerequest
root = makerequest.makerequest(app)
site = root.Plone

admin = root.acl_users.getUserById('admin')
admin = admin.__of__(site.acl_users)

from AccessControl.SecurityManagement import newSecurityManager
newSecurityManager(None, admin)

from zope.site.hooks import setHooks
from zope.site.hooks import setSite
setHooks()
setSite(site)
site.setupCurrentSkin(site.REQUEST)

After that you should be able to create content, or update a member's properties

site.invokeFactory('Folder', 'test')
folder = site.test
folder.processForm()
Twitter