Le 16 sept. 08 à 17:16, Hans-Peter Locher a écrit :

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.

IIRC, the magic is in portal_quickinstaller that records lots of changed and created stuffs during an install. And can revert all this on uninstall.

--
Gilles Lenfant
INGENIWEB (TM) - SAS 50000 Euros - RC B 438 725 632
Bureaux de la Colline
1 rue Royal
92210 Saint Cloud - France
Phone : 01 78 15 24 00 / Fax : 01 46 02 44 04
web : www.ingeniweb.com - une société du groupe Alter Way







_______________________________________________
Product-Developers mailing list
[email protected]
http://lists.plone.org/mailman/listinfo/product-developers

Reply via email to