I want to write a customized add-view with formlib. I've written an
addview-class with a 'create' method (see below) and a custom-factory
which is called by the create method. The problem I got stuck with now
is a problem of context and instantiation and I guess maybe the solution
would be a different registration of the view.
The view is for adding new 'Example' objects to an 'ExampleDB'
I have registered the page with the <browser:page> directive -- I don't
know if this is right at all:
I 've tried two alternative values for the 'for'-attribute: 1) the
container-object interface, 2) the interface for the object to be added
ad 1) The page is rendered, but when I press the Add-button there's an
error: After the 'createAndAdd'-method (inherited from
formlib.form.AddFormBase) has called my customized 'create'-method it
calls an 'add'-method, which calls self.context.add(...), but there is
no 'add'-method for my ExampleDB-object (which is the context). Should
there be one???
ad 2) This alternative seems to be better, since I want to add
'Example'-objects. But there is no 'Example'-object at the time when the
view is called. So what is the context?
The solution will be, as I guess, very similar to the z3-form-framework
with its /containerX/+/AddObjectY.html thing. I've studied the
source-code of zope.app.form.browser.add.AddView but run out of
zope.app.container.interfaces.IAdding seems most promising -- but what
to do with it?
Is it right to register a formlib-based addview with the
How do I get the + ? ;)
class ExampleAddView(ExampleMisc, MyFormlibForm, form.AddForm):
form_fields = form.Fields(IExample['example_orig_lang'],
template = ViewPageTemplateFile('example_add.pt')
def create(self, data):
example_factory = zapi.getUtility(IFactory,
example = example_factory(
einheitsacht = self.request.get('einheitsacht', None),
resource = self.request.get('resource', None),
example_orig_lang = data['example_orig_lang'],
example_x_lang = ,
example_in_resource_lang = data['example_in_resource_lang'],
quotation = data['quotation'],
page = data['page'])
Zope3-dev mailing list