[Product-Developers] creating content inside a setup handler.
Hans-Peter Locher
hans-peter.locher at inquant.de
Tue Sep 16 15:16:53 UTC 2008
Hi,
I'm working on a policy product which creates some content during
installation.
I have a custom folderish content type "Queue" which I want to add
some instances of.
The code check if there is already an object with the id, and only
creates if that isn't the case.
I was happy having my unit tests pass, unti I've started my Plone
site and manually installed/ uninstalled the policy product.
It happens that on installation content gets created as desired.
But on uninstall, the objects get deleted (wtf)
The code looks as follows:
<snip>
def create_content(portal):
""" Creates queues and sets them to state active """
logger.info("********** create content")
wf = getToolByName(portal, 'portal_workflow')
for item in CONTENT:
if item['id'] in portal.objectIds():
logger.info("Object %s already created , pass" %
item['id'])
else:
portal.invokeFactory('Queue',
item['id'],
title=item['title'],
description=item['description'])
queue = getattr(portal, item['id'])
wf.doActionFor(queue, 'activate')
logger.info("%s created" % item['id'])
<snip>
Is this some new functionality that setuphandlers get a magic reverse
or am I missing something?
Thanks for any hints.
--
mr_savage
Hans-Peter Locher
InQuant GmbH
http://www.inquant.de
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.plone.org/pipermail/plone-product-developers/attachments/20080916/e14ab554/attachment-0001.html>
More information about the Product-Developers
mailing list