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 Edit(grok.EditForm): grok.context(Mammoth) form_fields = grok.Fields(IMammoth).omit('size')
class Edit2(grok.EditForm): grok.context(Mammoth2) form_fields = grok.AutoFields(Mammoth).omit('name')
class Index(grok.View): grok.context(Mammoth) def render(self): return 'Hi, my name is %s, and I\'m "%s"' % (self.context.name, self.context.size)
class Edit4(grok.EditForm): grok.context(IYetAnotherMammoth)
class Edit2(grok.EditForm): grok.context(Manfred)
class Edit(grok.EditForm): grok.context(Mammoth)
class Edit2(grok.EditForm): grok.context(Mammoth) form_fields = grok.AutoFields(Mammoth)