[Checkins] SVN: zope.component/branches/tlotze-hooks/ moved IPossibleSite and ISite here from zope.location, test setSite which loosely relies on those interfaces

Thomas Lotze tl at gocept.com
Wed Oct 21 11:19:42 EDT 2009


Log message for revision 105193:
  moved IPossibleSite and ISite here from zope.location, test setSite which loosely relies on those interfaces

Changed:
  U   zope.component/branches/tlotze-hooks/CHANGES.txt
  U   zope.component/branches/tlotze-hooks/src/zope/component/hooks.txt
  U   zope.component/branches/tlotze-hooks/src/zope/component/interfaces.py

-=-
Modified: zope.component/branches/tlotze-hooks/CHANGES.txt
===================================================================
--- zope.component/branches/tlotze-hooks/CHANGES.txt	2009-10-21 15:17:59 UTC (rev 105192)
+++ zope.component/branches/tlotze-hooks/CHANGES.txt	2009-10-21 15:19:42 UTC (rev 105193)
@@ -4,6 +4,9 @@
 3.8.0 (unreleased)
 ==================
 
+- Moved the IPossibleSite and ISite interfaces here from zope.location as they
+ are dealing with zope.component's concept of a site, but not with location.
+
 - Moved the zope.site.hooks functionality to zope.component.hooks as it isn't
   actually dealing with zope.site's concept of a site.
 

Modified: zope.component/branches/tlotze-hooks/src/zope/component/hooks.txt
===================================================================
--- zope.component/branches/tlotze-hooks/src/zope/component/hooks.txt	2009-10-21 15:17:59 UTC (rev 105192)
+++ zope.component/branches/tlotze-hooks/src/zope/component/hooks.txt	2009-10-21 15:19:42 UTC (rev 105193)
@@ -21,3 +21,25 @@
 >>> from zope.component.hooks import getSiteManager
 >>> getSiteManager()
 <BaseGlobalComponents base>
+
+Let's set a site now. A site has to be an object that provides the
+``getSiteManager`` method, which is specified by
+``zope.component.interfaces.IPossibleSite``:
+
+>>> from zope.component.registry import Components
+>>> class Site(object):
+...     def __init__(self):
+...         self.registry = Components('components')
+...     def getSiteManager(self):
+...         return self.registry
+
+>>> from zope.component.hooks import setSite
+>>> site1 = Site()
+>>> setSite(site1)
+
+After this, the newly set site is considered the currently active one:
+
+>>> getSite() is site1
+True
+>>> getSiteManager() is site1.registry
+True

Modified: zope.component/branches/tlotze-hooks/src/zope/component/interfaces.py
===================================================================
--- zope.component/branches/tlotze-hooks/src/zope/component/interfaces.py	2009-10-21 15:17:59 UTC (rev 105192)
+++ zope.component/branches/tlotze-hooks/src/zope/component/interfaces.py	2009-10-21 15:19:42 UTC (rev 105193)
@@ -923,3 +923,22 @@
 class IComponents(IComponentLookup, IComponentRegistry):
     """Component registration and access
     """
+
+
+class IPossibleSite(Interface):
+    """An object that could be a site.
+    """
+
+    def setSiteManager(sitemanager):
+        """Sets the site manager for this object.
+        """
+
+    def getSiteManager():
+        """Returns the site manager contained in this object.
+
+        If there isn't a site manager, raise a component lookup.
+        """
+
+
+class ISite(IPossibleSite):
+    """Marker interface to indicate that we have a site"""



More information about the checkins mailing list