Skip to main content

Relations allows for the definition of sets of rules for validation, creation and lifetime of Archetypes references.

Project description

Relations Readme


Relations allows for the definition of sets of rules for
validation, creation and lifetime of Archetypes references.
Contained in each ruleset are components that make for the actual
rules logic.

Rulesets may be created and edited through the web (TTW).
Components implementing custom behaviour are easily added.


In Plone, click "Add/Remove Products" in the Plone Setup. Then select
Relations from the list of available products and click "Install".

Now click "Relations Library" in the Plone Setup portlet on the
left to visit the TTW configuration user interface.


As an example, add a ruleset by clicking "Add Ruleset" in the
library. Now choose a reasonable identification. Notice that
identifications are required to be unique among rulesets in your

Note: When you create a reference through a ruleset, the
relationship attribute of the reference is set to be the ruleset's
id. There's nothing that is different about how you use the
Archetypes Reference API when querying for referenced objects.
(However, references are created and deleted differently; namely
through function 'processor.process'.)

The ruleset's title is what is presented to the user in Plone.
Let's choose "Is Child Of" as the title of our ruleset, and
"isChildOf" as the identification.

After saving changes, click "Add New Item" and add a cardinality
constraint. Enter "Exactly Two" as the title and choose "2" for
both the minimum and the maximum number of targets.

At this point we still need another component so we can actually
make use of the "Is Child Of" ruleset. Add a "Portal Type
Constraint" and choose "Unrestricted" as its title. Click the
"Save" button and then the "Relations" tab that just appeared.
The form says "Edit Relations for Unrestricted", meaning that we
can from here add and remove "Is Child Of" references from our
Portal Type Constraint "Unrestricted" to any referenceable portal

Through our "Exactly Two" constraint we assert that we have
exactly two "parents".


Archetypes >= 1.4.0
Python 2.4

See also

Additional documentation is in the product's doc/ directory on the


This code was created for the ZUCCARO project. ZUCCARO is a
database framework for the Humanities developed by the Bibliotheca
Hertziana, Max-Planck Institute for Art History. For further
information, please visit

2008-09-10 Cris Ewing (cewing at u dot washington dot edu)

Fixed a bug in the finalizeOnConnect() method of
that left Shared Objects (association classes) cataloged by
portal_catalog. This caused attribute errors to be thrown by
methods called in Plone's sharing UI. (See for a detailed

Tagged 0.8.1 bugfix release, posted egg to cheeseshop.

2008-05-28 Alex Clark (aclark at aclark dot net)


2007-06-25 Jens Klein (jens at bluedynamics dot com)

we added events to relations on each connect and disconnect.
within this implementation some cleanup were done.
the events are used for exampe by RelationsIndex, but you
can subscribe to them also to fulfill task need to be done
on connect or disconnect.

