[Grok-dev] z3c.form
Tim Terlegård
tim.terlegard at valentinewebsystems.se
Tue Jul 15 15:09:25 EDT 2008
On Jul 15, 2008, at 8:17 PM, Toni Mueller wrote:
> I find it non-obvious how to use z3c.form. There's a simple example of
> how to make an "AddForm" in the docs
Did you also see z3c.formdemo?
> , but (maybe because I don't
> understand Grokkers?) trying to copy that yields a traceback because I
> don't have a 'request' object.
>
> My playground app currently looks like this:
>
>
> class MyApp(grok.Application, grok.Container):
> grok.traversable('add')
>
> def traverse(self, name):
> if name == 'add':
> return MyAddForm()
> else:
> raise NotImplementedError
>
>
> class MyAddForm(z3c.form.form.AddForm):
> ...
>
>
>
> Running this yields this error:
>
> TypeError: __init__() takes exactly 3 arguments (1 given)
I haven't used z3c.form myself, but i would except AddForm to be a view,
that means the constructor wants a context and a request.
so MyAddForm(self.context, self.request) would perhaps work better.
I don't think it causes the error, but you don't need
grok.traversable('add').
grok.traversable('attr') makes the 'attr' attribute on the class/object
traversable. But you don't have any 'add' attribute in your code. The
traverse() method works without that.
/Tim
More information about the Grok-dev
mailing list