Initial import
git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@82 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
2ce59c130e
commit
a537b0d595
7 changed files with 306 additions and 0 deletions
4
__init__.py
Normal file
4
__init__.py
Normal file
|
@ -0,0 +1,4 @@
|
|||
"""
|
||||
$Id: __init__.py $
|
||||
"""
|
||||
|
42
configure.zcml
Normal file
42
configure.zcml
Normal file
|
@ -0,0 +1,42 @@
|
|||
<configure
|
||||
xmlns="http://namespaces.zope.org/zope"
|
||||
i18n_domain="zope"
|
||||
>
|
||||
|
||||
<!-- Backward compatibility -->
|
||||
<modulealias module="loops" alias="src.loops" />
|
||||
|
||||
<!-- Security definitions -->
|
||||
|
||||
<!-- Content declarations -->
|
||||
|
||||
<interface
|
||||
interface=".interfaces.ITask"
|
||||
type="zope.app.content.interfaces.IContentType"
|
||||
/>
|
||||
|
||||
<content class=".task.Task">
|
||||
|
||||
<implements interface="zope.app.container.interfaces.IContentContainer" />
|
||||
|
||||
<implements
|
||||
interface="zope.app.annotation.interfaces.IAttributeAnnotatable" />
|
||||
|
||||
<factory
|
||||
id="loops.Task"
|
||||
description="Task object " />
|
||||
|
||||
<require
|
||||
permission="zope.View"
|
||||
interface="zope.app.container.interfaces.IReadContainer"/>
|
||||
|
||||
<require
|
||||
permission="zwiki.AddWikiPage"
|
||||
interface="zope.app.container.interfaces.IWriteContainer"/>
|
||||
|
||||
</content>
|
||||
|
||||
<!-- Register various browser related components, including all views -->
|
||||
<include package=".browser" />
|
||||
|
||||
</configure>
|
45
entity.py
Normal file
45
entity.py
Normal file
|
@ -0,0 +1,45 @@
|
|||
#
|
||||
# Copyright (c) 2004 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
|
||||
#
|
||||
|
||||
"""
|
||||
Definition of the Entity class.
|
||||
|
||||
$Id: entity.py $
|
||||
"""
|
||||
|
||||
from zope.interface import implements
|
||||
from zope.app.container.ordered import OrderedContainer
|
||||
|
||||
from interfaces import IEntity
|
||||
|
||||
|
||||
class Entity(OrderedContainer):
|
||||
""" A Task is a scheduled piece of work.
|
||||
Resources may be allocated to a Task.
|
||||
A Task may depend on subtasks.
|
||||
"""
|
||||
|
||||
implements(IEntity)
|
||||
|
||||
def getRelations(self, relationships=None):
|
||||
return []
|
||||
|
||||
def getReverseRelations(self, relationships=None):
|
||||
return []
|
||||
|
||||
|
136
interfaces.py
Normal file
136
interfaces.py
Normal file
|
@ -0,0 +1,136 @@
|
|||
#
|
||||
# Copyright (c) 2004 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
|
||||
#
|
||||
|
||||
"""
|
||||
loops interface definitions.
|
||||
|
||||
$Id: interfaces.py $
|
||||
"""
|
||||
|
||||
from zope.app.container.interfaces import IOrderedContainer
|
||||
|
||||
from zope.schema import TextLine
|
||||
|
||||
|
||||
class IEntity(IOrderedContainer):
|
||||
""" Common base class of the Task and Resource classes.
|
||||
"""
|
||||
|
||||
def getRelations(relationships=None):
|
||||
""" Return a list of target objects from relations assiociated
|
||||
with this Entity, possibly restricted to the relationships given.
|
||||
"""
|
||||
|
||||
def getReverseRelations(relationships=None):
|
||||
""" Return a list of source objects from relations directed at
|
||||
this Entity as the target, possibly restricted to the relationships
|
||||
given.
|
||||
"""
|
||||
|
||||
class DummyIEntity:
|
||||
def getRelation(target, relationship=None):
|
||||
""" Return the relation object specified by target and relationship.
|
||||
"""
|
||||
|
||||
def addRelation(target, relationship, **props):
|
||||
""" Create a new relation object with relationship to target
|
||||
and assign it to self.
|
||||
If supported by relationship additional properties may be
|
||||
given as keyword parameters.
|
||||
Return relation object.
|
||||
"""
|
||||
|
||||
def removeRelation(target, relationship):
|
||||
""" Remove the relation to target with relationship from self.
|
||||
"""
|
||||
|
||||
def getController():
|
||||
""" Return the LoopsController object of this Entity, typically
|
||||
the parent LoopsManager object or the portal_loops Tool.
|
||||
"""
|
||||
|
||||
|
||||
class ITask(IEntity):
|
||||
""" A Task is a scheduled piece of work.
|
||||
Resources may be allocated to a Task.
|
||||
A Task may depend on subtasks.
|
||||
"""
|
||||
|
||||
title = TextLine(
|
||||
title=u'Title',
|
||||
description=u'Name or short title of the task',
|
||||
default=u'',
|
||||
required=True)
|
||||
|
||||
class DummyITask:
|
||||
def getSubtasks(taskTypes=None):
|
||||
""" Return a list of subtasks of self,
|
||||
possibly restricted to the task types given.
|
||||
"""
|
||||
|
||||
def createSubtask(taskType=None, container=None, id=None, **props):
|
||||
""" Create a new task with id in container and assign it to self as a subtask.
|
||||
container defaults to parent of self.
|
||||
id will be generated if not given.
|
||||
Return the relation object that leads to the subtask
|
||||
(fetch the subtask via relation.getTarget()).
|
||||
"""
|
||||
|
||||
def assignSubtask(task):
|
||||
""" Assign an existing task to self as a subtask.
|
||||
Return the relation object that leads to the subtask.
|
||||
"""
|
||||
|
||||
def deassignSubtask(task):
|
||||
""" Remove the subtask relation to task from self.
|
||||
"""
|
||||
|
||||
def getParentTasks():
|
||||
""" Return a list of tasks to which self has a subtask relationship.
|
||||
"""
|
||||
|
||||
def getAllocatedResources(allocTypes=None, resTypes=None):
|
||||
""" Return a list of resources allocated to self,
|
||||
possibly restricted to the allocation types and
|
||||
target resource types given.
|
||||
"""
|
||||
|
||||
def allocateResource(resource, allocType=None, **props):
|
||||
""" Allocate resource to self. A special allocation type may be given.
|
||||
Additional properties may be given as keyword parameters.
|
||||
Return relation object that implements the allocation reference.
|
||||
"""
|
||||
|
||||
def deallocateResource(resource):
|
||||
""" Deallocate from self the resource allocated.
|
||||
"""
|
||||
|
||||
def allocatedUserIds():
|
||||
""" Returns list of user IDs of allocated Person objects that are portal members.
|
||||
Used by catalog index 'allocUserIds'.
|
||||
"""
|
||||
|
||||
def getAllocType(resource):
|
||||
""" Return the allocation type for the resource given. Raise a
|
||||
ValueException if resource is not allocated to self.
|
||||
"""
|
||||
|
||||
def getAllAllocTypes():
|
||||
""" Return a tuple with all available allocation types defined
|
||||
in the LoopsController object that is responsible for self.
|
||||
"""
|
40
task.py
Normal file
40
task.py
Normal file
|
@ -0,0 +1,40 @@
|
|||
#
|
||||
# Copyright (c) 2004 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
|
||||
#
|
||||
|
||||
"""
|
||||
Definition of the Task class.
|
||||
|
||||
$Id: task.py $
|
||||
"""
|
||||
|
||||
from zope.interface import implements
|
||||
|
||||
from entity import Entity
|
||||
from interfaces import ITask
|
||||
|
||||
|
||||
class Task(Entity):
|
||||
""" A Task is a scheduled piece of work.
|
||||
Resources may be allocated to a Task.
|
||||
A Task may depend on subtasks.
|
||||
"""
|
||||
|
||||
implements(ITask)
|
||||
|
||||
title = u''
|
||||
|
4
tests/__init__.py
Normal file
4
tests/__init__.py
Normal file
|
@ -0,0 +1,4 @@
|
|||
"""
|
||||
$Id: __init__.py $
|
||||
"""
|
||||
|
35
tests/test_task.py
Executable file
35
tests/test_task.py
Executable file
|
@ -0,0 +1,35 @@
|
|||
# $Id: test_task.py $
|
||||
|
||||
import unittest
|
||||
from zope.testing.doctestunit import DocTestSuite
|
||||
from zope.app.container.tests.test_icontainer import TestSampleContainer
|
||||
from zope.interface.verify import verifyClass
|
||||
|
||||
from src.loops.task import Task
|
||||
from src.loops.interfaces import ITask
|
||||
|
||||
#class Test(TestSampleContainer):
|
||||
class Test(unittest.TestCase):
|
||||
"Test methods of the Task class."
|
||||
|
||||
def makeTestObject(self):
|
||||
return Task()
|
||||
|
||||
def testInterface(self):
|
||||
self.assert_(ITask.providedBy(Task()), 'Interface ITask is not implemented by class Task.')
|
||||
verifyClass(ITask, Task)
|
||||
|
||||
def testTitle(self):
|
||||
t = Task()
|
||||
self.assertEqual(u'', t.title)
|
||||
t.title = u'First Task'
|
||||
self.assertEqual(u'First Task', t.title)
|
||||
|
||||
def test_suite():
|
||||
return unittest.TestSuite((
|
||||
#DocTestSuite('src.loops.task'),
|
||||
unittest.makeSuite(Test),
|
||||
))
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main(defaultTest='test_suite')
|
Loading…
Add table
Reference in a new issue