[Grok-dev] object relationships

Jeroen Michiel jmichiel at yahoo.com
Wed Jan 28 09:39:14 EST 2009


I'm trying to use relationships between my models, but I'm a bit confused at
what to use...
This is my problem: I got models A B and C, and both objects of type B and C
should carry a relationship to an object of type A. Now I want to be able
for any given object B to get me a list of all C type objects that refer to
the same A type object as my current B type object. I should also be able to
make these relationships with forms.

I've done some browsing on PyPI, and zc.relation seems the most appropriate
package for the relations themselves. As for the forms I've noticed the
z3c.relationfield and z3c.relationfieldui packages, and though I seem to get
them to 'work', I don't understand it all.

First of all, is this the way to go, or are there other packages that are
better suited?

If so, I don't understand how the widget is supposed to work, and how I can
use another one. 
If you use the default and generate an AddForm, you get a textfield and a
button that shows a popup to a view that should be called 'explorerurl'. But
that's where I get stuck: how is this view supposed to return me a reference
to the object I want to refer to? Javascript, a HTTP POST ... I'm a bit lost
here, you see...
But then, what I would really like, is just a listbox with the possible
object to refer to. Can I do this by setting the value_type to a Choice with
a source (apparently not: unexpected keyword argument 'value_type') ?

If anyone can help me get this working, I'm willing to make a how-to of it.
View this message in context: http://www.nabble.com/object-relationships-tp21706997p21706997.html
Sent from the Grok mailing list archive at Nabble.com.

More information about the Grok-dev mailing list