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

2006-09-15 Thread Luis De la Parra
Stephan Richter wrote:

> ... or something like that. I did not investigate further. Then I changed
> the registration to:
> 
>for="zope.app.file.interfaces.IFile"
> name="viewlet.html"
> template="index.pt"
> permission="zope.View"/>

hmm... I put some debug strings in ViewletManagerBase.__init__ and if I
registered the page for IFile: it works as you said, and I get following
lines on the console:

===
ViewletManagerBase.__init__:
context =   
view =  


If I switch it back to for="*", then I get this output:

===
ViewletManagerBase.__init__:
context =   
view =  

so the context passed from the "page object" to the viewlet manager is wrong
(seems wrong to me) and the adapter look-up fails

can you give me a hint why this viewmeta is my context with this kind of
page registration?

regards.luis


___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


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

2006-09-15 Thread Luis De la Parra

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:
> 
>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:
> 
>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


___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


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

2006-09-15 Thread Luis De la Parra

hello,

yes... I'm sure it provides IFile: I added it via the normal zmi add menu.
did you have time to try my test package? is it working for you??

This is what I get when I visit /file.txt/@@introspector.html
##
Object Introspector: zope.app.file.file.File ( file.txt ) 
 Parent: 
Directly Provided Interfaces
 No interfaces are directly provided. 
Provided Interfaces
zope.app.publication.interfaces.IFileContent 
zope.app.file.interfaces.IFile 
zope.annotation.interfaces.IAttributeAnnotatable 
zope.app.externaleditor.interfaces.IExternallyEditable 
persistent.interfaces.IPersistent

#
...and this is what I get on /file.txt/viewlet.html

viewlet test:

so the viewletmanager is being called, but it doesnt find any viewlets...
=-(

regards.luis



Stephan Richter wrote:

> On Thursday 14 September 2006 14:21, Luis De la Parra wrote:
>> I then change my configure.zcml as described, and none of the above links
>> shows "hello" anymore.. I would expect /viewlet.html to show an empty
>> message, and /file.txt/viewlet.html to display "hello" again..
> 
> Are you sure, file.txt provides IFile? You can check this out with
> @@introspector.html.
> 
> Regards,
> Stephan


___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users