[Zope3-Users] searching and relations

Pete Taylor baldtrol at gmail.com
Fri Jul 21 10:21:41 EDT 2006


Lorenzo,
I've run into a very (very!) similar situation, and ended up writing
some wrapper/simplification utilities for zc.relationship.
zc.relationship is wonderfully powerful, but a bit complex.  It's use
is intuitive once you wade through the 2000+ lines of documentation
(which is worthwhile reading), but it's a bit intimidating at first.

I've packaged up my wrapper utilities as a product, and ZPL2.1'd the
code.  If you'd like it, even just for reference, let me know.  I
intend to release it more publicly shortly.  It implements nice
adapters, so objects implementing a particular marker interface can do
things like:

client = MyClient()
q = IQuestion(obj)
orders = q.ask_as_subject("owns")
orders
['<some.Order object at...>']

you can also build filter functions that take the relationship you're
targeting as an argument, and check any property of the relationship
in question...

let me know if you'd like a copy.  if not, then i'd suggest going
through at least the containers.txt in zc.relationship.

as far as the catalog goes, i'd get into using hurry.query as fast as
possible ;)

On 7/21/06, Lorenzo Gil Sanchez <lgs at sicem.biz> wrote:
> Hi,
>
> I've been following recent discussion about relations in Zope. Both
> intrinsic and extrinsic relationships.
>
> For the following question lets assume we have a IClient and an IOrder
> content types and the IOrder schema has a IClient attribute called 'client'.
>
> Reading previous messages to this list I understand that's the best way
> to model this kind of intrinsic relationship between an Order and a Client.
>
> Now the question: using a Catalog, what should I do to answer these kind
> of questions:
>
>   - Give me all orders whose client's name starts with 'John'
>
>   - Give me all orders whose client's age is between 20 and 30
>
>   - Give me all orders for a certain client
>
> I guess I need to use a special kind of FieldIndex for objects but I'm
> new to the Catalog land and I'm pretty much lost.
>
> Any help, examples or pointers to detailed doc are greatly appreciated :-)
>
> Best regards,
>
> Lorenzo Gil
> _______________________________________________
> Zope3-users mailing list
> Zope3-users at zope.org
> http://mail.zope.org/mailman/listinfo/zope3-users
>


-- 
"All guilt is relative, loyalty counts, and never let your conscience
be your guide."
  - Lucas Buck, American Gothic


More information about the Zope3-users mailing list