added expert package (for intelligent query and filter features)

git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@1635 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
helmutm 2007-03-10 11:06:00 +00:00
parent 3e62f36022
commit 28625c18c0
4 changed files with 138 additions and 0 deletions

81
expert/README.txt Normal file
View file

@ -0,0 +1,81 @@
===============================================================
loops - Linked Objects for Organization and Processing Services
===============================================================
The loops expert - knows what is in a loops site and how to make
use of it.
($Id$)
The query stuff depends on hurry.query, see
http://cheeseshop.python.org/pypi/hurry.query
Setting up a loops Site and Utilities
=====================================
Let's do some basic set up
>>> from zope.app.testing.setup import placefulSetUp, placefulTearDown
>>> site = placefulSetUp(True)
>>> from zope import component, interface
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):
>>> from cybertools.relation.tests import IntIdsStub
>>> component.provideUtility(IntIdsStub())
>>> from cybertools.relation.registry import RelationRegistry
>>> from cybertools.relation.interfaces import IRelationRegistry
>>> relations = RelationRegistry()
>>> relations.setupIndexes()
>>> component.provideUtility(relations, IRelationRegistry)
>>> from loops.type import ConceptType, TypeConcept
>>> component.provideAdapter(ConceptType)
>>> component.provideAdapter(TypeConcept)
>>> from zope.app.catalog.catalog import Catalog
>>> catalog = Catalog()
>>> from zope.app.catalog.interfaces import ICatalog
>>> component.provideUtility(catalog, ICatalog)
>>> from zope.app.catalog.field import FieldIndex
>>> from zope.app.catalog.text import TextIndex
>>> from loops.interfaces import IIndexAttributes
>>> catalog['loops_title'] = TextIndex('title', IIndexAttributes)
>>> catalog['loops_text'] = TextIndex('text', IIndexAttributes)
>>> catalog['loops_type'] = TextIndex('type', IIndexAttributes)
>>> from loops import Loops
>>> loopsRoot = site['loops'] = Loops()
>>> from loops.knowledge.setup import SetupManager
>>> component.provideAdapter(SetupManager, name='knowledge')
>>> from loops.setup import SetupManager
>>> setup = SetupManager(loopsRoot)
>>> concepts, resources, views = setup.setup()
>>> from loops import util
>>> from loops.concept import IndexAttributes
>>> component.provideAdapter(IndexAttributes)
>>> from loops.concept import Concept
>>> for c in concepts:
... catalog.index_doc(util.getUidForObject(c), c)
>>> #sorted(concepts)
Text Queries
============
Fin de partie
=============
>>> placefulTearDown()

4
expert/__init__.py Normal file
View file

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

30
expert/query.py Normal file
View file

@ -0,0 +1,30 @@
#
# Copyright (c) 2006 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
#
"""
Generic query functionality for retrieving stuff from a loops database
$Id$
"""
from zope import interface, component
from zope.app import zapi
from zope.component import adapts
from zope.interface import implements
from zope.cachedescriptors.property import Lazy

23
expert/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.expert import query
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')