Re: [Zope] Execute a PageTemplate in another context

2008-02-04 Thread Andrew Milton
+---[ Peter Bengtsson ]--
| Is it possible to execute a PageTemplate as if it was located somewhere 
| else?
| The PageTemplate has this code::
| htmlbr tal:replace=here/absolute_url_path//html
| 
| And it's located in a folder called /foo/bar/ which are normal Zope 
| Folder objects.
| I'm executing this template object from Python code (not from URL 
| travsersal) and the rendered result is:
| html/foo/bar/html
| 
| But what if I want to execute it as if it existed in another context, 
| e.g. /barfoo
| Is that possible?
| 
| I can imagine a some convoluted solutions but was hoping for something 
| easy and obvious that I've missed.

context.foo.bar.barfoo.template_id(...) ?

-- 
Andrew Milton
[EMAIL PROTECTED]
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Execute a PageTemplate in another context

2008-02-04 Thread Peter Bengtsson



Andrew Milton wrote:

+---[ Peter Bengtsson ]--
| Is it possible to execute a PageTemplate as if it was located somewhere 
| else?

| The PageTemplate has this code::
| htmlbr tal:replace=here/absolute_url_path//html
| 
| And it's located in a folder called /foo/bar/ which are normal Zope 
| Folder objects.
| I'm executing this template object from Python code (not from URL 
| travsersal) and the rendered result is:

| html/foo/bar/html
| 
| But what if I want to execute it as if it existed in another context, 
| e.g. /barfoo

| Is that possible?
| 
| I can imagine a some convoluted solutions but was hoping for something 
| easy and obvious that I've missed.


context.foo.bar.barfoo.template_id(...) ?

It's not done like that. I receive it the PageTemplate object as is 
already. I tried this::


 return apply(template_obj, (self.some.other.context, self.REQUEST), kw)

But that didn't work.


--
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.com
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Execute a PageTemplate in another context

2008-02-04 Thread Andrew Milton
+---[ Peter Bengtsson ]--
| Andrew Milton wrote:
| +---[ Peter Bengtsson ]--
| | Is it possible to execute a PageTemplate as if it was located somewhere 
| | else?
| | The PageTemplate has this code::
| | htmlbr tal:replace=here/absolute_url_path//html
| | 
| | And it's located in a folder called /foo/bar/ which are normal Zope 
| | Folder objects.
| | I'm executing this template object from Python code (not from URL 
| | travsersal) and the rendered result is:
| | html/foo/bar/html
| | 
| | But what if I want to execute it as if it existed in another context, 
| | e.g. /barfoo
| | Is that possible?
| | 
| | I can imagine a some convoluted solutions but was hoping for something 
| | easy and obvious that I've missed.
| 
| context.foo.bar.barfoo.template_id(...) ?
| 
| It's not done like that. I receive it the PageTemplate object as is 
| already. I tried this::
| 
|  return apply(template_obj, (self.some.other.context, self.REQUEST), kw)

getattr(foo.bar.barfoo, template_obj.getId())() ?


-- 
Andrew Milton
[EMAIL PROTECTED]
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )