[Grok-dev] REPOST Re: Add Form URLS
Sebastian Ware
sebastian at urbantalk.se
Sat Jan 24 12:58:59 EST 2009
24 jan 2009 kl. 18.48 skrev Tim Cook:
> class AddEhr(grok.AddForm):
> grok.context(Ehr)
> form_fields = grok.AutoFields(Ehr)
>
> @grok.action('Add event')
> def add(self,**data):
> ehr001 = Ehr(**data)
def add(self, **data):
new_obj = Ehr() # Create a new object
self.applyData(new_obj, **data) # Apply the changes (unless they
were supplied in the line above)
self.context[key] = new_obj # Store the object with a key of your
choice (think ordinary dictionary)
Are you aware that you need a root container subclassing
grok.Application in order to be able to add an application to your
Grok instance? This is also behaves like a dictionary, but
grok.Application, unlike grok.Container, kan be populated during
__init__. In other words, you can add your root Ehr object when you
are creating your app.
Mvh Sebastian
More information about the Grok-dev
mailing list