[Zope3-Users] Custom addform and object creation error
Cliff Ford
Cliff.Ford at ed.ac.uk
Sat Apr 23 11:36:36 EDT 2005
I have a custom addform that works fine with a standard configuration.
However, on submission it redirects to the contents view of its
container and I want it to redirect somewhere else, such as the new
object's edit or metadata views. All I really need is a nextURL
configuration directive, mentioned in mailings some time ago, but I
don't think that has been implemented.
I have created a class with a __call__ method that returns the custom
form template, and a nextURL() method. In the configuration file I have
replaced the content_factory directive with the class directive.
With the custom form and class, the form displays and field validation
still works, but with valid fields I get an object creation error:
File "/usr/local/Zope3/src/zope/app/form/browser/add.py", line 71, in create
return self._factory(*args, **kw)
TypeError: 'NoneType' object is not callable
I have looked at the add.py module and am none the wiser. I guess I have
neglected to set something somewhere, may be context related. Can anyone
enlighten me? The custom class has almost nothing in it (see below) so I
am surprised it gets as far as it does. [I have also searched the
archives and read both recent Zope3 books but can't find an answer.]
Cliff
Custom class:
from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
class PageAddFormD:
"""This class reads the form data and creates a custom Page"""
template = ViewPageTemplateFile('pageaddformd.pt')
def __call__(self):
return self.template()
def getInterfaces(self):
""" Don't know if I need this here """
return implementedBy(GlgPage)
def nextURL(self):
""" return the next place to go """
# have not got this far yet
return '../'
More information about the Zope3-users
mailing list