[Grok-dev] How to use auto-forms to quickly handle nested objects

Tim Cook timothywayne.cook at gmail.com
Sun Mar 22 07:45:09 EDT 2009

Hi Steve,

In case you missed it, I think this may help

It is an approach I'll be trying over the next few days with a probelm
that is similar to yours.


On Sat, 2009-03-21 at 21:19 -0700, Steve Schmechel wrote:
> If you have a "grok.Model based" object that contains one or more collections of other "grok.Model based" objects, is there are way to quickly represent this hierarchy using auto-forms?
> I cannot find any examples of this nested structure in tutorials, how-to's, or example applications.  This would seem to be a natural layout for many object domains.  
> Is this generally handled differently?  Is everything handled as "annotations"?  Is everything jammed in the main application "grok.Container" and then located as needed using separate indexes/catalogs?
> Take, for example, the mammoth example in:
> http://grok.zope.org/documentation/tutorial/work-with-forms
> Mammoth(grok.Model) objects are stored in the MammothApplication(grok.Application, grok.Container) and auto-forms are used to view, add and edit mammoths.
> If a caveman wanted to track how much food his mammoth was consuming, we might have a collection of "feedings" for a given mammoth.  Each "feeding" object would have attributes/fields for the "type of food" and the "weight".  For simplicity, both attributes could be just user-entered text but the feeding should be derived from grok.Model (not a list of string pairs or something like that).
> It appears that zope.schema has a "Container" type and a "Dict" type.  
> (grok.Container would map to Dict???)
> Assuming we just want to be able to record the feedings and be able to view a simple listing of feedings for a given mammoth, what would be the quickest way to do this? 
> Can the auto-forms generate an "add" button on the Mammoth auto-form that takes you to a "grok.AddForm" for a Feeding?  Can the auto-form simply generate a hyper-link when displaying the "Feedings" field (grok.Container), so that you can navigate to that object and render a view/template that lists the individual feedings?
> I know all of this is rather basic and wouldn't make for a great user interface, but it would allow you to quickly prototype your content objects.
> I believe the whole "custom widgets" and "multi-adapters" route is probably the right way to do this sort of thing.  But it is a lot for a newbie to get their head around and I haven't seen any simple examples applied in any tutorials.
> Any advice is appreciated.  I will include what I learn in a tutorial that I am writing.  I really just need to be steered in the right direction.
> Thanks,
> Steve
> _______________________________________________
> Grok-dev mailing list
> Grok-dev at zope.org
> http://mail.zope.org/mailman/listinfo/grok-dev
Timothy Cook, MSc
Health Informatics Research & Development Services
LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook 
Skype ID == timothy.cook 
*You may get my Public GPG key from  popular keyservers or   *
*from this link http://timothywayne.cook.googlepages.com/home*
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://mail.zope.org/pipermail/grok-dev/attachments/20090322/ab9c6912/attachment.bin 

More information about the Grok-dev mailing list