class AddMammoth(grok.AddForm): grok.context(Zoo) form_fields = grok.AutoFields(Mammoth) @grok.action('Add entry') def add(self, **data): # pass data into Mammoth constructor self.context['manfred'] = manfred = Mammoth(**data) self.redirect(self.url(manfred))
class AddMammoth(grok.AddForm): grok.context(Zoo) form_fields = grok.AutoFields(IMammoth) @grok.action('Add entry') def add(self, **data): self.context['ellie'] = ellie = Mammoth() if self.applyData(ellie, **data): return 'There were changes according to applyData.' return 'There were no changes according to applyData.'
class Edit2(grok.EditForm): grok.context(Mammoth2) form_fields = grok.AutoFields(Mammoth).omit('name')
class Edit(grok.EditForm): grok.context(Mammoth) form_fields = grok.AutoFields(Mammoth).omit('size')
class Edit(grok.EditForm): form_fields = grok.AutoFields(IMammoth)
class Edit2(grok.EditForm): grok.context(Mammoth) form_fields = grok.AutoFields(Mammoth)