Re: [Zope3-Users] How to register multiple view for the same content class
On 9/28/07, Frank Burkhardt <[EMAIL PROTECTED]> wrote: > > You could use a view as dispatcher which then would be traversed like > object/@@view: > > class MyDispatcher(object): >def __call__(self): > > realview=zapi.getMultiAdapter((self.context,self.context.__parent__,self.request)) > return realview() > > class MyExampleView(object): >def __init__(context,parent,request): > self.context=context > self.parent=parent > self.request=request > >def __call__(self): > return "Book/shelf-specific html" > > *configure.zcml* > > ... /> > > > Got it. Thanks. -- Hong Yuan 大管家网上建材超市 装修装潢建材一站式购物 http://www.homemaster.cn ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] How to register multiple view for the same content class
Hi, On Fri, Sep 28, 2007 at 05:33:56PM +0800, Yuan HOng wrote: > On 9/28/07, Frank Burkhardt <[EMAIL PROTECTED]> wrote: > > > > > You just need another browser:page here. Name it 'in-shelf-view' and > > use something like > > > > > > > > to embed it. > > > > Thanks, that works. So all was missing is the '@@' notation to tell > TALES to look up a view for Book. > > > Registering the view for different "shelves" is possible, too. But this not > > a simple view anymore - it's a "Multiview". You need an adapter for > > (book,shelve,request) to do that which means, a simple browser:page won't > > work and you'll be not able to use the object/@@view notation for that. > > > > If not object/@@view, what then? A custom traverse to lookup the > Multiview maybe? You could use a view as dispatcher which then would be traversed like object/@@view: class MyDispatcher(object): def __call__(self): realview=zapi.getMultiAdapter((self.context,self.context.__parent__,self.request)) return realview() class MyExampleView(object): def __init__(context,parent,request): self.context=context self.parent=parent self.request=request def __call__(self): return "Book/shelf-specific html" *configure.zcml* Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] How to register multiple view for the same content class
On 9/28/07, Frank Burkhardt <[EMAIL PROTECTED]> wrote: > > You just need another browser:page here. Name it 'in-shelf-view' and > use something like > > > > to embed it. > Thanks, that works. So all was missing is the '@@' notation to tell TALES to look up a view for Book. > Registering the view for different "shelves" is possible, too. But this not > a simple view anymore - it's a "Multiview". You need an adapter for > (book,shelve,request) to do that which means, a simple browser:page won't > work and you'll be not able to use the object/@@view notation for that. > If not object/@@view, what then? A custom traverse to lookup the Multiview maybe? -- Hong Yuan 大管家网上建材超市 装修装潢建材一站式购物 http://www.homemaster.cn ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] How to register multiple view for the same content class
Hi, On Fri, Sep 28, 2007 at 03:19:10PM +0800, Yuan HOng wrote: [snip] > Is it possible to register two different views for the Book, one for > display in shelf, another for the detailed view? The one for the > detailed view is simply a BrowerPage, but how to do the book-in-shelf > view? Exactly the same way. > I'd like for my shelf template to look something like this: > > > to embed it. Registering the view for different "shelves" is possible, too. But this not a simple view anymore - it's a "Multiview". You need an adapter for (book,shelve,request) to do that which means, a simple browser:page won't work and you'll be not able to use the object/@@view notation for that. Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] How to register multiple view for the same content class
Hi, I thought this would be a simple case for Zope3, but after one whole day I am not able to find a clean solution. Must be missing something. Suppose I have a BookShelf which contains lots of Books. The view for BookShelf will show a list of Books contained in the shelf, and when the user click on a book, a detailed view for the Book will be opened. Of course the Book rendered in the shelf will be different from the same rendered in the book detail view. But how best to achieve this in zope3? The triditional solution (zope 2) I am familar with would be to use in the page template for the shelf like this: ... This however mixes the presentation of the shelf itself with the books on the shelf. If I want to change how books looks like on the shelf, I have to modify the shelf template, which doesn't seem to be a good separation of concerns. Is it possible to register two different views for the Book, one for display in shelf, another for the detailed view? The one for the detailed view is simply a BrowerPage, but how to do the book-in-shelf view? I'd like for my shelf template to look something like this: http://www.homemaster.cn ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users