[Zope-CMF] Determining the current view

J C Lawrence claw@kanga.nu
Sat, 08 Feb 2003 13:11:30 -0800


On Sat, 8 Feb 2003 19:38:18 +0100 
Dieter Maurer <dieter@handshake.de> wrote:
> J C Lawrence wrote at 2003-2-8 01:56 -0800:

>> a) Check that the thing currently being viewed is not a page template
>> or DTML method or script (ie it has to be a "real" object)?

> You look at "here.meta_type" and check whether you like it...

Ahh, of course, doh.  

I guess there really is no way in Zope to distinguish between an object
which represents itself (ie is a leafnode) from those which represent
others -- for the simple reason that they are the same: the same code
and same inheritance trees are present in both.  I'm going to have to
think about this a bit more.
  
>> b) Check that the object view method on the object is being invoked,
>> and not, for instance, folder_content, edit, or some other view of
>> the object?

> Not so easy:

>   The "view" method may be called when
  
>     * you do not specify an explicite template

>     * you use "view" explicitely

>     * you use the action, "view" is mapped to, directly.

> You can approximate the first two reasons by comparing "URL" with
> "here.getId or "here.absolute_url".  Acquisition may make it a bit
> more difficult.

> The last case is more difficult, as "view" can be mapped to different
> actions...

Hurm.  That hurts a little bit.  I think I can work around it however.
Thanks.

-- 
J C Lawrence                
---------(*)                Satan, oscillate my metallic sonatas. 
claw@kanga.nu               He lived as a devil, eh?		  
http://www.kanga.nu/~claw/  Evil is a name of a foeman, as I live.