[Grok-dev] object relationships

Martijn Faassen faassen at startifact.com
Fri Feb 13 15:23:43 EST 2009


Hey,

I'm glad the basics work now. I was able to encapsulate the choice 
behavior quite nicely without too little code. The trick was to derive a 
new RelationChoice field so that the relation is actually indexed 
properly and so you can pass a source to it. The other trick was to 
create a new source factory that you can easily supply with a list of 
targets.

Jeroen Michiel wrote:
[snip]
> I still have a small issue if I want to remove my app:
>  File
> "c:\docume~1\jm\.buildout\eggs\z3c.relationfield-0.4.1-py2.4.egg\z3c\relationfield\event.py",
> line 36, in removeRelations
>     catalog = component.getUtility(ICatalog)
>  File
> "C:\Docume~1\jm\.buildout\eggs\zope.component-3.4.0-py2.4.egg\zope\component\_api.py",
> line 207, in getUtility
>     raise ComponentLookupError(interface, name)
> ComponentLookupError: (<InterfaceClass zc.relation.interfaces.ICatalog>, '')
> 
> It seems the catalog is unregistered before the objects are removed, or
> something of that nature...

Yes, it must be some deregistration order issue. I've seen those before 
in other contexts.. I think the issue could be fixed by placing some 
fallback behavior in event.py so that if the catalog is missing things 
will proceed without error. Send me a patch or remind me to look at it 
again. :)

> At least I can write a nice how-to now!

Great!

> BTW: I had already found a nicer way to use a regular choice field with a
> relation than what I described before, but I'll put it in the how-to as
> well.

I'd be interested in learning about this too.

> Speaking of how-to's: I already made a how-to on zc.sourcefactory that I
> submitted for reviewing, but it hasn't been reviewed yet. Do I need to do
> anything more? Or is this no longer the way how-to's should be submited?

Oh, just make noise on this list when you have something to review, I 
don't think we have people watching what there is to review...

I'll look at it now. That looks like a very nice introduction, so I'll 
publish it right away. Thanks very much for writing it, I think people 
will be helped by this.

Regards,

Martijn



More information about the Grok-dev mailing list