[Checkins] SVN: zc.extjs/branches/dev/src/zc/extjs/application. Fixed a bug in zc.extjs.application.AttributeTraversable.

Gintautas Miliauskas gintas at pov.lt
Mon Mar 31 18:26:44 EDT 2008


Log message for revision 85046:
  Fixed a bug in zc.extjs.application.AttributeTraversable.
  
  Provided interfaces were removed from the request, breaking skins and other
  things.
  

Changed:
  U   zc.extjs/branches/dev/src/zc/extjs/application.py
  U   zc.extjs/branches/dev/src/zc/extjs/application.txt

-=-
Modified: zc.extjs/branches/dev/src/zc/extjs/application.py
===================================================================
--- zc.extjs/branches/dev/src/zc/extjs/application.py	2008-03-31 21:11:30 UTC (rev 85045)
+++ zc.extjs/branches/dev/src/zc/extjs/application.py	2008-03-31 22:26:44 UTC (rev 85046)
@@ -91,7 +91,7 @@
             zope.interface.directlyProvides(
                 request,
                 zc.extjs.interfaces.IAjaxRequest,
-                zope.interface.directlyProvidedBy(object),
+                zope.interface.directlyProvidedBy(request),
                 )
             return result
         raise zope.publisher.interfaces.NotFound(self, name, request)    

Modified: zc.extjs/branches/dev/src/zc/extjs/application.txt
===================================================================
--- zc.extjs/branches/dev/src/zc/extjs/application.txt	2008-03-31 21:11:30 UTC (rev 85045)
+++ zc.extjs/branches/dev/src/zc/extjs/application.txt	2008-03-31 22:26:44 UTC (rev 85046)
@@ -311,7 +311,8 @@
 SubApplication
     This class, which Application subclasses, provides traversal to
     attributes that provide IBrowserPublisher.  It also stamps
-    IAjaxRequest on the request object when an object is traversed.
+    IAjaxRequest on the request object when an object is traversed
+    [#iajaxrequest]_ .
 
     (Maybe this request stamping should be done further down the
     traversal chain or perhaps only done if X-Requested-With is
@@ -454,3 +455,36 @@
    so as not to dilute the content.
 
 .. [#forms] See form.txt.
+
+.. [#iajaxrequest] Traversing into a subapplication adds IAjaxRequest to the
+   list of interfaces provided by the request.
+
+    >>> import zc.extjs.application
+    >>> import zc.extjs.interfaces
+    >>> import zope.publisher.browser
+    >>> request = zope.publisher.browser.TestRequest()
+    >>> class SubApp(zc.extjs.application.SubApplication):
+    ...      @zc.extjs.application.jsonpage
+    ...      def foo(self):
+    ...          return 'bar'
+    >>> subapp = SubApp(object(), request)
+
+  Now let's try traversing into the subapplication:
+
+    >>> zc.extjs.interfaces.IAjaxRequest.providedBy(request)
+    False
+    >>> subapp.publishTraverse(request, 'foo')()
+    '"bar"'
+    >>> zc.extjs.interfaces.IAjaxRequest.providedBy(request)
+    True
+
+  Note that the request keeps any provided interfaces:
+
+    >>> request = zope.publisher.browser.TestRequest()
+    >>> class IMyInterface(zope.interface.Interface):
+    ...     pass
+    >>> zope.interface.directlyProvides(request, IMyInterface)
+    >>> subapp.publishTraverse(request, 'foo')()
+    '"bar"'
+    >>> IMyInterface.providedBy(request)
+    True



More information about the Checkins mailing list