Francois Barriere, on 2009-09-04:
> Hello,
>
> In my product I have added new lines to the diff_tool.xml file
> (under profiles/default), plus some fixes. I then registered an
> upgradeStep with the following configure.zcml snippet:
>
> <gs:upgradeStep
> title="Upgrade ATMEL.policy product"
> description="ATMEL.policy product migration/upgrade steps"
> source="*"
> destination="0.3"
> handler=".migrations.migration_to_0_3"
> sortkey="1"
> profile="ATMEL.policy:default"/>
>
> The source is "*" as there was no previous upgrade step, I have a handler that
> does various fixes using Python code and defined the profile.
>
> When upgrading the Python code is executed by the regular import steps are
> not (the changes in profles/default/diff_tool.xml) are not reflected.
> I thought the upgrade would re-run the import steps of the profile...
No. One of the goals up upgrade steps is to have a means to *avoid*
having to apply the complete profile, as that can have unwanted side
effects. Probably the best known example is the catalog.xml: if you
specify an index there, then this index will be empty after applying
the profile (or just this import step), even when it already existed.
> Am I wrong? Should I force the import step from my Python code?
> In this case, what is the use of the "profile" attibute of the
> upgradeStep?
The profile attribute marks this upgrade step as being an upgrade for
the ATMEL.policy:default profile and not for say the Products.Poi
profile.
If you want to reapply the complete profile in an upgrade step, you
can do that like this:
def applyProfile(context):
# In an upgrade step context is portal_setup
context.runAllImportStepsFromProfile(PROFILE_ID)
In you case PROFILE_ID is probably profile-ATMEL.policy:default.
To apply just one import step, do something like this; this is taken
from Products.Poi:
def run_workflow_step(context):
context.runImportStepFromProfile(PROFILE_ID, 'catalog')
# Run the update security on the workflow tool.
logger.info('Updating security settings. This may take a while...')
wf_tool = getToolByName(context, 'portal_workflow')
wf_tool.updateRoleMappings()
logger.info('Done updating security settings.')
BTW, this post of mine to the CMF mailing list with some notes about
which source and destination numbers to use may be of interest:
http://www.mail-archive.com/[email protected]/msg06107.html
Specifying source="*" like you do will always make this step available
on the Upgrades tab of portal_setup, even right after you have run
it. At least that is the case with Plone 3.0-3.3.
Plus, not shown in that post, it is conceptually better to just use
integers as the source and destination number. metadata.xml and
version.txt need not have anything in common. I would say:
- set metadata.xml on 3
- use source="2"
- use destination="3"
It may be good to play around with these numbers and see what happens
in the UI.
Cheers,
--
Maurits van Rees | http://maurits.vanrees.org/
Work | http://zestsoftware.nl/
"This is your day, don't let them take it away." [Barlow Girl]
_______________________________________________
Product-Developers mailing list
[email protected]
http://lists.plone.org/mailman/listinfo/product-developers