[Grok-dev] Add forms - one object type to multiple object types
Kevin Teague
kevin at bud.ca
Sat Mar 10 21:14:11 EST 2007
grok.context() declares what interfaces the View (or AddForm) can
adapt, so you do not have to pass it a Grok Component, instead you
can pass it an Interface. You can say that an AddForm can be adapted
to any object with;
from zope import interface
class AddPage(grok.AddForm):
grok.context(interface.Interface) #base interface, applies to
all objects
This will work fine, although technically you are stating that your
AddForm works for anything, when it will only actually work for
Container objects. You can specify that your AddForm works with just
Containers by doing:
from zope.app.container.interfaces import IContainer
class AddPage(grok.AddForm):
grok.context(IContainer) # base container interface, only
applies to container objects
More information about the Grok-dev
mailing list