[Zope-dev] Re: Bug in AbsoluteURL Adapter
Philipp von Weitershausen
philipp at weitershausen.de
Tue Nov 27 14:48:08 EST 2007
Sebastian Wehrmann wrote:
> while using the AbsoluteURL Adapter in a view,
By the way, you're using Five's AbsoluteURL adapter. (It's different
from the one in Zope 3). Also, the patch below seems to be for Five.
Would be good to mention that :).
> 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?
Can you round up a test that demonstrates how the current implementation
fails to cover your case and how your suggestion change fixes that?
More information about the Zope-Dev
mailing list