[z3-five] Bug in AbsoluteURL Adapter

Sebastian Wehrmann sw at gocept.com
Tue Nov 27 10:49:35 CET 2007


Hi there,

while using the AbsoluteURL Adapter in a view, it only returns the path 
of the object, not the URL. This is because the object does not have a 
request and therefore the method absolute_url() used by the adapter 
cannot call the physicalPathToURL() method.

Because we always have the request object in this adapter we can call 
the physicalPathToURL() method directly and convert the physical path of 
the object and return it.

Here is a diff with the fix:

Index: browser/absoluteurl.py
===================================================================
--- browser/absoluteurl.py      (Revision 81990)
+++ browser/absoluteurl.py      (Arbeitskopie)
@@ -35,8 +35,8 @@
         self.context, self.request = context, request
 
     def __str__(self):
-        context = aq_inner(self.context)
-        return context.absolute_url()
+        path = self.context.getPhysicalPath()
+        return self.request.physicalPathToURL(path)
 
     __call__ = __str__
 

Any comments?

-- 
Sebastian Wehrmann

gocept gmbh & co. kg · forsterstrasse 29 · 06112 halle/saale · germany
www.gocept.com · work. +49 345 122988912 · fax. +49 345 12298891



More information about the z3-five mailing list