On Fri, 2006-02-10 at 14:48 -0800, Paulus Zegwaard wrote: 
> But although I understand Zope 3 has something like that too, I'm 
> unclear how to achieve that every object provides an absolute_url 

Objects that are contained provide ILocation interface 

__name__ - object name
__parent__ - container name 

it is container's responsibility to set these and it all happens behind
the scenes and contained objects themselves shouldn't have to worry
about it too much. 

For example if you had something like this

class IPerson(Interface):
        surname = TextLine(title=_(u"Surname"))
        firstName = TextLine(title=_(u"First Name"))

when implementing this interface you would just say it is persistent and

class Person(Persistent):

        __name__ = None
        __parent__ = None
        surname = u''
        firstName = u''


from zope.app.container.contained import Contained
class Person(Persistent, Contained):

        surname = u''
        firstName = u''
(This way Contained implements the location stuff - the name and

And that should be it. To get absolute url I would do something like 

from zope.app import zapi
zapi.absoluteURL(obj, request)

there is also 


which will return path of the object

For a better explanation of the location concept look up 'location' in
the index of Philipp's book once it arrives.

> A related questions is: is there an obvious way to get the site url (or 
> object) other then just knowing the name?

Not sure about this..


Zope3-users mailing list

Reply via email to