started with system package for global loops configuration and agent/job control

git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@2656 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
helmutm 2008-05-31 09:00:58 +00:00
parent 18ab09c31b
commit e07afbccb0
6 changed files with 198 additions and 0 deletions

53
system/README.txt Normal file
View file

@ -0,0 +1,53 @@
===============================================================
loops - Linked Objects for Organization and Processing Services
===============================================================
loops System Management.
($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.tests.setup import TestSite
>>> t = TestSite(site)
>>> concepts, resources, views = t.setup()
>>> appRoot = site['loops']
In addition to the application site we need a loops system management site.
>>> from loops.interfaces import ILoops, IConcept
>>> from loops.setup import ISetupManager
>>> from loops.system.setup import SetupManager
>>> component.provideAdapter(SetupManager, (ILoops,), ISetupManager,
... name='system')
>>> sysConcepts, sysResources, sysViews = t.siteSetup('loops.system')
>>> systemRoot = site['loops.system']
>>> sorted(sysConcepts)
[u'domain', u'file', u'hasType', u'job', u'note', u'predicate', u'query',
u'standard', u'textdocument', u'type']
Agents and Jobs
===============
Fin de partie
=============
>>> placefulTearDown()

4
system/__init__.py Normal file
View file

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

11
system/configure.zcml Normal file
View file

@ -0,0 +1,11 @@
<!-- $Id$ -->
<configure
xmlns:zope="http://namespaces.zope.org/zope"
xmlns:browser="http://namespaces.zope.org/browser"
i18n_domain="zope">
<zope:adapter factory="loops.system.setup.SetupManager"
name="system" />
</configure>

65
system/interfaces.py Normal file
View file

@ -0,0 +1,65 @@
#
# 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
#
"""
System management interfaces.
$Id$
"""
from zope.interface import Interface, Attribute
from zope import interface, component, schema
from loops.interfaces import IConceptSchema
from loops.util import _
class IJob(IConceptSchema):
""" Specifies/represents a job to be executed by a cybertools.agent
instance.
"""
identifier = schema.TextLine(
title=_(u'Job Identifier'),
description=_(u'A name/ID unique within the realm of the '
'controller.'),
required=True,)
agentId = schema.TextLine(
title=_(u'Agent Identifier'),
description=_(u'The identifier of the agent that will '
'execute the job; this identifies also the type '
'of job, e.g. a crawling or transport job.')
startTime = schema.Date(
title=_(u'Start Date/Time'),
description=_(u'Date/time at which the job should be '
'executed. If omitted the job will be executed '
'immediately.'),
required=False,)
#params = Attribute('Mapping with key/value pairs to be used by '
# 'the ``execute()`` method.')
#repeat = Attribute('Number of seconds after which the job should be '
# 'rescheduled. Do not repeat if 0.')
#successors = Attribute('Jobs to execute immediately after this '
# 'one has been finished.')
class IJobManager(IConceptSchema):
""" A container/manager for jobs to be executed by a cybertools.agent
instance.
"""

42
system/setup.py Normal file
View file

@ -0,0 +1,42 @@
#
# 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
#
"""
Automatic setup of a loops site for the system package.
$Id$
"""
from zope.component import adapts
from zope.interface import implements, Interface
from loops.concept import Concept
from loops.interfaces import ITypeConcept
from loops.setup import SetupManager as BaseSetupManager
class SetupManager(BaseSetupManager):
def setup(self):
concepts = self.context.getConceptManager()
type = concepts.getTypeConcept()
predicate = concepts['predicate']
# type concepts:
job = self.addAndConfigureObject(concepts, Concept, 'job', title=u'Job',
conceptType=type)

23
system/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 system 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')