[Zope-CMF] Re: Moving to browser views
Charlie Clark wrote: Hi, I making my first stab at browser views for my iCal support having finally come up with some templates that seem to produce files that work with most calendar programs. I have a couple of questions: 1) should I implement them as BrowserViews calling templates or should I use an adapter? The templates are TAL and the only difference to an HTML page is the different response header. i think the most common idiom is to use browser:page directives, pointing at a BrowserView subclass, using either template or attribute within the directive to specify the action to take. 2) how do I pass in values derived specifically for these views? ie. going from options = {} options['name'] = charlie ... return context.mytemplate(**options) while it may be appropriate in some cases to pass values directly into the template like this, usually the template pulls the values from the view class. you can make name an attribute (or a property) of the view class, and then use the view/name TALES expression within the template. -r ___ Zope-CMF maillist - Zope-CMF@lists.zope.org http://mail.zope.org/mailman/listinfo/zope-cmf See http://collector.zope.org/CMF for bug reports and feature requests
Re: [Zope-CMF] Re: Moving to browser views
Am 18.07.2007 um 22:07 schrieb Rob Miller: while it may be appropriate in some cases to pass values directly into the template like this, usually the template pulls the values from the view class. you can make name an attribute (or a property) of the view class, and then use the view/name TALES expression within the template. Okay, thanks! I'm nearly there. I think. %-? ;-) Because I'm only creating essentially a slightly different view of an event I've taken the ZCML for the standard view as a lead: browser:page for=Products.CMFCalendar.interfaces.IEvent layer=Products.CMFDefault.interfaces.ICMFDefaultSkin name=event_iCal_view class=.event.EventiCalView permission=zope2.View / is event_iCal_view my view class? So, let's say I need to turn my creation date into 20030127T09Z I can call this in my view class via self.startdate = self.context.CreationDate() and call this in my template via view/startdate? Charlie -- Charlie Clark Helmholtzstr. 20 Düsseldorf D- 40215 Tel: +49-211-938-5360 GSM: +49-178-782-6226 ___ Zope-CMF maillist - Zope-CMF@lists.zope.org http://mail.zope.org/mailman/listinfo/zope-cmf See http://collector.zope.org/CMF for bug reports and feature requests
[Zope-CMF] Re: Moving to browser views
Charlie Clark wrote: I making my first stab at browser views for my iCal support having finally come up with some templates that seem to produce files that work with most calendar programs. I have a couple of questions: 1) should I implement them as BrowserViews calling templates or should I use an adapter? The templates are TAL and the only difference to an HTML page is the different response header. 2) how do I pass in values derived specifically for these views? ie. going from options = {} options['name'] = charlie ... return context.mytemplate(**options) to the appropriate call inside a browser view. I haven't been able to work this out based on the examples or the Zope 3 book. shameless-plug You know, I wrote a whole book for learning how to use this Zope 3 stuffm (and that includes explanations of how to use it in Zope 2 via Five). /shameless-plug -- http://worldcookery.com -- Professional Zope documentation and training ___ Zope-CMF maillist - Zope-CMF@lists.zope.org http://mail.zope.org/mailman/listinfo/zope-cmf See http://collector.zope.org/CMF for bug reports and feature requests
[Zope-CMF] Re: Moving to browser views
Charlie Clark, on 2007-07-18: Okay, thanks! I'm nearly there. I think. %-? ;-) Because I'm only creating essentially a slightly different view of an event I've taken the ZCML for the standard view as a lead: browser:page for=Products.CMFCalendar.interfaces.IEvent layer=Products.CMFDefault.interfaces.ICMFDefaultSkin name=event_iCal_view class=.event.EventiCalView permission=zope2.View / is event_iCal_view my view class? No, that is the name. That means you can do tal:define=view context/@@event_iCal_view in a template that has an IEvent provider as context. The class is the EventiCalView class in event.py. So, let's say I need to turn my creation date into 20030127T09Z I can call this in my view class via self.startdate = self.context.CreationDate() and call this in my template via view/startdate? Yes. You need to do the tal:define above first though, unless there is some other magic (well, code) that hooks up this view to that specific template. I think that is done when you specify template=mytemplate in the zcml snippet. -- Maurits van Rees | http://maurits.vanrees.org/ [NL] Work | http://zestsoftware.nl/ Do not worry about your difficulties in computers, I can assure you mine are still greater. ___ Zope-CMF maillist - Zope-CMF@lists.zope.org http://mail.zope.org/mailman/listinfo/zope-cmf See http://collector.zope.org/CMF for bug reports and feature requests
Re: [Zope-CMF] Re: Moving to browser views
Am 18.07.2007 um 23:03 schrieb Philipp von Weitershausen: shameless-plug You know, I wrote a whole book for learning how to use this Zope 3 stuffm (and that includes explanations of how to use it in Zope 2 via Five). /shameless-plug No need to be shameless, Mr. Gallagher! I've got the book and am working my way through it. It's very good but it didn't cover this in quite the detail I need. Charlie -- Charlie Clark Helmholtzstr. 20 Düsseldorf D- 40215 Tel: +49-211-938-5360 GSM: +49-178-782-6226 ___ Zope-CMF maillist - Zope-CMF@lists.zope.org http://mail.zope.org/mailman/listinfo/zope-cmf See http://collector.zope.org/CMF for bug reports and feature requests
Re: [Zope-CMF] Re: Moving to browser views
Am 18.07.2007 um 23:10 schrieb Maurits van Rees: No, that is the name. That means you can do tal:define=view context/@@event_iCal_view in a template that has an IEvent provider as context. The class is the EventiCalView class in event.py. Yes, thanks. So, let's say I need to turn my creation date into 20030127T09Z I can call this in my view class via self.startdate = self.context.CreationDate() and call this in my template via view/startdate? Yes. You need to do the tal:define above first though, unless there is some other magic (well, code) that hooks up this view to that specific template. Actually I don't define the view explicitly in the template as my class calls it directly. I think that is done when you specify template=mytemplate in the zcml snippet. Well, I've now got two classes (EventvCalView has to set different headers so I can't see an easy way round this in ZCML) and two different templates. Everything is working fine apart from the content-type is remaining steadfastly text/html! Content-Disposition is being set correctly. How do I fix this? ;-) Tomorrow I'll try and write the tests for this so that I can submit the patch. And I'll also have something to talk about at the Rheinland ZUG meeting on Friday! ;-) Charlie -- Charlie Clark Helmholtzstr. 20 Düsseldorf D- 40215 Tel: +49-211-938-5360 GSM: +49-178-782-6226 ___ Zope-CMF maillist - Zope-CMF@lists.zope.org http://mail.zope.org/mailman/listinfo/zope-cmf See http://collector.zope.org/CMF for bug reports and feature requests
Re: [Zope-CMF] Re: Moving to browser views
Am 18.07.2007 um 23:32 schrieb Charlie Clark: Well, I've now got two classes (EventvCalView has to set different headers so I can't see an easy way round this in ZCML) and two different templates. Everything is working fine apart from the content-type is remaining steadfastly text/html! Content- Disposition is being set correctly. How do I fix this? ;-) mm, calling the template gets the response header reset... 1) call the template 2) set the headers 3) write the response Charlie -- Charlie Clark Helmholtzstr. 20 Düsseldorf D- 40215 Tel: +49-211-938-5360 GSM: +49-178-782-6226 ___ Zope-CMF maillist - Zope-CMF@lists.zope.org http://mail.zope.org/mailman/listinfo/zope-cmf See http://collector.zope.org/CMF for bug reports and feature requests