[Checkins] SVN: zope.publisher/trunk/ - make the apply skin pattern not a hard coded part of IBrowserRequest

Roger Ineichen roger at projekt01.ch
Sat Feb 28 23:07:37 EST 2009


Log message for revision 97389:
  - make the apply skin pattern not a hard coded part of IBrowserRequest
    since other IHTTPRequest based implementation could use the skin
    pattern too. e.g JSON-RPC
  - added tests
  - fix broken paste.txt test output (on windows)
  
  Note:
  JSON-RPC doesn't provide IBrowserRequest because it can not handle
  file upload which is a part of IBrowserRequest 

Changed:
  U   zope.publisher/trunk/CHANGES.txt
  U   zope.publisher/trunk/src/zope/publisher/interfaces/browser.py
  U   zope.publisher/trunk/src/zope/publisher/paste.txt
  U   zope.publisher/trunk/src/zope/publisher/tests/test_browserrequest.py
  U   zope.publisher/trunk/src/zope/publisher/tests/test_paste.py

-=-
Modified: zope.publisher/trunk/CHANGES.txt
===================================================================
--- zope.publisher/trunk/CHANGES.txt	2009-02-28 22:37:48 UTC (rev 97388)
+++ zope.publisher/trunk/CHANGES.txt	2009-03-01 04:07:36 UTC (rev 97389)
@@ -1,6 +1,13 @@
 CHANGES
 =======
 
+3.5.7dev (unreleased)
+---------------------
+
+- Feature: added ISkinable which allows us to implement the apply skin pattern
+  not only for IBrowserRequest
+
+
 3.5.6 (2009-02-14)
 ------------------
 

Modified: zope.publisher/trunk/src/zope/publisher/interfaces/browser.py
===================================================================
--- zope.publisher/trunk/src/zope/publisher/interfaces/browser.py	2009-02-28 22:37:48 UTC (rev 97388)
+++ zope.publisher/trunk/src/zope/publisher/interfaces/browser.py	2009-03-01 04:07:36 UTC (rev 97389)
@@ -74,7 +74,29 @@
         """
 
 
-class IBrowserRequest(IHTTPRequest):
+class ISkinable(Interface):
+    """A skinable (request) can apply a skin.
+    
+    The implementation in BrowserRequest will apply a default skin/layer called
+    ``IDefaultBrowserLayer`` if not default skin get registered.
+    """
+
+
+class IDefaultSkin(Interface):
+    """Any component providing this interface must be a skin.
+
+    This is a marker interface, so that we can register the default skin as an
+    adapter from the presentation type to `IDefaultSkin`.
+    """
+
+
+class ISkinChangedEvent(Interface):
+    """Event that gets triggered when the skin of a request is changed."""
+
+    request = Attribute("The request for which the skin was changed.")
+
+
+class IBrowserRequest(IHTTPRequest, ISkinable):
     """Browser-specific Request functionality.
 
     Note that the browser is special in many ways, since it exposes
@@ -138,15 +160,3 @@
                             'The old alias will go away in Zope 3.5.')
 #
 ##############################################################################
-
-class IDefaultSkin(Interface):
-    """Any component providing this interface must be a skin.
-
-    This is a marker interface, so that we can register the default skin as an
-    adapter from the presentation type to `IDefaultSkin`.
-    """
-
-class ISkinChangedEvent(Interface):
-    """Event that gets triggered when the skin of a request is changed."""
-
-    request = Attribute("The request for which the skin was changed.")

Modified: zope.publisher/trunk/src/zope/publisher/paste.txt
===================================================================
--- zope.publisher/trunk/src/zope/publisher/paste.txt	2009-02-28 22:37:48 UTC (rev 97388)
+++ zope.publisher/trunk/src/zope/publisher/paste.txt	2009-03-01 04:07:36 UTC (rev 97389)
@@ -61,8 +61,7 @@
     ...        'REQUEST_METHOD': 'GET', 'wsgi.input':  cStringIO.StringIO('')}
 
     >>> for data in app(env, start_response):
-    ...     print data,
-    ... # doctest: +NORMALIZE_WHITESPACE
+    ...     print data
     200 Ok
     <html><body>Thanks for your request:<br />
     <h1>BrowserRequest</h1>
@@ -71,7 +70,7 @@
     PATH_INFO:	/a/b
     QUERY_STRING:	
     REQUEST_METHOD:	GET
-    wsgi.input:	<cStringIO.StringI object at 0xb7470a40>
+    wsgi.input:	<cStringIO.StringI object at ...>
     </pre>
     <h1>Publication arguments:</h1>
     Globals: {'global_option': 42}<br />

Modified: zope.publisher/trunk/src/zope/publisher/tests/test_browserrequest.py
===================================================================
--- zope.publisher/trunk/src/zope/publisher/tests/test_browserrequest.py	2009-02-28 22:37:48 UTC (rev 97388)
+++ zope.publisher/trunk/src/zope/publisher/tests/test_browserrequest.py	2009-03-01 04:07:36 UTC (rev 97389)
@@ -28,6 +28,7 @@
 from zope.publisher.interfaces.browser import IBrowserApplicationRequest
 from zope.publisher.interfaces.browser import IBrowserRequest
 from zope.publisher.interfaces.browser import IBrowserPublication
+from zope.publisher.interfaces.browser import ISkinable
 
 from zope.publisher.tests.test_http import HTTPTests
 from zope.publisher.tests.publication import TestPublication
@@ -454,6 +455,7 @@
         request = self._createRequest()
         verifyObject(IBrowserRequest, request)
         verifyObject(IBrowserApplicationRequest, request)
+        verifyObject(ISkinable, request)
 
     def testIssue394(self):
         extra = {'PATH_INFO': '/folder/item3/'}
@@ -561,6 +563,16 @@
         self.assertEqual(request.traverse(app).name, 'Engineering')
         self.assertEqual(request._last_obj_traversed, app.ZopeCorp.Engineering)
 
+    def test_IBrowserRequest(self):
+        verifyObject(IBrowserRequest, self._Test__new())
+
+    def test_ISkinable(self):
+        self.assertEqual(ISkinable.providedBy(self._Test__new()), True)
+
+    def testVerifyISkinable(self):
+        verifyObject(ISkinable, self._Test__new())
+
+
 def test_suite():
     suite = unittest.TestSuite()
     suite.addTest(unittest.makeSuite(BrowserTests))

Modified: zope.publisher/trunk/src/zope/publisher/tests/test_paste.py
===================================================================
--- zope.publisher/trunk/src/zope/publisher/tests/test_paste.py	2009-02-28 22:37:48 UTC (rev 97388)
+++ zope.publisher/trunk/src/zope/publisher/tests/test_paste.py	2009-03-01 04:07:36 UTC (rev 97389)
@@ -59,9 +59,7 @@
     return unittest.TestSuite((
         doctest.DocFileSuite(
             '../paste.txt',
-            checker = renormalizing.RENormalizing([
-                (re.compile('at 0x[0-9a-f]+'), 'at <SOME ADDRESS>'),
-                ]),
+            optionflags=doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE,
             ),
         ))
 



More information about the Checkins mailing list