Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to define a procedure to upgrade an add-on?

Tags:

plone

When I change the profile version for an add-on that I wrote I always get the message above.

This add-on has been upgraded. Old profile version was 10. New profile version is 11. There is no upgrade procedure defined for this add-on. Please consult the add-on documentation for upgrade information, or contact the add-on author.

So how I can define a procedure to upgrade an add-one?

like image 419
Daniel Hernández Avatar asked Mar 09 '13 22:03

Daniel Hernández


1 Answers

in your configure.zcml (or preferably in a separated upgrades.zcml included in configure.zcml), you need to declare your upgrade step like that:

  <genericsetup:upgradeStep
  source="22"
  destination="23"
  title="Remove such js from registry"
  description=""
  profile="Products.MyProduct:default"
  handler=".upgrades.upgrade_22_to_23"
  />

and you need a upgrades.py file to implement the upgrade step (just an example):

from Products.CMFCore.utils import getToolByName

def upgrade_22_to_23(context):
    js_id = '++resource++blabla/blibli.js'
    jsregistry = getToolByName(context, 'portal_javascripts')
    jsregistry.unregisterResource(js_id)

Note: in zcml, source might be set to '*' if you want the step to apply from any previous profile version to the one you target.

like image 84
ebrehault Avatar answered Sep 28 '22 04:09

ebrehault