[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/component/ Added a
new event generated when a local site is created.
Jim Fulton
jim at zope.com
Fri Feb 18 15:00:24 EST 2005
Log message for revision 29210:
Added a new event generated when a local site is created.
Changed:
U Zope3/trunk/src/zope/app/component/interfaces/__init__.py
U Zope3/trunk/src/zope/app/component/site.py
U Zope3/trunk/src/zope/app/component/site.txt
-=-
Modified: Zope3/trunk/src/zope/app/component/interfaces/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/component/interfaces/__init__.py 2005-02-18 17:00:36 UTC (rev 29209)
+++ Zope3/trunk/src/zope/app/component/interfaces/__init__.py 2005-02-18 20:00:24 UTC (rev 29210)
@@ -64,6 +64,17 @@
the global site manager which contains file based utilities and adapters.
"""
+class INewLocalSite(zope.interface.Interface):
+
+ manager = zope.interface.Attribute("The new site manager")
+
+class NewLocalSite:
+ zope.interface.implements(INewLocalSite)
+
+ def __init__(self, manager):
+ self.manager = manager
+
+
class ISiteManagementFolder(registration.IRegisterableContainer,
IContainer):
"""Component and component registration containers."""
Modified: Zope3/trunk/src/zope/app/component/site.py
===================================================================
--- Zope3/trunk/src/zope/app/component/site.py 2005-02-18 17:00:36 UTC (rev 29209)
+++ Zope3/trunk/src/zope/app/component/site.py 2005-02-18 20:00:24 UTC (rev 29210)
@@ -92,6 +92,7 @@
self, interfaces.ISite,
zope.interface.directlyProvidedBy(self))
+ zope.event.notify(interfaces.NewLocalSite(sm))
def _findNextSiteManager(site):
while True:
Modified: Zope3/trunk/src/zope/app/component/site.txt
===================================================================
--- Zope3/trunk/src/zope/app/component/site.txt 2005-02-18 17:00:36 UTC (rev 29209)
+++ Zope3/trunk/src/zope/app/component/site.txt 2005-02-18 20:00:24 UTC (rev 29210)
@@ -50,6 +50,14 @@
>>> myfolder.getSiteManager() is sm
True
+Note that an event is generated when a local site manager is created:
+
+ >>> from zope.app.event.tests.placelesssetup import getEvents
+ >>> from zope.app.component.interfaces import INewLocalSite
+ >>> [event] = getEvents(INewLocalSite)
+ >>> event.manager is sm
+ True
+
If one tries to set a bogus site manager, a `ValueError` will be raised:
>>> myfolder2 = folder.Folder()
More information about the Zope3-Checkins
mailing list