Re: [Zope3-Users] view vs page confused
Hi, On Tue, Mar 27, 2007 at 06:03:54PM +0200, Dominique Lederer wrote: [snip] so if i create a class which inherits from BrowserView, and then register it via zcml as browser:page, it becomes adaptes to IBrowserRequest an turns to a BrowserPage (via the on-the-fly created class)? so inheriting from BrowserPage instead from BrowserView would make no sense with my example? It doesn't event make sense to inherit from BrowserView because a browser:page-registered view-class is just a mixin. A class like this is enough: class MyView(object): def mySpecialMethod(self): [...] [...] browser:page class=.views.MyView [...] / Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] view vs page confused
Marius Gedminas schrieb: On Wed, Jan 24, 2007 at 08:31:52PM +0100, Dominique Lederer wrote: can someone explain me please when to use browser:view and when browser:page? As far as I understand, the intended use of browser:page is to define views that are accessible to browsers by using URLs. The intended use of browser:view is to define helper views that are accessible to page templates in TALES expressions like tal:attributes=href context/@@absolute_url. I might be wrong. and when would i inherit a View Class from zope.publisher.BrowserView and when from zope.publisher.BrowserPage, and why do i need them when i could just inherit from object without any errors? A browser page must implement IBrowserPublisher if you want it to be accessible from the outside. BrowserPage does that. The browser:page also does that, but in a different way. The directive does deep magic -- it constructs a new class on the fly that implements IBrowserPublisher and inherits from the view class you've specified. It can also provide a 'index' attribute and a default implementation of __call__. BrowserView only gives you a useful __init__. If you inherit directly from object, you'll have to define __init__ by yourself. Looking at the code I see that BrowserView also gives you a __parent__ property that is used by the standard Zope 3 security policy. I do not think it is all that important, as usually views in Zope3-land are not security proxied. Magic is going out of fashion in Zope3-land. In my personal opinion the best practice for Zope 3 views is to follow this pattern: class MyView(BrowserPage): adapts(ISomeContext, IBrowserRequest) template = ViewPageTemplateFile('...') def __call__(self): # do form processing, if any return self.template() and then register it with browser:page. so if i create a class which inherits from BrowserView, and then register it via zcml as browser:page, it becomes adaptes to IBrowserRequest an turns to a BrowserPage (via the on-the-fly created class)? so inheriting from BrowserPage instead from BrowserView would make no sense with my example? cheers Dominique ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] view vs page confused
On Wed, Jan 24, 2007 at 08:31:52PM +0100, Dominique Lederer wrote: can someone explain me please when to use browser:view and when browser:page? As far as I understand, the intended use of browser:page is to define views that are accessible to browsers by using URLs. The intended use of browser:view is to define helper views that are accessible to page templates in TALES expressions like tal:attributes=href context/@@absolute_url. Thanks Marius for the nice explanation. Of course, the question remains why a view is named 'page' and an other kind of view is named 'view'. Perhaps 'page' should be renamed to 'view' and 'view' should be renamed to 'fill_in_space_for_a_zope_guru' :) Greetings Alex -- Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen! Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] view vs page confused
hi! can someone explain me please when to use browser:view and when browser:page? and when would i inherit a View Class from zope.publisher.BrowserView and when from zope.publisher.BrowserPage, and why do i need them when i could just inherit from object without any errors? and what means the @@ or ++view++ if i can access a view(page?) without that? i am really confused :) please help. thanks Tom -- Feel free - 5 GB Mailbox, 50 FreeSMS/Monat ... Jetzt GMX ProMail testen: http://www.gmx.net/de/go/promail ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users