[ZPT] absolute url of a page template

Clemens Robbenhaar zpt@zope.org
Fri, 18 Oct 2002 20:30:47 +0200


Hi Clint,

 > I have a product the defines some PageTemplates via PageTemplateFile and
 > I'm trying to get the absolute url of the template itself. 
 > 
 > when I try :
 > here/Products/manage_main/absolute_url 
 > it became:
 > http://linux1:8080/AAA/Products/ 
 > 
 > how can I do this? 
 > 

Hm, I guessed this list is more focused on the development of page
templates than on howto's, thus maybe zope@zope.org would maybe a
better place for the posting; but anyway:

 PageTemplateFile objects do not have an 'absolute_url' method defined;
that is why You get the url of the "Products" object. 
Hm, maybe one could define one, like:

 def absolute_url(self):
    """ get the absolute url for this page template file """
    return self._getContext().absolute_url()+'/'+self.__name__


If You can live with a pragmatic approach and assume the name of the
page template does not change, You could mimic this method by writing
something like:

 python: here.Products.absolute_url()+'/manage_main'

in Your page remplate.

Cheers,
Clemens