[ZCM] [ZC] 797/ 3 Comment "absolute_url not callable by URL"

Collector: Zope Bugs, Features, and Patches ... zope-coders-admin@zope.org
Sun, 16 Feb 2003 11:25:24 -0500


Issue #797 Update (Comment) "absolute_url not callable by URL"
 Status Pending, Zope/feature+solution low
To followup, visit:
  http://collector.zope.org/Zope/797

==============================================================
= Comment - Entry #3 by tseaver on Feb 16, 2003 11:25 am

> = Comment - Entry #2 by shh on Feb 15, 2003 8:31 am
> 
> Hm, would you want to allow the 'relative' parameter to be url-callable?
>   I could simply go to http://your.zope.host/portal/absolute_url?relative=1
>   and spy on your virtual hosting setup...

Actually, the 'relative' parameter to the method won't let you
get "above" the virtual root::

        if relative:
            # This is useful for physical path relative to a VirtualRoot
            return '/'.join(path)
        return '/'.join([req['SERVER_URL']] + req._script + path)


> How about:
> 
>   def absoluteUrl(self):
>       """Web-callable absolute_url."""
>       return self.absolute_url()

That would work fine.
________________________________________
= Comment - Entry #2 by shh on Feb 15, 2003 8:31 am

Hm, would you want to allow the 'relative' parameter to be url-callable? I could simply go to http://your.zope.host/portal/absolute_url?relative=1 and spy on your virtual hosting setup...

How about:

  def absoluteUrl(self):
      """Web-callable absolute_url."""
      return self.absolute_url()


________________________________________
= Request - Entry #1 by slinkp on Feb 5, 2003 6:48 pm

absolute_url has no docstring and thus may not be called just by visiting http://zope:8080/foo/absolute_url.

Several points:

* It is often desirable during developement - "where is this thing really? let me check real quick."

* Other zope API methods of similar utility
(e.g. Image.tag) are callable by URL. So this is inconsistent.

* App.absolute_url IS callable by URL. So it's REALLY inconsistent :)

* Why not?

Following is a context diff that adds a docstring.
Apply this to lib/python/OFS/Traversable.py


*** Traversable.py      Wed Feb  5 18:27:31 2003
--- Traversable1.py     Wed Feb  5 18:35:41 2003
***************
*** 29,34 ****
--- 29,40 ----
  
      absolute_url__roles__=None # Public
      def absolute_url(self, relative=0):
+         """Return an absolute URL to the object,
+         based on the physical containment path.
+         If the optional relative argument is true,
+         return the physical path from the (possibly
+         virtual) root."""
+ 
          try:
              req = self.REQUEST
          except AttributeError:


==============================================================