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

_______________________________________________
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope )

Reply via email to