How do I change dtml template on the fly in Python product?
I have asked this question somewhat differently in another thread but here I go again from another angle, as it might have been my approach that was wrong to begin with. I have a Python product that allready does what I want it to, but I want to be able to create different views of the products content. (Model View Controller principle). To do this I have created a folder with different views (Or skins if you would prefer the Gnome/KDE way of saying it.) views view1 list.dtml view.dtml edit.dtml view2 list.dtml view.dtml edit.dtml In my class I have made a value that hold the name of the selected view, I call this: self.selView I want to make it possible to use the different sets of dtml files to create a different look and feel to the data. I want to write my "index_html" method so that it returns a rendered version of "list.dtml" corresponding to the selected view, by the name of the folder holding the selected view. something like this (which doesn't work): def index_html(): return HTMLFile('views/' + self.selView+ 'list') Is that the best way to do it? Regards Max M
Max Møller Rasmussen wrote:
I want to write my "index_html" method so that it returns a rendered version of "list.dtml" corresponding to the selected view, by the name of the folder holding the selected view.
something like this (which doesn't work):
def index_html(): return HTMLFile('views/' + self.selView+ 'list')
You actually want to write a __call__ method (something) like this: def __call__(self, REQUEST=None, **kw): """""" return apply(HTMLFile('views/' + self.selView+ 'list'),(self,REQUEST),kw) index_html=None ...this last bit is needed so index_html isn't acquired from an object above. cheers, Chris
participants (2)
-
Chris Withers -
Max Møller Rasmussen