Chris Withers wrote:
Jim Fulton wrote:
If you want to specify the name of a template in ZCML, then you'll
have to invoke some magic.
Why can't IView (or whatever it is) just specify that the constructor
must accept a request, response and a template instance?
Because the template may not be passed in, and even if it is, where
would it be constructed and how would it be found again?
If you have this:
def __init__(self, context, request, template):
self.template = template # IView specifices template = a template
then you may as well not have a 'template' attribute for <browser:page
/> at all since you have to do so much work; you could just do this
(which you can do now, in fact)
template = ViewPageTemplateFile('mytemplate.pt')
def __init__(self, context, request):
self.context = context
self.request = request
If you have it done in ZCML, though, you can get a template-only view
without any Python at all, though:
Zope3-dev mailing list