[Grok-dev] Re: Using martian to load schemata
faassen at startifact.com
Wed Jun 25 12:27:06 EDT 2008
Leonardo Rochael Almeida wrote:
> What I think might not work in your example is that there are things
> that happen at "import time" which you really can't work around, for
> instance, if I have a grok.Form with grok.AutoFields(IPage) interface,
> either "model('page.xml') will have to work immediately (which means
> not being able to rely on the C.A. being set up), or the AutoFields
> call won't find any actual fields on your interface.
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:
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?
More information about the Grok-dev