Questions regarding GS upgradeStep

4 messages Options
Embed this post
Permalink
Francois Barriere () Questions regarding GS upgradeStep
Reply Threaded More More options
Print post
Permalink
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...

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?

Francois.

--
   Francois BARRIERE                          ATMEL
                                              Zone Industrielle
   Tel: (33) 0 442 53 61 98                   13106 ROUSSET
E-Mail: [hidden email]           FRANCE
                 ---------------------------------
Everyone knows that debugging is twice as hard as writing a program
in the first place. So if you're as clever as you can be when you write it,
how will you ever debug it? (Brian Kernighan)
                 ---------------------------------

_______________________________________________
Product-Developers mailing list
[hidden email]
http://lists.plone.org/mailman/listinfo/product-developers
Maurits van Rees-3 () Re: Questions regarding GS upgradeStep
Reply Threaded More More options
Print post
Permalink
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/zope-cmf@.../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
[hidden email]
http://lists.plone.org/mailman/listinfo/product-developers
Francois Barriere () Re: Re: Questions regarding GS upgradeStep
Reply Threaded More More options
Print post
Permalink
On Sat, 5 Sep 2009 10:48:16 +0000 (UTC)
Maurits van Rees <[hidden email]> wrote:

> Francois Barriere, on 2009-09-04:
> > Hello,
> > [...]
> > 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.
>

   OK, I understand.

> > 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)

   This is what I have finally coded (almost, as I just need a single
   step, in my case).

> 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/zope-cmf@.../msg06107.html
>

   Thanks. It contains usefull informations.

> 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.
>

   The old version was "unknown" so I used "*" to make sure it matches,
but after a test using "unknown" works too. I will test it against a
numbered version to make sure it is only triggered to migrate from
"unknown" to "0.3" (or make sure running twice the migration steps has
no side effect).

Francois.

--
   Francois BARRIERE                          ATMEL
                                              Zone Industrielle
   Tel: (33) 0 442 53 61 98                   13106 ROUSSET
E-Mail: [hidden email]           FRANCE
                 ---------------------------------
Everyone knows that debugging is twice as hard as writing a program
in the first place. So if you're as clever as you can be when you write it,
how will you ever debug it? (Brian Kernighan)
                 ---------------------------------

_______________________________________________
Product-Developers mailing list
[hidden email]
http://lists.plone.org/mailman/listinfo/product-developers
Maurits van Rees-3 () Re: Questions regarding GS upgradeStep
Reply Threaded More More options
Print post
Permalink
Francois Barriere, on 2009-09-07:
> (or make sure running twice the migration steps has
> no side effect).

Unfortunately I don't think everybody does this, but this is indeed
always an excellent idea.

--
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
[hidden email]
http://lists.plone.org/mailman/listinfo/product-developers