diff --git a/integrator/README.txt b/integrator/README.txt new file mode 100644 index 0000000..2c931f1 --- /dev/null +++ b/integrator/README.txt @@ -0,0 +1,35 @@ +=============================================================== +loops - Linked Objects for Organization and Processing Services +=============================================================== + +Integration of external sources. + + ($Id$) + + +Setting up a loops Site and Utilities +===================================== + +Let's do some basic set up + + >>> from zope import component, interface + >>> from zope.traversing.api import getName + >>> from zope.app.testing.setup import placefulSetUp, placefulTearDown + >>> site = placefulSetUp(True) + +and build a simple loops site with a concept manager and some concepts +(with a relation registry, a catalog, and all the type machinery - what +in real life is done via standard ZCML setup or via local utility +configuration): + + >>> from loops.integrator.testsetup import TestSite + >>> t = TestSite(site) + >>> concepts, resources, views = t.setup() + + >>> len(concepts) + len(resources) + 18 + +Fin de partie +============= + + >>> placefulTearDown() diff --git a/integrator/__init__.py b/integrator/__init__.py new file mode 100644 index 0000000..4bc90fb --- /dev/null +++ b/integrator/__init__.py @@ -0,0 +1,4 @@ +""" +$Id$ +""" + diff --git a/integrator/configure.zcml b/integrator/configure.zcml new file mode 100644 index 0000000..cc0be03 --- /dev/null +++ b/integrator/configure.zcml @@ -0,0 +1,9 @@ + + + + + diff --git a/integrator/interfaces.py b/integrator/interfaces.py new file mode 100644 index 0000000..99e4816 --- /dev/null +++ b/integrator/interfaces.py @@ -0,0 +1,32 @@ +# +# 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 +# + +""" +Intergrator interfaces. + +$Id$ +""" + +from zope.interface import Interface, Attribute +from zope import interface, component, schema + + +class IExternalCollection(Interface): + """ A collection of resources. + """ + diff --git a/integrator/tests.py b/integrator/tests.py new file mode 100755 index 0000000..7ff96d6 --- /dev/null +++ b/integrator/tests.py @@ -0,0 +1,23 @@ +# $Id$ + +import unittest, doctest +from zope.testing.doctestunit import DocFileSuite +from zope.interface.verify import verifyClass +#from loops.versioning import versionable + +class Test(unittest.TestCase): + "Basic tests for the expert sub-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/integrator/testsetup.py b/integrator/testsetup.py new file mode 100644 index 0000000..e315acf --- /dev/null +++ b/integrator/testsetup.py @@ -0,0 +1,49 @@ +""" +Set up a loops site for testing. + +$Id$ +""" + +from zope import component +from zope.app.catalog.catalog import Catalog +from zope.app.catalog.interfaces import ICatalog +from zope.app.catalog.field import FieldIndex +from zope.app.catalog.text import TextIndex + +from cybertools.relation.tests import IntIdsStub +from cybertools.relation.registry import RelationRegistry +from cybertools.relation.interfaces import IRelationRegistry +from cybertools.relation.registry import IndexableRelationAdapter +from cybertools.typology.interfaces import IType + +from loops import Loops +from loops import util +from loops.interfaces import IIndexAttributes +from loops.concept import Concept +from loops.concept import IndexAttributes as ConceptIndexAttributes +from loops.resource import Resource +from loops.resource import IndexAttributes as ResourceIndexAttributes +from loops.integrator.interfaces import IExternalCollection +from loops.knowledge.setup import SetupManager as KnowledgeSetupManager +from loops.setup import SetupManager, addObject +from loops.tests.setup import TestSite as BaseTestSite +from loops.type import ConceptType, ResourceType, TypeConcept + + +class TestSite(BaseTestSite): + + def __init__(self, site): + self.site = site + + def setup(self): + component.provideAdapter(KnowledgeSetupManager, name='knowledge') + concepts, resources, views = self.baseSetup() + + tType = concepts.getTypeConcept() + + tExtFile = concepts['extfile'] = Concept(u'External File') + tExtCollection = concepts['extcollection'] = Concept(u'External Collection') + + self.indexAll(concepts, resources) + return concepts, resources, views +