[Zope-dev] Zope 2.7.0 b3 regressions

Lennart Regebro regebro at nuxeo.com
Wed Dec 3 08:42:59 EST 2003


From: "Yuppie" <schubbe at web.de>
> 1.) absolute_url(relative=1) behaves different
> ----------------------------------------------
>
> 'relative' was changed from 'relative to site object' to 'relative to
> server root'. This is an API change and breaks Products like CMF.
>
> See <http://zope.org/Collectors/Zope/809>
>
> I propose to revert this change.

+1.

I added a comment to the Issue, and are copying it here FYI:

There is no reason to change absolute_url. If you use CMF, there is the
portal_url tool, which could need some enhancing, btw, and if not, you need
to make your own set of methods. Methods you sooner or later will need are
(the exact naming is optional):

virtualRootPath(ob): Returns the path to the virtual root. For example: ('',
'mysite.com')

physicalPath(ob): Returns the full path to the object. For example: ('',
'mysite.com', 'path', 'to', 'object')
//Note: This already exists as obj.getPhysicalPath()...

virtalPath(ob): Returns the path from the virtual root. For example: ('',
'path', 'to', 'object') (Note that it starts with a '')

path2url(path): For the above paths returns '/mysite.com',
'/mysite.com/path/to/object' and '/path/to/object' respectively.

After you have these, you can forget about absolute_url. :)

I have yet encountered a specific need to return
'http://www.mysite.com/<anything>' because the browser will typically add
that automatically anyway when you return '/<anything>'.

These methods SHOULD really be a part of the VirtualHostMonster, but they
aren't. People are welcome to fix this. :-) Since the VirtualHostMonster
determines the virtual root dynamically per request, I don't know how to
implement virtualRootPath and virtualPath... I guess you would need to get
the virtual root from the request, somehow. You'll still end up with the
situation that you want the virtual root for objects that are under other
virtual roots that the one the current request is using, but that is an
unsolvable problem with the current VirtualHostMonster.

//Lennart





More information about the Zope-Dev mailing list