2

My package introduces registry entries. Changes by site administrator should not be overwritten on reinstall of the package.

Many ways to Rome. I chose ftw.upgrade. I like the declarative way of the upgrade step syntax. Its possible to use an upgrade directory for generic setup xml-Files like propertiestool.xml. No need to define handler python code. The upgrade works well. The admin can upgrade from control panel and in my case the new property is added. Insomma: For a new property just these have to be added: an upgrade-step declaration for source and destination version and directory where to find the properties.xml. Thumb up! –

Katja Süss
  • 759
  • 6
  • 13
  • 3
    Best practice is not to reinstall a package, but creating a upgrade step which installs only the delta (Your change on the registry). Reinstall a package is usually overrides the changes you made. – Mathias May 28 '15 at 07:21
  • Writing upgrade steps for example with ftw.upgrade is also very well documented. --> https://github.com/4teamwork/ftw.upgrade – Mathias May 28 '15 at 08:50
  • @Mathias: :D Yeah, had mentioned that in the answer below, already. – Ida May 28 '15 at 09:14
  • Offering an upgrade step promises to distract site admin from reinstalling. I'll use this. – Katja Süss May 28 '15 at 09:43
  • @KatjaSüss: If you like, tell us, if everything went well. Curious to hear about your experience with ftw.upgrade :-) – Ida Jun 05 '15 at 07:01
  • Nice, thx for sharing! – Ida Jun 05 '15 at 17:01
  • Refs: http://stackoverflow.com/questions/14244443/updating-plone-addons-on-several-sites-at-once – Ida Jun 16 '15 at 04:04

2 Answers2

3

You can pilot what to do when installing a Plone add-on by providing an Extension/install.py file with a install method inside:

def install(portal, reinstall=False):
    if not reinstall:
        setup_tool = portal.portal_setup
        setup_tool.runAllImportStepsFromProfile('profile-your.pfile:default')

This way you are driving what Plone should do when installing.

If you need it: the same if for uninstall:

def uninstall(portal, reinstall=False):
    if not reinstall:
        setup_tool = portal.portal_setup
        setup_tool.runAllImportStepsFromProfile('profile-example.gs:uninstall')

This way you can prevent the uninstall step to be run when reinstalling.

Warning: as Mathias suggested using quickinstaller -> reinstall feature is bad.

Warning: this will not probably work anymore on Plone 5 (there's open discussion about this).

keul
  • 7,673
  • 20
  • 45
  • What does 'NBB' and 'NBBB' stand for? – Ida May 28 '15 at 08:32
  • As the quest is registry-related, maybe a good moment to point out your article about it, which I enjoyed: http://blog.redturtle.it/redturtle/plone.app.registry-how-to-use-it-and-love-it (too bad though, that the containing link to djay's doc is dead. – Ida May 28 '15 at 09:16
  • Actually ment its even better follow-up: http://blog.redturtle.it/2012/09/18/plone-registry-strikes-back :) – Ida May 28 '15 at 09:28
  • 1
    @IdaEbkes thanks, I fixed NBB (that mean something only in italian). About registry article: I think this is more related to another article of mine: http://blog.keul.it/2013/05/how-to-make-your-plone-add-on-products.html :) – keul May 28 '15 at 09:44
  • Yes, wonderful, so for agile site admins the not to avoid reinstall can be made more safe. – Katja Süss May 28 '15 at 09:48
  • @keul: Thanks, that article is even betterst ;) Reads like a complete doc, actually. – Ida May 28 '15 at 10:07
2

I think what you describe is one of the problems upcoming with the increasing complexity of Plone's stack, and one of the reasons, why it is not recommended to execute a re-install anymore, but to provide a profile for each version of the Add-On, via upgrade-steps (as Mathias mentioned). That increases dev-time significantly and results in even more conflicts, of my experience. Here are the refering docs: http://docs.plone.org/develop/addons/components/genericsetup.html#add-upgrade-step

Elizabeth Leddy once wrote an Add-On to ease that pain and I can confirm it does: https://github.com/ampsport/amp.ezupgrade

And the great guys from FTW, too, I never used it, but looks promising: https://pypi.python.org/pypi/ftw.upgrade

Neither used this one, even claims to have some extra goodies, like cleanup broken OFS objects and R. Patterson's on it: https://github.com/collective/collective.upgrade

As we're here, the first good doc I could find about it ~ 1.5 years ago, comes from Uwosh, of course: http://www.uwosh.edu/ploneprojects/docs/how-tos/how-to-use-generic-setup-upgrade-steps

Another solution can be, to check, if it's an initial- or re-install, and set the properties programatically via a Python-script, conveniently called 'setuphandlers.py', like described in this answer: How to check, if my product is already installed, when installing it? That way one can still trigger re-installs without blowing it all up.

Lastly, a lot of the GS-xml-files understand the purge-property, setting it to False, will not overwrite the whole file, just your given props. This might, or not, apply to your case, you can find samples in the above referenced official doc.

Community
  • 1
  • 1
Ida
  • 3,994
  • 21
  • 40
  • Wow, thanks for this bunch of information. Upgrade steps are a nice help with their message displayed on control panel. – Katja Süss May 28 '15 at 09:46
  • it hasn't been recommended to run reinstall since I've ever worked with plone--6 years. – vangheem Jun 04 '15 at 16:21
  • @vangheem: Not recommended, true. Still depends on the concrete case and can be feasible. I liked to simply hit reinstall during dev, when changing a prop in a profile's xml-file, much faster. For curiousity: What tool do you use for them, or are you writing them manually? – Ida Jun 05 '15 at 06:58