[z3-five] Adaptation in untrusted code
Chris Withers
chris at simplistix.co.uk
Thu Nov 16 12:39:09 CET 2006
Martin Aspeli wrote:
>> Indeed. Can you give me a simple example of how you'd do this as a view?
>> Philipp said that views adapt the request, whereas no request is
>> involved here and nor do I want it do be...
>
> Where are you doing this?
Why does it matter? What do you mean by "where"? I'm doing it wherever I
want a rendering of an object relative to another object and maybe with
a title override. This is primarily for creating internal linking around
a site but I want to re-use it for things like listing on a contents
view, etc.
> In general, if you register a view, you give it a name and you say
> what interface it can be available on (or * for any type):
>
> <browser:page
Why browser:page? I _only_ want to be able to do:
tal:content="structure obj/@@render"
...and I think I can get away with not having an explicit context. I
certainly don't need the title override.
> name="foo"
> for=".interfaces.IMyType"
> template="some-template.pt"
I don't need a template here, I already have an set of adapters for my
objects which do what I want. I just want to be able to use them sanely
from inside ZPT's, see my other post.
> So, you traverse to /mytype/@@foo (the @@ is optional, but disambiguates).
I'd prefer these to be traversable inside a ZPT but not in a URL, but
I'd put up with them being url traversable if I really must.
> If your class derives from Products.Five.browser.BrowserView (I assume
> you're on Zope 2 underneath, if not it's
> zope.publisher.browser.BrowserView I think), you can override
> __call__() to do whatever (using self.context and self.request as
> appropriate).
Dammit, why can't I just use a simple adapter :-(
Chris
--
Simplistix - Content Management, Zope & Python Consulting
- http://www.simplistix.co.uk
More information about the z3-five
mailing list