new loops subpackage 'integrator' for importing and integrating operating system files and other external objects

git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@1682 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
helmutm 2007-04-10 14:56:48 +00:00
parent 2b250fce37
commit 503370574c
6 changed files with 152 additions and 0 deletions

35
integrator/README.txt Normal file
View file

@ -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()

4
integrator/__init__.py Normal file
View file

@ -0,0 +1,4 @@
"""
$Id$
"""

View file

@ -0,0 +1,9 @@
<!-- $Id$ -->
<configure
xmlns:zope="http://namespaces.zope.org/zope"
xmlns:browser="http://namespaces.zope.org/browser"
i18n_domain="zope"
>
</configure>

32
integrator/interfaces.py Normal file
View file

@ -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.
"""

23
integrator/tests.py Executable file
View file

@ -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')

49
integrator/testsetup.py Normal file
View file

@ -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