zc.relationship

HomePage: UNKNOWN

Author: Zope Project

Download: https://pypi.python.org/packages/source/z/zc.relationship/zc.relationship-1.1.1.tar.gz

        =======
CHANGES
=======

1.1
===

(supports Zope 3.4/Zope 2.11/ZODB 3.8)

1.1.1
-----

- Add support for both ZODB 3.7 and ZODB 3.8 via a small import location
  monkey patch.

- Fix name errors caught by pyflakes.

1.1.0
-----

- adjust to BTrees changes in ZODB 3.8 (thanks Juergen Kartnaller)

- converted buildout to rely exclusively on eggs  

1.0
===

(supports Zope 3.3/Zope 2.10/ZODB 3.7)

1.0.2
-----

- Incorporated tests and bug fixes to relationship containers from
  Markus Kemmerling:

  * ManyToOneRelationship instantiation was broken
  
  * The `findRelationships` method misbehaved if both, `source` and `target`,
    are not None, but `bool(target)` evaluated to False.
    
  * ISourceRelationship and ITargetRelationship had errors.

1.0.1
-----

(supports Zope 3.3/Zope 2.10/ZODB 3.7)

- Incorporated test and bug fix from Gabriel Shaar:

  if the target parameter is a container with no objects, then
  `shared.AbstractContainer.isLinked` resolves to False in a bool context and
  tokenization fails.  `target and tokenize({'target': target})` returns the
  target instead of the result of the tokenize function.

- Made README.txt tests pass on hopefully wider set of machines (this was a
  test improvement; the relationship index did not have the fragility).
  Reported by Gabriel Shaar.

1.0
---

(supports Zope 3.3/Zope 2.10/ZODB 3.7)

Initial release

========
Overview
========

The Relationship package currently contains two main types of components: a
relationship index, and some relationship containers.  Both are designed for
use within the ZODB.  They share the model that relationships are full-fledged
objects that are indexed for optimized searches.  They also share the ability
to perform optimized intransitive and transitive relationship searches, and
to support arbitrary filter searches on relationship tokens.

The index is a very generic component that can be used to optimize searches
for N-ary relationships, can be used standalone or within a catalog, can be
used with pluggable token generation schemes, and generally tries to provide
a relatively policy-free tool.  It is expected to be used primarily as an
engine for more specialized and constrained tools and APIs.

The relationship containers use the index to manage two-way
relationships, using a derived mapping interface.  It is a reasonable
example of the index in standalone use.

This document describes the relationship index.  See container.txt for
documentation of the relationship container.

=====
Index
=====

The index interface searches for object and relationship tokens. To use a
relationship index, you need to have interface attributes, or methods callable
with no arguments, that are treated as relationship pointers.  The pointers
may be a collection of items or a single item.

To exercise the index, we'll come up with a somewhat complex relationship to
index. Let's say we are modeling a generic set-up like SUBJECT
RELATIONSHIPTYPE OBJECT in CONTEXT.  This could let you let users define
relationship types, then index them on the fly.  The context can be something
like a project, so we could say

"Fred" "has the role of" "Project Manager" on the "zope.org redesign project".

Mapped to the parts of the relationship object, that's

["Fred" (SUBJECT)] ["has the role of" (RELATIONSHIPTYPE)]
["Project Manager" (OBJECT)] on the ["zope.org redesign project" (CONTEXT)].

Without the context, you can still do interesting things like

["Ygritte" (SUBJECT)] ["manages" (RELATIONSHIPTYPE)] ["Uther" (OBJECT)]

So let's define a basic interface without the context, and then an extended
interface with the context.

    >>> from zope import interface
    >>> class IRelationship(interface.Interface):
    ...     subjects = interface.Attribute(
    ...         'The sources of the relationship; the subject of the sentence')
    ...     relationshiptype = interface.Attribute(
    ...         '''unicode: the single relationship type of this relationship;
    ...         usually contains the verb of the sentence.''')
    ...     objects = interface.Attribute(
    ...