[Zope3-checkins] SVN: Zope3/trunk/src/zope/publisher/ Add annotations to base request, following standard package-name key

Gary Poster gary at zope.com
Mon Apr 25 17:37:46 EDT 2005


Log message for revision 30177:
  Add annotations to base request, following standard package-name key 
  conventions.
  
  

Changed:
  U   Zope3/trunk/src/zope/publisher/base.py
  U   Zope3/trunk/src/zope/publisher/interfaces/__init__.py
  U   Zope3/trunk/src/zope/publisher/tests/test_baserequest.py

-=-
Modified: Zope3/trunk/src/zope/publisher/base.py
===================================================================
--- Zope3/trunk/src/zope/publisher/base.py	2005-04-25 21:23:43 UTC (rev 30176)
+++ Zope3/trunk/src/zope/publisher/base.py	2005-04-25 21:37:46 UTC (rev 30177)
@@ -192,6 +192,7 @@
         '_principal',        # request principal, set by publication
         'interaction',       # interaction, set by interaction
         'debug',             # debug flags
+        'annotations',       # per-package annotations
         )
 
     environment = RequestDataProperty(RequestEnvironment)
@@ -215,6 +216,7 @@
         self._principal = None
         self.debug = DebugFlags()
         self.interaction = None
+        self.annotations = {}
 
     def setPrincipal(self, principal):
         self._principal = principal

Modified: Zope3/trunk/src/zope/publisher/interfaces/__init__.py
===================================================================
--- Zope3/trunk/src/zope/publisher/interfaces/__init__.py	2005-04-25 21:23:43 UTC (rev 30176)
+++ Zope3/trunk/src/zope/publisher/interfaces/__init__.py	2005-04-25 21:37:46 UTC (rev 30177)
@@ -436,7 +436,21 @@
         This is a read-only mapping from variable name to value.
         """)
 
+    annotations = Attribute(
+        """Stores arbitrary application data under package-unique keys.
 
+        By "package-unique keys", we mean keys that are are unique by
+        virtue of including the dotted name of a package as a prefex.  A
+        package name is used to limit the authority for picking names for
+        a package to the people using that package.
+    
+        For example, when implementing annotations for hypothetical
+        request-persistent adapters in a hypothetical zope.persistentadapter
+        package, the key would be (or at least begin with) the following::
+    
+          "zope.persistentadapter"
+        """)
+
 class IResponse(IPublisherResponse, IApplicationResponse):
     """The basic response contract
     """

Modified: Zope3/trunk/src/zope/publisher/tests/test_baserequest.py
===================================================================
--- Zope3/trunk/src/zope/publisher/tests/test_baserequest.py	2005-04-25 21:23:43 UTC (rev 30176)
+++ Zope3/trunk/src/zope/publisher/tests/test_baserequest.py	2005-04-25 21:37:46 UTC (rev 30177)
@@ -74,6 +74,8 @@
     def test_IPublisherRequest_processInputs(self):
         self._Test__new().processInputs()
 
+    def test_AnnotationsExist(self):
+        self.assertEqual(self._Test__new().annotations, {})
 
     # Needed by BaseTestIEnumerableMapping tests:
     def _IEnumerableMapping__stateDict(self):



More information about the Zope3-Checkins mailing list