[Zope3-Users] Re: Re: viewlets for specific interfaces

Luis De la Parra lparrab at gmx.net
Fri Sep 15 14:10:14 EDT 2006


hello stephan,

thanks for taking the time to take a look at it. I guess I don't understand
some of the basic concepts then...

I actually want "viewlet.html" to be available to all objects (not only
IFile), but some of the viewlets should be discriminated based on the
current object.

suppose my "viewlet.html" is called "index.html" and is used as a "main
template" for display of different types of objects.

in the index.html page-template I want to have a section "viewletmanager"
called "about_this"

then I want to have a viewlet "talkback" showing user comments, which is
available for all objects, and I want a second viewlet (registered with the
same "about_this" viewlet manager called "photo_information" which only
works for objects implementing "IPhoto"

if I visist my_music_file.mp3/index.html  I want to see the user comments to
my new song on the bottom of the page, and if I visit
my_photo.jpg/index.html I want to to see a box with info such as
shutter-speed, apperture, etc, and a box with the user comments...

do I really need two different "index.html"s ? even if the rest of the page
should be the same ( display a link for download in the upper part, title,
and description on the right, etc )

regards. luis

Stephan Richter wrote:

> On Thursday 14 September 2006 14:21, Luis De la Parra wrote:
>> wow. thanks for the offer... maybe I'm doing something wrong somewhere
>> else then. I'm attaching a minimal package which (does not) work(s) for
>> me:
> 
> Here is you problem:
> 
> You registered the page "viewlet.html" as follows:
> 
>   <browser:page
>     for="*"
>     name="viewlet.html"
>     template="index.pt"
>     permission="zope.View"/>
> 
> For some reason this caused this view to be really a view the default view
> (index.html), so that you implicit traversal was:
> 
> file.txt/@@index.html/@@viewlet.html
> 
> ... or something like that. I did not investigate further. Then I changed
> the registration to:
> 
>   <browser:page
>     for="zope.app.file.interfaces.IFile"
>     name="viewlet.html"
>     template="index.pt"
>     permission="zope.View"/>
> 
> and everything worked just fine. Whether the described traversal behavior
> is correct I cannot say without a bit more digging, which I have no time
> for now.
> 
> How did I figure that out? I went to
> zope.viewlet.manager.ViewletManagerBase and did some debugging just before
> the viewlets were looked up and found that the context was not what you
> would expect. I immediately knew that the page "viewlet.html" was working
> onto the wrong context and thus registered it for the specific interface
> and everything worked.
> 
> Regards,
> Stephan




More information about the Zope3-users mailing list