[Zope-dev] z3c.form render & traversal bug?

Nick Bower nick_bower at fastmail.fm
Tue Mar 24 06:36:59 EDT 2009


In trying to work out how to traverse from a z3c.form Form for a simple 
scenario, I've uncovered something a little confusing with the Form code.

In my case the user specifies search criteria then gets a results page. 
  I am doing the following;

from z3c.form import form
from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile

class SearchForm(form.Form):

   # usual stuff
   fields=...

   def @handleSearch(self, action):
     # process criteria and setup for displaying results
     ...
     self.template = ViewPageTemplateFile('www/results.pt')

Which breaks because of BaseForm's render() method (see comments):

def render(self):
   '''See interfaces.IForm'''
   # render content template
   if self.template is None:
     template = zope.component.getMultiAdapter((self, self.request),
         IPageTemplate)
     return template(self) # ** displays ok default edit form
   return self.template() # ** breaks results page no instance

Should the last line be self.template(self) because 
ViewPageTemplateFile.__call__(self, instance, *args **kw) requires a 
single mandatory argument?

Although ViewPageTemplateFile requires an argument, IPageTemplate 
doesn't mandate it so I'm wondering if there were other adapters the 
code's author had in mind when doing this.  It seems a little 
inconsistent to a zope3 novice anyway.






More information about the Zope-Dev mailing list