[Product-Developers] Content creation during install

Hans-Peter Locher hans-peter.locher at inquant.de
Mon Apr 20 07:20:41 UTC 2009


I prefer creating and manipulating
the content entirely in the setuphandler.

You have to be careful, normally, the created conted will be removed  
on uninstall/ reinstall

loosing all changes done to the content since initial installation.

to prohibit this,
you can use

a beforeUninstall hook

inside an Extensions/Install.py

like:


def beforeUninstall(self, reinstall=False, product=None, cascade=[]):
     """ Prevent created content from being deleted on uninstall
     """
     if 'portalobjects' in cascade:
         cascade.remove('portalobjects')

     return True, cascade


Best regards

Hans-Peter


Am 17.04.2009 um 15:01 schrieb Dave Turvene:

> My question: what is the current thinking on programmatic content
> creation during product install?
>
> First let me say I'm a great fan of Aspeli's repeatable site creation.
> Anything I can do in code and configuration once is better than
> re-doing it over and over through the ZMI.
>
> I'm developing a base site framework for testing.  The framework is
> simple, and to my liking so that I don't have to go into the ZMI and
> change workflows, user options, etc.  I create a couple users with
> different privileges and populate the site with some content.
> That's the rub.
>
> For example, I want a new front-page.  The current logic seems to be:
>
> * Add a new-front-page object using
> CMFCore.exportimport.content.importSiteStructure
>
> * Modify the properties/state of new-front-page using a setuphandler
>
> As I see it, a site/product creates content using one mechanism and
> then massages it using another.
>
> There is also a GenericSetup/doc/SampleSite package that appears to
> create new entities.  But I couldn't get it to work.  All it seems to
> do is call Products.GenericSetup.utils.importObjects to build
> new XML structure, but nothing else seems to happen.
>
> It looks like importSiteStructure is the mechanism to use and  
> SampleSite
> is deprecated.  I most definitely could be wrong.
>
> Soapbox: it seems to me a little awkward to use XML files everywhere  
> and
> then CSV for content creation.  Why does
> CMFCore.exportimport.content.importSiteStructure
> use a CSV format instead of XML?
>
> One idea is to call desired factories in my setuphandler and modify
> the instances all in one place.
>
> Dave
>
>
> _______________________________________________
> Product-Developers mailing list
> Product-Developers at lists.plone.org
> http://lists.plone.org/mailman/listinfo/product-developers
>






More information about the Product-Developers mailing list