[Grok-dev] autoforms and derived interfaces

Jasper Spaans j at jasper.es
Tue Jun 23 11:44:40 EDT 2009


Hi,

The following code should speak for itself; is it supposed to work like
this? (the reason for the constructor is that form_fields takes its value
from IAction, which is not what I want as I'm adding/editting objects of
type context.__class__, which might implement interfaces derived from
IAction.)

trollfot on #grok mentioned that a use case for the current behaviour is
when you want to prevent editing all of the attributes of an object.

What's your opinion?

class EditAction(grok.EditForm):
    grok.name('edit')
    grok.context(IAction)
    grok.template('addaction')
    
    def __init__(self, context, request):
        super(EditAction, self).__init__(context, request)
        self.form_fields = grok.AutoFields(context.__class__)

Cheers,
--
Jasper Spaans

Fox-IT Experts in IT Security!                                 
I www.fox-it.com


More information about the Grok-dev mailing list