[Grok-dev] object relationships

Jeroen Michiel jmichiel at yahoo.com
Thu Mar 5 07:20:09 EST 2009

My how-to is getting close to being finished, however, I'm running into some
I'm trying to hide the relation inside the implementation by doing this:

class IBuddy(Interface):
    name = schema.TextLine(title=u'The Name')
    buddy = schema.Choice(title=u'My Buddy', required=False, source =

class Buddy(grok.Model):
    grok.implements(IBuddy, IHasRelations)
    buddy_rel = Relation()
    def setBuddy(self, obj):
        intids = component.getUtility(IIntIds)
        self.buddy_rel = RelationValue(intids.queryId(obj))
        print 'Buddy Set: %s' % self.buddy_rel
    def getBuddy(self):
        return self.buddy_rel.to_object
    buddy=property(getBuddy, setBuddy)

as opposed to this:
class IBuddy(Interface, IHasRelations):
    name = schema.TextLine(title=u'The Name')
    buddy = RelationChoice(title=u'My Buddy', required=False, source =

class Buddy(grok.Model):

However, with the relation now being part of the implementation, the
_potential_relations function in z3c.relationfield.event no longer returns
the relations as the getFields function doesn't find a field providing
IRelation. It's no longer inside an interface...

I guess I will first have to subclass the interface and then implement that
View this message in context: http://www.nabble.com/object-relationships-tp21706997p22350542.html
Sent from the Grok mailing list archive at Nabble.com.

More information about the Grok-dev mailing list