diff --git a/compound/README.txt b/compound/README.txt new file mode 100644 index 0000000..2300efd --- /dev/null +++ b/compound/README.txt @@ -0,0 +1,6 @@ +=============================================================== +loops - Linked Objects for Organization and Processing Services +=============================================================== + + ($Id$) + diff --git a/compound/__init__.py b/compound/__init__.py new file mode 100644 index 0000000..4bc90fb --- /dev/null +++ b/compound/__init__.py @@ -0,0 +1,4 @@ +""" +$Id$ +""" + diff --git a/compound/base.py b/compound/base.py new file mode 100644 index 0000000..6193c0b --- /dev/null +++ b/compound/base.py @@ -0,0 +1,24 @@ +# +# Copyright (c) 2008 Helmut Merz helmutm@cy55.de +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +""" +Compound objects like articles, blog posts, storyboard items, ... + +$Id$ +""" + diff --git a/compound/interfaces.py b/compound/interfaces.py new file mode 100644 index 0000000..8a9a923 --- /dev/null +++ b/compound/interfaces.py @@ -0,0 +1,61 @@ +# +# Copyright (c) 2008 Helmut Merz helmutm@cy55.de +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +""" +Compound objects like articles, blog posts, storyboard items, ... + +$Id$ +""" + +from zope.interface import Interface, Attribute +from zope import interface, component, schema + +from loops.util import _ + + +class ICompound(Interface): + """ A compound is a concept that is built up of other objects, its + components. + + These components are typically resources, but may also be other + concepts that should provide the ICompound interface as their + type interface. The components are assigned in an ordered way + so that the components are accessed in a reproducible order. + + The components are bound to the compound via standard resource + or concept relations using a special predicate, ``ispartof``. + """ + + components = Attribute('Objects (resources or other compounds) that ' + 'this object consists of') + + def add(obj, position=None): + """ Add a component to the compound. + + If the ``position`` argument is None, append it to the end + of the current list of components, otherwise insert it before + the position given. The numbering of the positions is like for + Python lists, so 0 means before the first one, -1 before the + last one. + """ + + def reorder(components): + """ Change the order settings of the relations that connect the + components given (a sequence) to the compound so that they are + ordered according to this sequence. + """ diff --git a/compound/tests.py b/compound/tests.py new file mode 100755 index 0000000..644d326 --- /dev/null +++ b/compound/tests.py @@ -0,0 +1,24 @@ +# $Id$ + +import unittest, doctest +from zope.testing.doctestunit import DocFileSuite +from zope.app.testing import ztapi +from zope.interface.verify import verifyClass + + +class Test(unittest.TestCase): + "Basic tests for the loops.compound package." + + def testSomething(self): + pass + + +def test_suite(): + flags = doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS + return unittest.TestSuite(( + unittest.makeSuite(Test), + DocFileSuite('README.txt', optionflags=flags), + )) + +if __name__ == '__main__': + unittest.main(defaultTest='test_suite') diff --git a/constraint/README.txt b/constraint/README.txt new file mode 100644 index 0000000..2300efd --- /dev/null +++ b/constraint/README.txt @@ -0,0 +1,6 @@ +=============================================================== +loops - Linked Objects for Organization and Processing Services +=============================================================== + + ($Id$) + diff --git a/constraint/__init__.py b/constraint/__init__.py new file mode 100644 index 0000000..4bc90fb --- /dev/null +++ b/constraint/__init__.py @@ -0,0 +1,4 @@ +""" +$Id$ +""" + diff --git a/constraint/base.py b/constraint/base.py new file mode 100644 index 0000000..38f3c88 --- /dev/null +++ b/constraint/base.py @@ -0,0 +1,25 @@ +# +# Copyright (c) 2008 Helmut Merz helmutm@cy55.de +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +""" +Constraint definitions for restricting concepts and predicates available +for assignment as children or as concepts to resources. + +$Id$ +""" + diff --git a/constraint/interfaces.py b/constraint/interfaces.py new file mode 100644 index 0000000..a965708 --- /dev/null +++ b/constraint/interfaces.py @@ -0,0 +1,86 @@ +# +# Copyright (c) 2007 Helmut Merz helmutm@cy55.de +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +""" +Constraint definitions for restricting concepts and predicates available +for assignment as children or as concepts to resources. + +Constraints may be used to build up an ontology, in the sense of a +ruleset that governs the possible relationships between objects. + +$Id$ +""" + +from zope.interface import Interface, Attribute +from zope import interface, component, schema + +from loops.util import _ + + +class IConstraint(Interface): + """ A constraint is an adapter for concepts and resources and + provides information on which relations are allowed for its + client object. + + When the client object is a concept the constraint checks + for child relations, if it is a resource it checks for concept + relations. In order to check for allowed parent relations (on + a concept only) you may specify ``relationType=parent`` + on the method calls. + """ + + client = Attribute('Object that will be checked for allowed relations.') + + def isRelationAllowed(concept, predicate, relationType=None): + """ Return True if this constraint allows the assignment of a + relation to the client object specified by the target concept + and the predicate given. + """ + + def getAllowedPredicates(relationType=None): + """ Return a sequence of concepts of type ``predicate`` that + may be used for assigning concepts to the client object. + """ + + + def getAllowedConcepts(predicate, candidates=None, relationType=None): + """ Return an iterable of concepts that - according to this + constraint - may be assigned to the client object via the + predicate given. + + If given, use candidates as a list of concepts from + which to select the allowed targets. + """ + + +class IStaticConstraint(IConstraint): + """ Provides a statically assigned contstraint setting. + + Typically used as a concept adapter for a persistent constraint + that allows editing of predicates, target types and cardinality + of allowed relationships. + """ + + relationType = schema.TextLine() + + predicates = schema.List() + + types = schema.List() + + cardinality = schema.List() + diff --git a/constraint/tests.py b/constraint/tests.py new file mode 100755 index 0000000..95f8a86 --- /dev/null +++ b/constraint/tests.py @@ -0,0 +1,24 @@ +# $Id$ + +import unittest, doctest +from zope.testing.doctestunit import DocFileSuite +from zope.app.testing import ztapi +from zope.interface.verify import verifyClass + + +class Test(unittest.TestCase): + "Basic tests for the loops.constraint package." + + def testSomething(self): + pass + + +def test_suite(): + flags = doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS + return unittest.TestSuite(( + unittest.makeSuite(Test), + DocFileSuite('README.txt', optionflags=flags), + )) + +if __name__ == '__main__': + unittest.main(defaultTest='test_suite')