[Zope] Skins folder for python (non-cmf) product

Dylan Reinhardt zope@dylanreinhardt.com
31 Mar 2003 17:54:50 -0800


On Mon, 2003-03-31 at 16:39, Chad Nantais wrote:
> I need an
> interface that can render 10 different ways.  

OK.  

It sounds like what you mean is that a *particular* name associated with
your core product needs to render in many different ways depending on
some contextual trigger.

I'm assuming you've ruled out coding up those differences in the
template file itself.  It's a good first approach, but too limiting for
when you *really* need to switch things around on the fly.

It *doesn't* sound like you're talking about CMF-style skins, where
objects in the ZMI "override" default interfaces.  But if that is what
you want, clearly CMF is a great resource for how to do it.

Assuming you want to pick from among several defined product interfaces
on-the-fly, try something like:

--------- 

# Set up your interfaces:
interface1 = DTMLFile('dtml/interface1', globals())
interface2 = DTMLFile('dtml/interface2', globals())

...

def pick_interface(self, REQUEST):
    # figure out what interface you're using
    my_interface = some_method(REQUEST[some_field])

    # and call your interface on the fly...
    return self.__dict__[my_interface](self, REQUEST)

----------

That's top-of-head, untested, etc.  But probably enough to go on.


> Maybe I'll spend more
> time dissecting CMF to learn how it implements skins.
> 

That's time well-spent in any event.

HTH,

Dylan