[Zope] How do I change dtml template on the fly in Python product?

Max Møller Rasmussen maxm@normik.dk
Fri, 27 Oct 2000 15:08:49 +0200


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