[Checkins] SVN: grok/trunk/src/grok/ Fix application_url tests: they were not actually testing the right

Martijn Faassen faassen at infrae.com
Thu May 3 14:27:55 EDT 2007


Log message for revision 75065:
  Fix application_url tests: they were not actually testing the right
  thing at all (browser.url instead of browser.contents), and one
  test was actually expecting the wrong result. The underlying code
  does work. :)
  
  Add the option to pass a name into the application_url(), similar to url()
  

Changed:
  U   grok/trunk/src/grok/components.py
  U   grok/trunk/src/grok/ftests/url/application.py

-=-
Modified: grok/trunk/src/grok/components.py
===================================================================
--- grok/trunk/src/grok/components.py	2007-05-03 17:59:05 UTC (rev 75064)
+++ grok/trunk/src/grok/components.py	2007-05-03 18:27:55 UTC (rev 75065)
@@ -202,11 +202,11 @@
             obj = self.context
         return util.url(self.request, obj, name)
 
-    def application_url(self):
+    def application_url(self, name=None):
         obj = self.context
         while obj:
             if isinstance(obj, Application):
-                return self.url(obj)
+                return self.url(obj, name)
             obj = obj.__parent__
         raise ValueError("No application found.")
 

Modified: grok/trunk/src/grok/ftests/url/application.py
===================================================================
--- grok/trunk/src/grok/ftests/url/application.py	2007-05-03 17:59:05 UTC (rev 75064)
+++ grok/trunk/src/grok/ftests/url/application.py	2007-05-03 18:27:55 UTC (rev 75065)
@@ -15,16 +15,23 @@
   >>> browser = Browser()
   >>> browser.handleErrors = False
   >>> browser.open('http://localhost/cave')
-  >>> browser.url
+  >>> browser.contents
   'http://localhost/cave'
-
+  
 Asking for the application_url on the caveman returns the URL to the cave as
 well::
 
   >>> browser.open('http://localhost/cave/caveman')
-  >>> browser.url
-  'http://localhost/cave/caveman'
+  >>> browser.contents
+  'http://localhost/cave'
 
+You can pass a name to specify a particular view or sub object to add
+to the URL::
+
+  >>> browser.open('http://localhost/cave/caveman/second')
+  >>> browser.contents
+  'http://localhost/cave/second'
+  
 """
 import zope.interface
 
@@ -37,7 +44,12 @@
     def render(self):
         return self.application_url()
 
+class Second(grok.View):
+    grok.context(zope.interface.Interface)
 
+    def render(self):
+        return self.application_url('second')
+    
 class Cave(grok.Application, grok.Container):
     pass
 



More information about the Checkins mailing list