Luis De la Parra wrote:

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

well.. after some more testing and trying I got it to finally work, altough
it seems to be a big ugly hack and I don't really understand _why_ it
works.
(I guess the problem is that I still don't have the difference clear between
a page and a view, but it seems like the "page" generated by the
browser:page directive didn't pass the "right" context when calling the
template)

this is what I did:

1)change my "main page" registration to: ( added the class=".DemoPageView)

  <browser:page
    for="*"
    name="viewlet.html"
    template="index.pt"
    class=".DemoPageView"
    permission="zope.View"/>

2)since I don't have any other "content types" installed, I changed the
viewlet registration to IImage:

  <browser:viewlet
    name="hello"
    for="zope.app.file.interfaces.IImage"
    manager=".ILeftColumn"
    class=".HelloMessage"
    permission="zope.Public"/>

3) added the DemoPageView:

class DemoPageView(BrowserPage):
    interface.implements(IBrowserPublisher)

    def __call__(self, *a, **k):
      return ViewPageTemplateFile('index.pt')(self.context)

4) added a zope.app.file.Image... and now it works:
file.txt/viewlet.html  ->> viewlet test:     <<<<no message, as expected!
image.jpb/viewlet.html ->> viewlet test: Hello!  <<< hello msg as expected!!

I had to test against image vs. file because my first tests file vs. folder
gave a message

############
...
  File "/home/luis/src/z/src/zope/app/pagetemplate/viewpagetemplatefile.py",
line 44, in __call__
    namespace = self.pt_getContext(
ForbiddenAttribute: ('request', <zope.app.folder.folder.Folder object at
0xb6d1252c>)
###########


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

Reply via email to