[Grok-dev] Re: z3c.form

Toni Mueller support at oeko.net
Tue Jul 15 16:22:32 EDT 2008

Hi Tim,

thanks for answering!

On Tue, 15.07.2008 at 21:09:25 +0200, Tim Terlegård <tim.terlegard at valentinewebsystems.se> wrote:
> 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?

not yet. For this and similar reasons, I added a precautionary

>> 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()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ This goee BOOOM!, as does
   	    return MyAddForm(None, self.request)

>> 	else:
>> 	    raise NotImplementedError
> 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.

You mean, in the traverse() method, where it crashes?

I tried that, but didn't succeed because there is no request attribute
to self. That's when I dug out pdb.

> 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.

Hmmm. I didn't try that, but at least, while I don't need any of these
in the current Grok, automatic traversal appears to be broken when I
try to use z3c.form.

Kind regards,

More information about the Grok-dev mailing list