2007-02-25 Philipp Auersperg (phil at

allowedTypesByInterface now also supports zope3 interfaces

2006-03-30 Daniel Nouri <daniel (dot) nouri at gmail (dot) com> (adddeleteVocab): I put the ``adddelete_vocab`` script
onto the filesystem while adding a check for
``ModifyPortalContent`` on context. The Python script still
exists, but it's only an alias now. Also added tests, which the
script didn't have.

2006-03-01 Jens Klein <> i18n moved in Archetypes 1.4 to

2006-02-04 Daniel Nouri <dpunktnpunkt at>

tests: Added more tests to check if multiple refs per triple
(i.e. same source, target, relationship) are working. (Note that
this currently requires the dpunktnpunkt-multipleref branch of
Archetypes and that it's disallowed by default.

2006-01-28 Daniel Nouri <dpunktnpunkt at>

components/ (InverseImplicator.implyOnDisconnect):
Improvement of implementation.

2006-01-26 Daniel Nouri <dpunktnpunkt at>

components/ (InverseImplicator): New implementation
that no longer assumes that there's only one reference with the
same relationship between two objects. (IRuleset.implyOnConnect): No longer care about
whether a reference with the same triple of (source, target,
relationship) already exists. (ALLOW_MULTIPLE_REFS_PER_TRIPLE): Added configuration
option for updateReferences argument of
ReferenceEngine.addReference. It's turned off by default. (IRuleset.implyOnConnect)
(IPrimaryImplicator.connect): Added metadata keyword argument that
lets you provide attributes for the reference. Note that this is
subject to change and will probably be moved out of the public
API. (IReferenceConnectionProcessor.process): Elements
of ``disconnect`` may also be UIDs of reference objects.

2005-11-22 Jens Klein <>

fixed hiding of tools from navigation and tabs

2005-08-10 Daniel Nouri <dpunktnpunkt at> (Library.__implements__): Fixed the faulty
IActionProvider implementation of Library.

2005-07-20 Daniel Nouri <dpunktnpunkt at>

components/ Applied patch by David Baehrens that
allows us to define source cardinality with CardinalityConstraint.

2005-07-07 Daniel Nouri <dpunktnpunkt at> (XMLImportExport.schema): Use the accessor as the
default_method. (AllowedTypesByIface._verifyObjectPaste): Use
PortalFolderBase's _verifyObjectPaste as we're actually not
inheriting from PortalFolder.

tests/ (TestRuleset.testRenameRulesetInLibrary):
Import transaction instead of using the global get_transaction. (process): Import transaction instead of using the
global get_transaction.

2005-06-03 Daniel Nouri <dpunktnpunkt at>

components/ (ContentReferenceFinalizer):
Added isPrimary attribute to CRF.

2005-05-28 Daniel Nouri <dpunktnpunkt at>

Extensions/ (install_tools): Don't add library to

2005-05-18 Daniel Nouri <dpunktnpunkt at>

skins/relations/, model/*, tests/relations_sample.xml,
tests/, doc/Overview.txt,,,
Merged relations_xml_import_export branch. Adds import/export
capabilities to Rules, Rulesets, Library and RulesetCollections.

2005-02-21 Daniel Nouri <dpunktnpunkt at> (IRuleset.getComponents): This replaces the earlier
private _filterByInterface. (IRuleset.listActionsFor): Added a method which I
forgot to put in the interface earlier. (IVocabularyProvider.getSearchTerms): This should allow
us to interface with ATReferenceBrowserWidget in a reasonable manner.

components/ (PortalTypeConstraint.getSearchTerms):
Comply with IVocabularyProvider.getSearchTerms .

2005-02-16 Daniel Nouri <dpunktnpunkt at>

doc/Overview.txt: Doctest examples.

2005-02-06 Daniel Nouri <dpunktnpunkt at>

doc/Overview.txt: Added Developer's Documentation. More to
come. Cleaned up a bit.

2005-02-02 Daniel Nouri <dpunktnpunkt at> Slimmed by removing reimplemented methods
_Vocabulary and Vocabulary of ReferenceField. The field's purpose
needs to be made clear, still. See XXX comments.

2005-01-27 Daniel Nouri <dpunktnpunkt at> (RulesetCollection): Implemented a "Ruleset Collection"
type that allows to categorise Rulesets inside the Library. (RulesetAwareContainer): Factored out methods
invokeFactory and _setObject of Library into class

2005-01-25 Daniel Nouri <dpunktnpunkt at>

*: Massive renaming. 'Jig' becomes 'Ruleset',
'ReferenceJigRegistry' becomes 'Library' etc. These changes not
only affect portal type names, but also classes & variables.
These changes are not backwards compatible (i.e., no way to
migrate) and they're not tested thoroughly.

2005-01-13 Daniel Nouri <dpunktnpunkt at> (ReferenceJig.listActionsFor): Remove duplicate actions.

skins/relations/ Added helper script for
'relations_form', which now lists existing refs along with their
actions. 'relations_form' still needs improvement. (IReferenceActionProvider): Added subtype of

2005-01-08 Daniel Nouri <dpunktnpunkt at>

skins/relations/relations_form.cpt: Added an overview form that will
list existing references.

skins/relations/relations_adddelete.cpt: Renamed from relations_form. (getReferenceableTypes): Added function that returns a list
of portal type strings of all referenceable types.

Extensions/ (install_tools): Fixed metaTypesNotToList
feature on install, which wasn't using the right meta_type.

2005-01-02 Daniel Nouri <dpunktnpunkt at>

components/, tests/ Added
component "ContentReferenceFinalizer", which associates portal objects
with references. (ReferenceJig._forEachDo): Prevent acquiring method from self
if it's not implemented in the component.

2005-01-01 Daniel Nouri <dpunktnpunkt at>

Extensions/ (install_tools): Fixed hiding in navtree; check
for the existance of a 'portal_properties.navtree_properties' to not
break all tests. :-) (makeBrainAggrFromBrain): More explanatory exception message
when no metadata could be found in a source.

2004-10-21 Daniel Nouri <>

tests/*: Removed calls to CMFTestCase.setupCMFSite(), which were done
too early.

2004-10-15 Daniel Nouri <>

COPYRIGHT, LICENSE: Added copyright information. (ReferenceJigRegistry._setObject): Copied referencejigs are
registered properly now.

2004-10-05 Daniel Nouri <> (ReferenceJigSchema): Added 'about' field to referencejig's

2004-10-04 Daniel Nouri <> (ReferenceJigRegistry.getJig): Restored old way of looking
up a jig by its id, which involves two catalog lookups. 'targetId'
index of 'reference_catalog' seems to be broken.

This fixes a bug where renaming a jig would cause a lookup to fail.

README.txt: Revamped README. Also, some minor code changes according
to new terms.

2004-10-02 Daniel Nouri <> (ReferenceJigRegistry.getJigs): Made ReferenceJigRegistry
an OrderedBaseFolder. 'getJigs' now returns jigs in the order in which
they appear in the registry. (ReferenceJig._afterRename): Set relationship attribute for
references that belong to us on rename. (ReferenceJigRegistry._setObject): Added function only
to assist ReferenceJig in finding out when it is renamed. (ReferenceJig.implyOnConnect): When connecting, we now put up
a reference between the jig and the ref.

tests/ (TestReferenceJig.testRenameJigInRegistry): Test
the new 'referencejig rename -> ref relationship attrs change'

tests/ (TestReferenceJig.testForward): Fixed bug with a
ref catalog search.

2004-09-25 Daniel Nouri <>

tests/ (TestJigRegistry.testRenameRegistry): Added test
to ensure that the jig registry may not be renamed. Added module: Schema definitions for jig module, and other
common schemas. (AllowedTypesByIface._verifyObjectPaste): Use _setObject
of 'portal_types' instead of setattr. This fixes renaming of jigs and
components yet again.

2004-09-24 Daniel Nouri <>

components/ (PortalTypeConstraint.makeVocabulary): Fixed bug
where filtering a vocabulary would behave differently than creating it.

2004-09-22 Daniel Nouri <> (AllowedTypesByIface._verifyObjectPaste): A temporary and
rather hackish solution for a bug that would hinder renaming jigs
and components.
AllowedTypesByIface feels more and more like a hack.

tests/ (TestReferenceJig.testRenameJigInRegistry): Added
test for the jig/component rename bug.

Extensions/ (uninstall): Working around a bug with
QuickInstaller thinking we own ['mimetypes_registry',
'portal_transforms', 'archetype_tool', 'uid_catalog',

2004-09-20 Daniel Nouri <>

skins/relations/relations_form_security.vpy: Added check for
'Modify portal content' permission when using 'relations_form'.

skins/relations/ Removed vocabulary logic
out of PT. The result is this somewhat bloated script. (makeBrainAggregate): Made function public. (ReferenceJigRegistry.listActions): We want to check for
'Modify portal content' permission for the 'Relations' action. (isReferenceable): Added new TTW method to assist

2004-09-19 Daniel Nouri <> (ValidationException): Added class level attribute
__allow_access_to_unprotected_subobjects__, fixing a severe bug with

skins/relations/relations_form.cpt: Display error messages in the
orange box.

2004-09-16 Daniel Nouri <> (ReferenceJigRegistry.listActions): Made ReferenceJigRegistry
an ActionProvider. All referenceable objects have a 'relations' action
now. (process): Made function public. (ValidationException): Made exception class public.

skins/relations/*, TODO: Added form for creating references through
'processor.process'. Removed TODO item for such a form, added one
for i18n. (ReferenceJigRegistry.invokeFactory): Moved automatic
registration of jigs from _setObject to invokeFactory.

components/ (PortalTypeConstraint.makeVocabulary): Fixed a
bug where this method would return [] if allowed target types were the
empty list.

2004-09-10 Daniel Nouri <>

components/ (CardinalityConstraint.doValidate): Renamed
validate to doValidate to avoid nameclash with 'BaseObject.validate'.

2004-09-07 Daniel Nouri <> (ReferenceJig, ReferenceJigRegistry): Added class docstring.
Zope returned 404s because of this.

TODO, (ReferenceJig, ReferenceJigRegistry): ReferenceJig's
and ReferenceJigRegistry's type titles are now "Reference Rulebook" and
"Rulebook Library" respectively.

2004-09-06 Daniel Nouri <>,, components/*: Removed `jig' argument from
all calls to IJigComponents. Extended IJigComponent and added a new
superclass JigComponentBase providing a `getJig' method., (IReferenceJig): IReferenceJig.makeVocabulary
now accepts an optional `targets' argument. Targets, which has a
default value of None, is forwarded to the first IVocabularyProvider.
No changes to IVocabularyProvider necessary. (AllowedTypesByIface): A superclass for ReferenceJig and
ReferenceJigRegistry that alters PortalFolder's allowedContentTypes
and invokeFactory behaviour. Method `allowedContentTypes' was a module
level function before. I had to add invokeFactory. (JigComponentBase): Added global_allow = 0. Subclasses are
now by default only addable inside ReferenceJigs.

tests/ Deleted. These types were not in use anywhere.

TODO: Added two items.

2004-08-22 Daniel Nouri <> (process): Changed interface of processor from seperate
processConnection and processDisconnection to one process function
with optional connect and disconnect arguments.

Changed 7 tests to reflect these changes.

2004-08-19 Daniel Nouri <>

components/ Added 'Inverse Implicator' component.

tests/ (TestInverseImplicator): Test for
InverseImplicator. Changed BrainAggregate to use __getattr__ instead of
relying on acquisition to get uid brain's attributes.

2004-08-17 Daniel Nouri <>

components/ (CardinalityConstraint): Added

tests/ (TestCardinalityConstraint): Test for

components/ (InterfaceConstraint): Added InterfaceConstraint:
A validator/vocab provider based on PortalTypeConstraint that checks
for interfaces rather than types.

tests/ (TestInterfaceConstraint): Added test.

2004-08-16 Daniel Nouri <> Use a subtransaction and abort it for both
processConnection and processDisconnection if an exception is thrown.

components/ A validator and vocab provider that restricts
types of source and target.

tests/ Test components in module components.

2004-08-15 Daniel Nouri <>

tests/ (createObjects, createJig): Factored out of

tests/ Test for processConnection and

2004-08-11 Daniel Nouri <>

TODO: Added file.

Added jig as the first argument to every component call. Updated
interfaces and tests accordingly.

2004-08-10 Daniel Nouri <>

tests/ (TestJigRegistry.testAllowedContentTypes): Added. (ReferenceJigRegistry.allowedContentTypes): Override
allowedContentTypes in Jig Registry as well to the effect that we
are now able to add any type of objects that implement the
IReferenceJig interface from the UI. Added. (allowedContentTypesByInterface): Refactored
allowedContentTypes of ReferenceJig into this.

Extensions/, Extensions/ Add ReferenceJigRegistry
to Plone configlets.

2004-08-03 Daniel Nouri <> Modified behaviour of IPrimaryImplicator's connect
and disconnect methods. They now return None if they didn't add or
delete the reference because it was already there or deleted

tests/ (TestReferenceJig.testDefaultPrimaryImplicator):

2004-08-01 Daniel Nouri <> (ReferenceJigRegistry): Made ReferenceJigRegistry an AT
BaseFolder instead of an OFS.Folder. ReferenceJigRegistry will serve
as a folderish UI for adding jigs.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Products.Relations-0.8.1.tar.gz (85.4 kB view hashes)

Uploaded source

Built Distribution

Products.Relations-0.8.1-py2.4.egg (161.3 kB view hashes)

Uploaded 2 4

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page