[Checkins] SVN: Products.GenericSetup/branches/1.4/Products/GenericSetup/ Backported r94319 from trunk (events: Added 'handleProfileImportedEvent' subscriber. After a full import it updates 'last version for profile'.
Vincent Fretin
vincent.fretin at gmail.com
Sun May 24 08:26:48 EDT 2009
Log message for revision 100333:
Backported r94319 from trunk (events: Added 'handleProfileImportedEvent' subscriber. After a full import it updates 'last version for profile'.
Changed:
U Products.GenericSetup/branches/1.4/Products/GenericSetup/CHANGES.txt
U Products.GenericSetup/branches/1.4/Products/GenericSetup/configure.zcml
U Products.GenericSetup/branches/1.4/Products/GenericSetup/events.py
-=-
Modified: Products.GenericSetup/branches/1.4/Products/GenericSetup/CHANGES.txt
===================================================================
--- Products.GenericSetup/branches/1.4/Products/GenericSetup/CHANGES.txt 2009-05-24 12:20:04 UTC (rev 100332)
+++ Products.GenericSetup/branches/1.4/Products/GenericSetup/CHANGES.txt 2009-05-24 12:26:48 UTC (rev 100333)
@@ -4,9 +4,14 @@
1.4.5 (unreleased)
------------------
+- events: Added 'handleProfileImportedEvent' subscriber.
+ After a full import it updates 'last version for profile'.
+ (Backported from trunk)
+
- Added a for_=None parameter to tool.py:listProfileInfo to have the same
signature as registry.py:listProfileInfo, so profiles can be filtered by interfaces.
+
1.4.4 (2009-05-15)
------------------
@@ -18,6 +23,7 @@
- Fixed invalid XML for the "Import' tab so it doesn't break when rendered
with Chameleon.
+
1.4.3 (2009-04-22)
------------------
@@ -34,16 +40,19 @@
- Changed upgrade logic to set the current version after an upgrade to the
of the last step, instead of the current profile version.
+
1.4.2.2 (2008-09-22)
--------------------
- Packaging update: version of 1.4.2.1 said '1.4.2'.
+
1.4.2.1 (2008-09-22)
--------------------
- Packaging update: version of 1.4.2 said '1.4.2dev'.
+
1.4.2 (2008-09-22)
------------------
Modified: Products.GenericSetup/branches/1.4/Products/GenericSetup/configure.zcml
===================================================================
--- Products.GenericSetup/branches/1.4/Products/GenericSetup/configure.zcml 2009-05-24 12:20:04 UTC (rev 100332)
+++ Products.GenericSetup/branches/1.4/Products/GenericSetup/configure.zcml 2009-05-24 12:26:48 UTC (rev 100333)
@@ -109,4 +109,6 @@
handler="Products.GenericSetup.components.exportComponentRegistry"
/>
+ <subscriber handler=".events.handleProfileImportedEvent"/>
+
</configure>
Modified: Products.GenericSetup/branches/1.4/Products/GenericSetup/events.py
===================================================================
--- Products.GenericSetup/branches/1.4/Products/GenericSetup/events.py 2009-05-24 12:20:04 UTC (rev 100332)
+++ Products.GenericSetup/branches/1.4/Products/GenericSetup/events.py 2009-05-24 12:26:48 UTC (rev 100333)
@@ -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