[Checkins] SVN: grok/trunk/src/grok/ Fix an application_url bug: it didn't work with empty containers, which

Martijn Faassen faassen at infrae.com
Thu May 3 14:40:18 EDT 2007


Log message for revision 75067:
  Fix an application_url bug: it didn't work with empty containers, which
  evaluate to False. Instead of explicitly comparing to None, application_url
  was checking whether the object evaluated to True, which only works for
  containers which actually have some content.
  

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 18:35:20 UTC (rev 75066)
+++ grok/trunk/src/grok/components.py	2007-05-03 18:40:17 UTC (rev 75067)
@@ -204,7 +204,7 @@
 
     def application_url(self, name=None):
         obj = self.context
-        while obj:
+        while obj is not None:
             if isinstance(obj, Application):
                 return self.url(obj, name)
             obj = obj.__parent__

Modified: grok/trunk/src/grok/ftests/url/application.py
===================================================================
--- grok/trunk/src/grok/ftests/url/application.py	2007-05-03 18:35:20 UTC (rev 75066)
+++ grok/trunk/src/grok/ftests/url/application.py	2007-05-03 18:40:17 UTC (rev 75067)
@@ -31,6 +31,14 @@
   >>> browser.open('http://localhost/cave/caveman/second')
   >>> browser.contents
   'http://localhost/cave/second'
+
+application_url also works with empty containers::
+
+  >>> from grok.ftests.url.application import Corridors
+  >>> cave['corridors'] = Corridors()
+  >>> browser.open('http://localhost/cave/corridors')
+  >>> browser.contents
+  'http://localhost/cave'
   
 """
 import zope.interface
@@ -56,3 +64,6 @@
 
 class CaveMan(grok.Model):
     pass
+
+class Corridors(grok.Container):
+    pass



More information about the Checkins mailing list