Hey All,

Thought I'd share this and see if anyone had any better ideas...

So, I have a set of views that subclass each other, nothing out of the 
ordinary there. However, I also want the zpts used by the views to 
"subclass" each other, such that a subclassing view can use its parent's 
macro(s) and provide the same to be used further downstream.

This is the only solution I can think of:

from Products.Five.browser import BrowserView
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile

class Base1(BrowserView):
     template = ViewPageTemplateFile('html/template1.html')

class Base2(Base1):
     template = ViewPageTemplateFile('html/template2.html')
     parent = Base1

class Base3(Base2):
     template = ViewPageTemplateFile('html/template3.html')
     parent = Base2

class Concrete(Base3):
     def __call__(self):
         return self.template(self)


<metal:x define-macro="main">
   <metal:x define-slot="slot"/>


<tal:x define="parent nocall:view">
<metal:x define-macro="main"
          tal:define="parent nocall:parent/parent">
<metal:x use-macro="parent/template/macros/main">
   <metal:x fill-slot="slot">
   <metal:x define-slot="slot"/>


<tal:x define="parent nocall:view">
<tal:x define="parent nocall:parent/parent">
<metal:x use-macro="parent/template/macros/main">
   <metal:x fill-slot="slot">

Can anyone think of a nicer way that doesn't involve the 'parent' 
attribute on the view classes and has (preferably much) nicer code in 
the zpts?



Simplistix - Content Management, Zope & Python Consulting
            - http://www.simplistix.co.uk
Zope-Dev maillist  -  Zope-Dev@zope.org
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope )

Reply via email to