Hi pete!

pete wrote:
Sorry in advance if this is a dumbo question,

Not at all. As you can see from other discussions on this list there are still no generally accepted patterns for using views in CMF.

but I'm having trouble seeing the style to follow in the following situation:

 - user calls a url, say /object/tuesday_message

 - if today's date is a tuesday, render 'tuesday.pt'

 - otherwise render 'no_message.pt'

both tuesday.pt and no_message.pt are proper templates which need to follow the site's main template, and have some logic in a view class.

Without views, I would make tuesday_message a python script, and return the required template directly with context.tuesday() or context.no_message().

But what's the best way to do this with a view: I don't want users to be able to access the templates directly, so I can't redirect between them, and the two templates are sufficiently different not to be combined together in an if-else type way.

Maybe there is a better solution, but using 'no_message.pt' as default and hard-coding additional templates in the view class should work for you:

    def __call__(self):
        if self.isTuesday():
            return ZopeTwoPageTemplateFile('tuesday.pt').__of__(self)()
        return self.index()



Zope-CMF maillist  -  Zope-CMF@lists.zope.org

See http://collector.zope.org/CMF for bug reports and feature requests

Reply via email to