[Grok-dev] Re: Using martian to load schemata
optilude at gmx.net
Wed Jun 25 12:42:14 EDT 2008
Martijn Faassen <faassen <at> startifact.com> writes:
> Yes, this is a good point. grok.Fields() (or formlib FormFields) work
> during import time, so you can't get the schema yet.
> You can work around this, but you'd need to make it a property:
> class MyForm(grok.EditForm):
> def form_fields(self):
> return grok.Fields(IMySchema)
> This way grok.Fields will only be executed during runtime, as the form
> is being rendered.
> We run into similar problems when generating a schema from RDB schema.
> It's unfortunate the form code assumes the schemas need to exist already
> during import time. I wonder whether z3c.form has a better way?
Sounds like a bit of a general problem. If you want to be able to use Zope
3 components in grokkers/martian directives, you're going to get into funny
dependency loops, I think.
More information about the Grok-dev