[silva-dev] Upgrading extensions
Samuel Schluep
schluep at iha.bepr.ethz.ch
Mon May 24 16:28:39 CEST 2004
Dear Clemens
Thank you for your answer
> > My proposition to fix this bug: Change line 114 of Silva/upgrade.py from:
> >
> > self.upgradeObject(o, version)
> >
> > to
> >
> > o = self.upgradeObject(o, version)
>
> I feel this is very consistent with the usual handling of "upgrader
>returns upgraded object". The problem seemed not show up so far because
>by accident. (When replacing the old Silva.Document by the new
>SilvaDocument.Document and upgrading the versions within this did not matter,
>as the old object and the new object contained the same objects ... I
>really need some while to figure out why that worked at all.)
>
>
Maybe this should be put on the issues list.
> [...]
> >
> > There is another problem, with the refresh of the dLCMS extension
> > product during the upgrade. The install depends on SilvaDocument already
> > being installed. But the upgrading mechanism will call the dLCMS install
> > first, which results in an error. Can the installation order be
> > determined somehow (for example through the depends_on='SilvaDocument'
> > parameter of extensionRegistry.register in __init__)?
> >
>
> Hm, sounds tricky, though the use case is very reasonable. Currently
>upgraders are simply executed in the order they are registered, which
>depends on the order their modules are imported at startup.
>
> Maybe upgraders should have a "depends" attribute or so?
>
> As a first attempt to fix it, does the problem go away if You add
>something like:
>
>from Products.SilvaDocument import upgrade
>
>to your upgrade.py?
>
>
This does not help. The Silva UpgraderRegistry has too much Python magic
for me too comprehend its function (leading double underscores,
setdefault function)... Now I found out: in Silva.upgrade_093,
RefreshAll will first refresh all extensions and then install SilvaDocument:
def upgrade(self, root):
zLOG.LOG('Silva', zLOG.INFO, 'refresh all installed products')
root.service_extensions.refresh_all()
zLOG.LOG('Silva', zLOG.INFO, 'install SilvaDocument')
root.service_extensions.install('SilvaDocument')
return root
Maybe the core Silva should not refresh all extensions automatically,
but only the core and SilvaDocument. Then it would let the Extensions
refresh themselves in their own upgrade script.
>I had similar problems in some upgraders ... the solution I found is to
>first check if the object exist before delete them, e.g. like:
>
> if hasattr(root,'service_display_widgets'):
> root.manage_delObjects('service_display_widgets')
>
> As "hasattr" may swallow ConflictError's and thus is considered harmful
>in principle, the clean way would be something like:
>
> if getattr( aq_base(root), 'service_display_widgets', None):
> root.manage_delObjects('service_display_widgets')
>
>no silver bullet, but works for me.
>
>
This works for me too.
Cheers
Sam
More information about the silva-dev
mailing list