[Zope3-Users] Re: absolute_url in the viewlet ?
Jürgen Kartnaller
juergen at kartnaller.at
Tue Oct 3 02:46:20 EDT 2006
Or simply :
from zope.traversing.browser.absoluteurl import absoluteURL
absoluteURL(self.context, self.request)
Jürgen
ksmith93940-dev at yahoo.com wrote:
> self.context.absolute_url looks very zope2ish, absolute_url is no longer inherited, it is an adapted component, so I believe the accepted Zope3 way is...
>
> from zope.app import zapi
> from zope.app.traversing.browser.interfaces import IAbsoluteURL
>
> .........
>
> def render(self):
> url = zapi.getMultiAdapter( (self.context, self.request), IAbsoluteURL)
> return "<li>IAbsoluteUrl == %s/</li>" % url
>
>
>
>
> Kevin Smith
>
> ----- Original Message ----
> From: Christophe Combelles <ccomb at free.fr>
> To: zope3-users at zope.org
> Sent: Monday, October 2, 2006 7:14:22 PM
> Subject: [Zope3-Users] absolute_url in the viewlet ?
>
> Hi,
>
> How can I obtain the absolute_url of the context object in a content provider or
> in a viewlet ?
>
> For example, in the demo3 of zope3demos, the render() method of the viewlet
> returns self.context.__name__.
> ( http://zope3demos.googlecode.com/svn/trunk/demo3/demo.py )
>
> How could I tell it to return the absolute_url instead of the __name__ ?
>
> (self.context.absolute_url gives a ForbiddenAttribute error.)
>
>
> thanks,
> Christophe
> _______________________________________________
> Zope3-users mailing list
> Zope3-users at zope.org
> http://mail.zope.org/mailman/listinfo/zope3-users
>
>
>
More information about the Zope3-users
mailing list