[Checkins] SVN: Products.GenericSetup/trunk/Products/GenericSetup/ - added an event handler that updates 'last version for profile' after a full import
Yvo Schubbe
y.2008 at wcm-solutions.de
Thu Dec 25 05:52:28 EST 2008
Log message for revision 94319:
- added an event handler that updates 'last version for profile' after a full import
Changed:
U Products.GenericSetup/trunk/Products/GenericSetup/CHANGES.txt
U Products.GenericSetup/trunk/Products/GenericSetup/configure.zcml
U Products.GenericSetup/trunk/Products/GenericSetup/events.py
-=-
Modified: Products.GenericSetup/trunk/Products/GenericSetup/CHANGES.txt
===================================================================
--- Products.GenericSetup/trunk/Products/GenericSetup/CHANGES.txt 2008-12-25 08:29:20 UTC (rev 94318)
+++ Products.GenericSetup/trunk/Products/GenericSetup/CHANGES.txt 2008-12-25 10:52:28 UTC (rev 94319)
@@ -4,6 +4,9 @@
GenericSetup 1.5.0 (unreleased)
-------------------------------
+- events: Added 'handleProfileImportedEvent' subscriber.
+ After a full import it updates 'last version for profile'.
+
- UpgradeSteps: Improved listUpgradeSteps behavior.
If versions and checker are specified for a step, the checker is used as an
additional restriction.
Modified: Products.GenericSetup/trunk/Products/GenericSetup/configure.zcml
===================================================================
--- Products.GenericSetup/trunk/Products/GenericSetup/configure.zcml 2008-12-25 08:29:20 UTC (rev 94318)
+++ Products.GenericSetup/trunk/Products/GenericSetup/configure.zcml 2008-12-25 10:52:28 UTC (rev 94319)
@@ -109,4 +109,6 @@
handler="Products.GenericSetup.components.exportComponentRegistry"
/>
+ <subscriber handler=".events.handleProfileImportedEvent"/>
+
</configure>
Modified: Products.GenericSetup/trunk/Products/GenericSetup/events.py
===================================================================
--- Products.GenericSetup/trunk/Products/GenericSetup/events.py 2008-12-25 08:29:20 UTC (rev 94318)
+++ Products.GenericSetup/trunk/Products/GenericSetup/events.py 2008-12-25 10:52:28 UTC (rev 94319)
@@ -1,18 +1,56 @@
+##############################################################################
+#
+# Copyright (c) 2007 Zope Corporation and Contributors. All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""GenericSetup events and subscribers.
+
+$Id$
+"""
+
+from zope.component import adapter
from zope.interface import implements
+
from Products.GenericSetup.interfaces import IBeforeProfileImportEvent
from Products.GenericSetup.interfaces import IProfileImportedEvent
+
class BaseProfileImportEvent(object):
+
def __init__(self, tool, profile_id, steps, full_import):
- self.tool=tool
- self.profile_id=profile_id
- self.steps=steps
- self.full_import=full_import
+ self.tool = tool
+ self.profile_id = profile_id
+ self.steps = steps
+ self.full_import = full_import
class BeforeProfileImportEvent(BaseProfileImportEvent):
+
implements(IBeforeProfileImportEvent)
class ProfileImportedEvent(BaseProfileImportEvent):
+
implements(IProfileImportedEvent)
+
+
+ at adapter(IProfileImportedEvent)
+def handleProfileImportedEvent(event):
+ """Update 'last version for profile' after a full import.
+ """
+ profile_id = event.profile_id
+ if not (profile_id and profile_id.startswith('profile-') and
+ event.tool.profileExists(profile_id) and event.full_import):
+ return
+
+ version = event.tool.getVersionForProfile(profile_id)
+ if version and version != 'unknown':
+ profile_id = profile_id[len('profile-'):]
+ event.tool.setLastVersionForProfile(profile_id, version)
More information about the Checkins
mailing list