|
/
Zope
/
gocept svn checkins
/
Archive
/
2007
/
2007-03
/
SVN: r4507 - in AlphaFlow/trunk: . Extensions
[
SVN: r4506 - in AlphaFlow/trunk: . Extensions ... ]
[
SVN: r4510 - in grok-workshop/trunk/src/workshop: ... ]
SVN: r4507 - in AlphaFlow/trunk: . Extensions
Christian Theune <ct(at)gocept.com> |
2007-03-01 00:31:21 |
[ FULL ]
|
Author: ctheune
Date: Thu Mar 1 00:31:19 2007
New Revision: 4507
Modified:
AlphaFlow/trunk/Extensions/Install.py
AlphaFlow/trunk/process.py
Log:
- whitespace, removed unused imports
Modified: AlphaFlow/trunk/Extensions/Install.py
==============================================================================
--- AlphaFlow/trunk/Extensions/Install.py (original)
+++ AlphaFlow/trunk/Extensions/Install.py Thu Mar 1 00:31:19 2007
(at)(at) -27,7 +27,6 (at)(at)
import zLOG
# CMF imports
-from Products.CMFCore.DirectoryView import createDirectoryView
from Products.CMFCore.utils import getToolByName
from Products.CMFCore import permissions
from Products.Archetypes.Extensions.utils import installTypes
Modified: AlphaFlow/trunk/process.py
==============================================================================
--- AlphaFlow/trunk/process.py (original)
+++ AlphaFlow/trunk/process.py Thu Mar 1 00:31:19 2007
(at)(at) -3,16 +3,11 (at)(at)
# $Id$
"""Process definitions"""
-# Python imports
-from xml.dom import minidom
-
-# Zope imports
from OFS.Folder import Folder
from AccessControl import ClassSecurityInfo
from Globals import InitializeClass
from Products.PageTemplates.PageTemplateFile import PageTemplateFile
-# Sibling imports
from Products.AlphaFlow.interfaces import IProcess
from Products.AlphaFlow import utils, config
from Products.AlphaFlow.activity import activity_registry
(at)(at) -25,7 +20,7 (at)(at)
def manage_addProcess(self, id, REQUEST=None):
self.manage_addProcess(id, REQUEST)
-
+
class Process(Folder, DOMImporter):
__implements__ = Folder.__implements__ + (IProcess,)
(at)(at) -55,7 +50,6 (at)(at)
encoding='ascii', datatype=str),
)
-
validation_errors = []
_properties = Folder._properties + (
(at)(at) -70,7 +64,6 (at)(at)
({'label' : 'Overview', 'action' : 'manage_overview'},) + \
Folder.manage_options
-
manage_overview = PageTemplateFile('www/processOverview', globals())
#########################
# ZMI convenience methods
|
SVN: r4508 - AlphaFlow/trunk/tests
Christian Theune <ct(at)gocept.com> |
2007-03-01 00:41:20 |
[ FULL ]
|
Author: ctheune
Date: Thu Mar 1 00:41:17 2007
New Revision: 4508
Removed:
AlphaFlow/trunk/tests/doctest.py
Modified:
AlphaFlow/trunk/tests/framework.py
AlphaFlow/trunk/tests/test_alarm.py
AlphaFlow/trunk/tests/test_condition.py
AlphaFlow/trunk/tests/test_definition.py
AlphaFlow/trunk/tests/test_doctest.py
AlphaFlow/trunk/tests/test_email.py
AlphaFlow/trunk/tests/test_expression.py
AlphaFlow/trunk/tests/test_patch.py
AlphaFlow/trunk/tests/test_roleassign.py
AlphaFlow/trunk/tests/test_security.py
AlphaFlow/trunk/tests/test_simpledecision.py
AlphaFlow/trunk/tests/test_workitem.py
Log:
- removed unused imports
- various cleanups
Modified: AlphaFlow/trunk/tests/framework.py
==============================================================================
--- AlphaFlow/trunk/tests/framework.py (original)
+++ AlphaFlow/trunk/tests/framework.py Thu Mar 1 00:41:17 2007
(at)(at) -70,7 +70,7 (at)(at)
print 'You might need to set SOFTWARE_HOME.'
sys.exit(1)
-import Testing, unittest
+import Testing
execfile(os.path.join(os.path.dirname(Testing.__file__), 'common.py'))
# Include ZopeTestCase support
Modified: AlphaFlow/trunk/tests/test_alarm.py
==============================================================================
--- AlphaFlow/trunk/tests/test_alarm.py (original)
+++ AlphaFlow/trunk/tests/test_alarm.py Thu Mar 1 00:41:17 2007
(at)(at) -5,7 +5,6 (at)(at)
import unittest
from DateTime import DateTime
-from Testing import ZopeTestCase
from Products.CMFCore.utils import getToolByName
(at)(at) -13,13 +12,14 (at)(at)
from Products.AlphaFlow.interfaces import IAlarmWorkItem, IAlarmActivity
from Products.AlphaFlow.activities.alarm import AlarmWorkItem, AlarmActivity
+
class AlarmTest(AlphaFlowTestCase):
interfaces_to_test = [
(IAlarmWorkItem, AlarmWorkItem),
(IAlarmActivity, AlarmActivity)
]
-
+
def _init_object(self):
portal = self.portal
self._create_test_users()
(at)(at) -38,7 +38,7 (at)(at)
doc = home.testdocument
doc.assignProcess('test')
return doc
-
+
def _getAlarmWorkItem(self, workitems):
for wi in workitems:
if IAlarmWorkItem.isImplementedBy(wi):
(at)(at) -49,7 +49,7 (at)(at)
portal = self.portal
wftool = getToolByName(portal, 'workflow_manager')
doc = self._init_object()
-
+
instance = doc.getInstance()
instance.start("testing")
self.assertEquals(instance.state, "active")
(at)(at) -78,8 +78,8 (at)(at)
doc.deadline = now - 1/1440.0
wftool.pingCronItems()
- self.assertEquals(alarm_wi.state, "complete")
- self.assertEquals(alarm_wi.getStatusInfo(), "deadline exceeded")
+ self.assertEquals(alarm_wi.state, "complete")
+ self.assertEquals(alarm_wi.getStatusInfo(), "deadline exceeded")
self.assertEquals(len(alarm_wi.getGeneratedWorkItems()), 1)
# test fallout on error for new wf instance
(at)(at) -97,13 +97,9 (at)(at)
self.assertEquals(alarm_wi.state, "fallout")
self.assertEquals(instance.state, "fallout")
self.assertEquals(len(alarm_wi.getGeneratedWorkItems()), 0)
-
-
+
+
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(AlarmTest))
- return suite
-
-if __name__ == '__main__':
- framework()
-
+ return suite
Modified: AlphaFlow/trunk/tests/test_condition.py
==============================================================================
--- AlphaFlow/trunk/tests/test_condition.py (original)
+++ AlphaFlow/trunk/tests/test_condition.py Thu Mar 1 00:41:17 2007
(at)(at) -5,9 +5,6 (at)(at)
import unittest
-from DateTime import DateTime
-from Testing import ZopeTestCase
-
from Products.CMFCore.utils import getToolByName
from Products.AlphaFlow.tests.AlphaFlowTestCase import AlphaFlowTestCase
(at)(at) -16,6 +13,7 (at)(at)
from Products.AlphaFlow.activities.condition import \
ConditionWorkItem, ConditionActivity
+
class ConditionTest(AlphaFlowTestCase):
interfaces_to_test = [
(at)(at) -48,7 +46,6 (at)(at)
doc = home.testdocument
doc.assignProcess('test')
return doc
-
def test_definition(self):
doc = self._init_object(['do_this', 'do_that'])
(at)(at) -85,7 +82,6 (at)(at)
self.assertEqual(task2.activity_type, "task")
self.assertEqual(task2.getActivity().getId(), "do_that")
-
def test_failure(self):
# Test behavior when expression returns activity id which is not in
continue_activity list
doc = self._init_object(['do_nothing'])
(at)(at) -106,7 +102,3 (at)(at)
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(ConditionTest))
return suite
-
-if __name__ == '__main__':
- framework()
-
Modified: AlphaFlow/trunk/tests/test_definition.py
==============================================================================
--- AlphaFlow/trunk/tests/test_definition.py (original)
+++ AlphaFlow/trunk/tests/test_definition.py Thu Mar 1 00:41:17 2007
(at)(at) -5,12 +5,9 (at)(at)
import os
import unittest
from random import shuffle
-from StringIO import StringIO
from tempfile import mktemp
from xml.dom import minidom
-from AccessControl.Permission import Permission
-from ExtensionClass import Base
from OFS.SimpleItem import SimpleItem
from Products.Archetypes.tests.utils import *
(at)(at) -25,7 +22,7 (at)(at)
from Products.AlphaFlow.interfaces import \
IProcess, IAlphaFlowed, IInstance, IActivity, IWorkItem, ITalesActivity, \
- IAutomaticWorkItem, IAction, IReviewWorkItem, IReviewActivity, IExit, \
+ IAutomaticWorkItem, IAction, IReviewWorkItem, IReviewActivity, \
IWorkflowAttribute, IAssignableActivity, IAutomaticActivity, \
IPermissionSetting
from Products.AlphaFlow.workflowedobject import AlphaFlowed
(at)(at) -34,16 +31,15 (at)(at)
from Products.AlphaFlow.activity import \
activity_registry, BaseTalesActivity, BaseAssignableActivity, \
BaseActivity, BaseAutomaticActivity
-from Products.AlphaFlow import config
from Products.AlphaFlow.workitem import \
BaseWorkItem, BaseAutomaticWorkItem, workitem_registry
from Products.AlphaFlow.action import Action
from Products.AlphaFlow.activities.review import ReviewWorkItem,
ReviewActivity
from Products.AlphaFlow.activities.permission import PermissionSetting
-from Products.AlphaFlow.utils import flexSplit, unique
+from Products.AlphaFlow.utils import flexSplit
from Products.AlphaFlow.exception import ConfigurationError
from Products.AlphaFlow.workflowattr import \
- WorkflowAttribute, InitializeWorkflowAttributes, findAttrInAttributes, \
+ WorkflowAttribute, findAttrInAttributes, \
workflow_attributes_registry
from Products.AlphaFlow.importexport import convert_to_xml
from Products.AlphaFlow.activities.notify import notify_registry
(at)(at) -67,7 +63,7 (at)(at)
id = 'faked'
state = 'active'
-
+
def getId(self):
return self.id
(at)(at) -214,7 +210,6 (at)(at)
if pot_node_items != node_items:
continue
return pot_node
-
def _compare_DOM_nodes(self, exp_node, got_node, wf_name,
documentElement=False):
(at)(at) -234,7 +229,7 (at)(at)
# workflow does not have compareable id
self.assertEqual(exp_node.parentNode.getAttribute('id'),
got_node.parentNode.getAttribute('id'))
-
+
exp_node_items = self._filter_relevant_attrs(exp_node)
got_node_items = self._filter_relevant_attrs(got_node)
self.assertEqual(exp_node_items,
(at)(at) -281,7 +276,7 (at)(at)
check_document = process.addActivity("check_document", "review")
process.check_document.reject_activity = ("write_document",)
process.check_document.accept_activity = ("publish_document",)
-
+
# "permission-change" is an activity, that updates the permissions
# to match a publication state
publish_document = process.addActivity("publish_document",
(at)(at) -289,7 +284,7 (at)(at)
publish_document.setPermissions([('View', ['Anonymous'], False),
('Modify portal content',
['Manager'], True)])
-
+
# Let's create some content
portal.createObject("testdocument", "DummyContent")
(at)(at) -300,7 +295,7 (at)(at)
doc.assignProcess('myProcess')
instance = doc.getInstance()
-
+
instance.edit(write_document_assignees="author",
write_document_task="Bitte eine"
"Pressemitteilung zum Thema Drogenpraevention 2004 schreiben",
(at)(at) -324,7 +319,7 (at)(at)
self.assertEquals([],
instance.getWorkItems(activity_id="michgibtsnich"))
self.assertEquals([write_document_wi],
instance.getWorkItems(activity_id="write_document"))
-
+
write_document_wi.complete()
self.login("editor1")
(at)(at) -336,9 +331,7 (at)(at)
self.loginAsPortalOwner()
self.assertEquals(0, len(instance.getWorkItems()))
self.assertEquals(False, doc.hasInstanceAssigned())
-
-
-
+
def test_get_process(self):
portal = self.portal
alf = getToolByName(portal, 'workflow_manager')
(at)(at) -351,7 +344,7 (at)(at)
self.assert_(IProcess.isImplementedBy(process))
self.assertEquals(alf.getProcess(pid, default), process)
self.failUnless(process in alf.listProcesses())
-
+
def test_grouped_schema(self):
self._import_wf('workflows/multi_review.alf')
portal = self.portal
(at)(at) -370,7 +363,7 (at)(at)
act_ids_got.sort()
self.assertEquals(act_ids_expected, act_ids_got)
self.assertEquals(gs[0].Title(), 'Dokument schreiben')
-
+
def test_suitableprocs(self):
self._import_wf()
self._create_test_users()
(at)(at) -395,14 +388,14 (at)(at)
doc.manage_addLocalRoles('author', ['Reviewer'])
suitable = [s.getId() for s in doc.getSuitableProcesses() if s.getId()
== 'test']
self.assertEquals(suitable, [])
-
+
def test_delprocess(self):
portal = self.portal
alf = getToolByName(portal, 'workflow_manager')
alf.addProcess('test')
alf.deleteProcess('test')
self.assertRaises(AttributeError, alf.getProcess, 'test')
-
+
def test_withrecursion(self):
self._import_wf()
self._create_test_users()
(at)(at) -420,8 +413,7 (at)(at)
def _get_fold():
return self.portal.testfolder
-
-
+
# Create small hierarchy
portal.createObject("testfolder", "DummyFolder")
portal.testfolder.setTitle("Testordner")
(at)(at) -458,30 +450,29 (at)(at)
fold.getWorkItemsForCurrentUser()[0].accept()
_check_state(objects, 'published')
-
def test_recursion_limits(self):
# we have a limit of 100 objects
-
+
from Products.AlphaFlow.activities.recursion import \
- RecursionActivity, RecursionWorkItem
-
+ RecursionActivity
+
self.loginAsPortalOwner()
portal = self.portal
portal.invokeFactory('DummyFolder', 'f1')
f1 = portal.f1
-
+
rec_ac = RecursionActivity('rec')
-
+
schema = rec_ac.getConfigurationSchema(f1)
self.assert_(schema.get('apply') is not None, 'No apply field')
-
+
for i in range(0, 120):
f1.invokeFactory('DummyContent', 'Doc_%03d' % i)
schema = rec_ac.getConfigurationSchema(f1)
self.assert_(schema.get('apply') is None,
'There is an apply field')
-
+
def test_large_recursion(self):
# profiling test case, disabled by default
return
(at)(at) -491,7 +482,7 (at)(at)
portal = self.portal
portal.invokeFactory('DummyFolder', 'f1')
f1 = portal.f1
-
+
for i in range(0, 80):
f1.invokeFactory('DummyContent', 'Doc_%03d' % i)
(at)(at) -502,14 +493,12 (at)(at)
p.runcall(instance.start, 'testing')
p.close()
-
def test_getActionById(self):
wi = ReviewWorkItem('asdf', 'pups')
self.assertEqual(wi.getActionById('accept').id, 'accept')
self.assertEqual(wi.getActionById('reject').id, 'reject')
self.assertRaises(KeyError, wi.getActionById, 'asdf')
-
def test_cache(self):
portal = self.portal
portal.invokeFactory('DummyContent', 'doc1')
(at)(at) -535,7 +524,7 (at)(at)
wi = WorkitemFake()
i._setObject(wi.id, wi)
wi = i._getOb(wi.id)
-
+
# the cache doesn't now about it
self.assertEquals([], i.getWorkItems())
(at)(at) -558,17 +547,17 (at)(at)
new_id = result[0]['new_id']
new_ob = getattr(portal, new_id)
self.assert_(not new_ob.hasInstanceAssigned())
-
+
def test_export_import(self):
self.loginAsPortalOwner()
self._import_wf()
portal = self.portal
alf = getToolByName(portal, 'workflow_manager')
-
+
folder = self.create(portal, 'DummyFolder', 'f1')
target_folder = self.create(portal, 'DummyFolder', 'f2')
content = self.create(folder, 'DummyContent', 'doc1')
-
+
folder.assignProcess('test')
instance = folder.getInstance()
instance.edit(recursion_apply=True)
(at)(at) -605,7 +594,7 (at)(at)
instance.start('testing')
wi = instance.getWorkItems()[0]
-
+
def check(ob):
self.assertEquals(doc.absolute_url(), ob.getUrl())
self.assertEquals(doc.getPhysicalPath(),
(at)(at) -614,7 +603,7 (at)(at)
brain = ob.getContentObjectPortalCatalogBrain()
self.assertEquals(doc.Title(), brain.Title)
self.assertEquals(doc.absolute_url(), brain.getURL())
-
+
check(instance)
check(wi)
(at)(at) -627,10 +616,10 (at)(at)
doc.assignProcess('test')
instance = doc.getInstance()
instance.start('testing')
-
+
wis = instance.getWorkItems()
self.assertEquals(2, len(wis))
-
+
this = wis[0]
that = wis[1]
if this.getActivity().getId() == 'do_that':
(at)(at) -646,7 +635,7 (at)(at)
self._import_wf('workflows/instance_transaction.alf')
alf = getToolByName(portal, 'workflow_manager')
-
+
doc = self.create(portal, 'DummyContent', 'doc1')
doc.assignProcess('test')
instance = doc.getInstance()
(at)(at) -658,7 +647,6 (at)(at)
instance.createWorkItems, ['i-do-not-exist'],
wis[0])
self.assertEquals(0, instance.transaction)
-
def test_before_start(self):
self.loginAsPortalOwner()
self._import_wf('workflows/before_start.alf')
(at)(at) -678,17 +666,16 (at)(at)
self.assertEquals(0, doc.after)
self.assertEquals(['before-task'],
wftool.getProcess('test')['some-task'].graphGetStartActivities())
-
-
+
def test_invalid_imports(self):
self.loginAsPortalOwner()
portal = self.portal
wf = getToolByName(portal, "workflow_manager")
self.assertRaises(ValueError, wf.importWorkflowFromXML, "test",
"/tmp/test.alf")
self.assertRaises(ValueError, wf.manage_importXML, "test",
"/tmp/test.alf", {}) # {} is a fake request
-
+
def test_flexsplit(self):
- self.assertEquals(["a","b"], flexSplit("a,b"))
+ self.assertEquals(["a","b"], flexSplit("a,b"))
self.assertEquals(["a","b","c"], flexSplit("a,b,c"))
self.assertEquals(["a"], flexSplit("a"))
self.assertEquals(["a", "b"], flexSplit("a b"))
(at)(at) -697,7 +684,6 (at)(at)
self.assertEquals(["a", "b", "c"], flexSplit("a,b c"))
self.assertEquals(["a", "b", "c"], flexSplit("a, b ,c"))
-
def test_restart(self):
self.loginAsPortalOwner()
self._import_wf('workflows/task.alf')
(at)(at) -721,12 +707,11 (at)(at)
def test_dcworkflow(self):
# test that a workflow state set in manage_afterAdd is not in any way
# modified by dcworkflow again
-
self.loginAsPortalOwner()
portal = self.portal
self._import_wf('workflows/dcworkflow.alf')
wftool = getToolByName(portal, 'portal_workflow')
-
+
def manage_afterAdd(self, item, container):
DummyContent.inheritedAttribute('manage_afterAdd')(self, item,
container)
(at)(at) -734,7 +719,7 (at)(at)
return
self.assignProcess("test")
self.getInstance().start("testing")
-
+
DummyContent.manage_afterAdd = manage_afterAdd
try:
portal.invokeFactory('DummyContent', 'doc1')
(at)(at) -745,16 +730,14 (at)(at)
review_state = wftool.getStatusOf(
'alphaflow_fake', doc1)['review_state']
self.assertEquals('private', review_state)
-
finally:
del DummyContent.manage_afterAdd
-
def test_fallout_startActivity(self):
# test for fix of bug #2666
self.loginAsPortalOwner()
self._import_wf('workflows/fallout_startActivity.alf')
-
+
doc1 = self.create(self.portal, 'DummyContent', 'doc1')
doc1.assignProcess('test')
instance = doc1.getInstance()
(at)(at) -763,15 +746,9 (at)(at)
fallout_workitems = instance.getWorkItems('fallout')
self.assertEqual(1, len(fallout_workitems))
self.assertEqual('become_fallout', fallout_workitems[0].activity_id)
-
-
-
+
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(ProcessDefinitionTest))
return suite
-
-if __name__ == '__main__':
- framework()
-
Modified: AlphaFlow/trunk/tests/test_doctest.py
==============================================================================
--- AlphaFlow/trunk/tests/test_doctest.py (original)
+++ AlphaFlow/trunk/tests/test_doctest.py Thu Mar 1 00:41:17 2007
(at)(at) -2,7 +2,6 (at)(at)
# Copyright (c) 2005-2006 gocept gmbh & co. kg
# See also LICENSE.txt
# $Id$
-import transaction
import unittest
from Products.PloneTestCase import PloneTestCase
(at)(at) -11,7 +10,6 (at)(at)
from AccessControl.SecurityManagement import newSecurityManager
from AccessControl.SecurityManagement import noSecurityManager
-from Products.AlphaFlow.tests import doctest
from Products.AlphaFlow.Extensions import dcworkflow
PloneTestCase.setupPloneSite()
Modified: AlphaFlow/trunk/tests/test_email.py
==============================================================================
--- AlphaFlow/trunk/tests/test_email.py (original)
+++ AlphaFlow/trunk/tests/test_email.py Thu Mar 1 00:41:17 2007
(at)(at) -12,7 +12,7 (at)(at)
from Products.AlphaFlow.activities.notify import \
EMailWorkItem, EMailActivity, RecipientOwner, RecipientNextAssignees,
\
RecipientActualRole
-from Products.AlphaFlow.exception import ConfigurationError
+
class EmailTest(AlphaFlowTestCase):
(at)(at) -23,7 +23,7 (at)(at)
(IEMailRecipientMode, RecipientNextAssignees),
(IEMailRecipientMode, RecipientActualRole),
]
-
+
def _init_object(self):
# Creates a simple workflow
portal = self.portal
(at)(at) -47,21 +47,19 (at)(at)
doc.assignProcess('test')
return doc
-
-
def test_recipient_owner(self):
def _test_recipients(mode, expected_ids, wi):
got_ids = mode.getRecipientsForWorkItem(wi)
got_ids.sort()
expected_ids.sort()
self.assertEquals(expected_ids, got_ids)
-
+
doc = self._init_object()
instance = doc.getInstance()
instance.start("comment")
wi = instance.getWorkItems(state="complete")[0]
self.assert_(IEMailWorkItem.isImplementedBy(wi))
-
+
ro = RecipientOwner('ro')
rna = RecipientNextAssignees('rna')
rar = RecipientActualRole('rar')
(at)(at) -76,7 +74,3 (at)(at)
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(EmailTest))
return suite
-
-if __name__ == '__main__':
- framework()
-
Modified: AlphaFlow/trunk/tests/test_expression.py
==============================================================================
--- AlphaFlow/trunk/tests/test_expression.py (original)
+++ AlphaFlow/trunk/tests/test_expression.py Thu Mar 1 00:41:17 2007
(at)(at) -14,7 +14,8 (at)(at)
from Products.AlphaFlow.activities.expression import \
ExpressionActivity, ExpressionWorkItem
-from Products.AlphaFlow.utils import evaluateTales, getTalesContext
+from Products.AlphaFlow.utils import getTalesContext
+
class ExpressionTest(AlphaFlowTestCase):
(at)(at) -22,7 +23,7 (at)(at)
(IExpressionWorkItem, ExpressionWorkItem),
(IExpressionActivity, ExpressionActivity)
]
-
+
def _init_object(self, wf='workflows/expression.alf'):
portal = self.portal
self._create_test_users()
(at)(at) -41,7 +42,7 (at)(at)
doc = home.testdocument
doc.assignProcess('test')
return doc
-
+
def test_definition(self):
doc = self._init_object()
(at)(at) -56,7 +57,6 (at)(at)
wis = instance.getWorkItems()
# only the task is left
self.assertEquals(len(wis), 1)
-
def test_runas(self):
doc = self._init_object('workflows/expression-runas.alf')
(at)(at) -80,7 +80,7 (at)(at)
context = getTalesContext(wi)
vars = context.vars
-
+
self.assertEquals(doc, vars['content'])
self.assertEquals(doc, vars['here'])
self.assertEquals(wi, vars['workitem'])
(at)(at) -89,13 +89,9 (at)(at)
self.assertEquals('author',
vars['alphaflow']['currentUser'].getUserName())
self.assertEquals(SpecialUsers.system,
vars['alphaflow']['systemUser'])
-
-
+
+
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(ExpressionTest))
return suite
-
-if __name__ == '__main__':
- framework()
-
Modified: AlphaFlow/trunk/tests/test_patch.py
==============================================================================
--- AlphaFlow/trunk/tests/test_patch.py (original)
+++ AlphaFlow/trunk/tests/test_patch.py Thu Mar 1 00:41:17 2007
(at)(at) -4,7 +4,6 (at)(at)
import unittest
-from Products.CMFCore.utils import getToolByName
from Products.AlphaFlow.interfaces import IAlphaFlowed
from Products.AlphaFlow import config
(at)(at) -36,6 +35,3 (at)(at)
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(PatchTest))
return suite
-
-if __name__ == '__main__':
- framework()
Modified: AlphaFlow/trunk/tests/test_roleassign.py
==============================================================================
--- AlphaFlow/trunk/tests/test_roleassign.py (original)
+++ AlphaFlow/trunk/tests/test_roleassign.py Thu Mar 1 00:41:17 2007
(at)(at) -4,14 +4,13 (at)(at)
import unittest
-from Products.CMFCore.utils import getToolByName
-
from Products.AlphaFlow.tests.AlphaFlowTestCase import AlphaFlowTestCase
from Products.AlphaFlow.activities.interfaces import \
IRoleAssignActivity, IRoleAssignWorkItem
from Products.AlphaFlow.activities.roleassign import \
RoleAssignActivity, RoleAssignWorkItem
+
class RoleAssignTest(AlphaFlowTestCase):
interfaces_to_test = [
(at)(at) -24,7 +23,7 (at)(at)
self.loginAsPortalOwner()
self._create_test_users()
portal = self.getPortal()
-
+
doc = self.create(portal, 'DummyContent', 'doc1')
wi = RoleAssignWorkItem('myid', 'my-activity')
(at)(at) -33,7 +32,7 (at)(at)
doc.manage_setLocalRoles('editor1', ['foo'])
doc.manage_setLocalRoles('editor2', ['foo', 'bar', 'baz'])
doc.manage_setLocalRoles('editor3', ['bar', 'baz'])
-
+
def _assert_role(role, expected_users):
got = doc.users_with_local_role(role)
got.sort()
(at)(at) -48,7 +47,7 (at)(at)
_assert_role('foo', [])
_assert_role('bar', ['editor2', 'editor3'])
_assert_role('baz', ['editor2', 'editor3'])
-
+
# now check the assignment of roles to users
wi._addLocalRole('newrole', ['editor1', 'editor3'], doc)
_assert_role('foo', [])
(at)(at) -56,8 +55,8 (at)(at)
_assert_role('baz', ['editor2', 'editor3'])
_assert_role('newrole', ['editor1', 'editor3'])
+
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(RoleAssignTest))
return suite
-
Modified: AlphaFlow/trunk/tests/test_security.py
==============================================================================
--- AlphaFlow/trunk/tests/test_security.py (original)
+++ AlphaFlow/trunk/tests/test_security.py Thu Mar 1 00:41:17 2007
(at)(at) -3,10 +3,7 (at)(at)
# $Id$
import unittest
-from random import shuffle
-from AccessControl.Permission import Permission
-from AccessControl.SecurityManagement import newSecurityManager
from AccessControl import getSecurityManager
from Products.PluginIndexes.common.PluggableIndex import \
PluggableIndexInterface
(at)(at) -16,17 +13,16 (at)(at)
from Products.AlphaFlow.tests.AlphaFlowTestCase import AlphaFlowTestCase
-from Products.AlphaFlow.interfaces import \
- IProcess, IAlphaFlowed, IInstance, IActivity
-from Products.AlphaFlow.workflowedobject import AlphaFlowed
+from Products.AlphaFlow.interfaces import IProcess, IInstance
from Products.AlphaFlow.instance import Instance
from Products.AlphaFlow.process import Process
-from Products.AlphaFlow import config, utils
+from Products.AlphaFlow import utils
from Products.AlphaFlow.exception import ConfigurationError
from Products.AlphaFlow.eventchannel import EventChannelIndex
from Products.AlphaFlow.utils import getRolesOfPermission
+
class ContentMock:
def __init__(self, uid):
(at)(at) -41,6 +37,7 (at)(at)
def reindexObjectSecurity(self):
pass
+
class InstanceMock:
def __init__(self, id='instance-id', workitem=None):
(at)(at) -60,6 +57,7 (at)(at)
def getWorkItemIds(self):
return ['wi1', 'wi2']
+
class WorkItemMock:
def __init__(self, id, relevant):
(at)(at) -84,9 +82,9 (at)(at)
def getContentObject(self):
return ContentMock('content-uid')
-
+
class SecurityTest(AlphaFlowTestCase):
-
+
interfaces_to_test = [(IInstance, Instance),
(IProcess, Process),
(PluggableIndexInterface, EventChannelIndex),
(at)(at) -188,7 +186,7 (at)(at)
# let's assign the author again
f.set(instance, 'author')
instance.updateWorkitemsAndContentObjects()
-
+
# in review we, as author, may not view the document, complete and
# check catalog again
doc.getWorkItemsForCurrentUser()[0].complete()
(at)(at) -196,7 +194,6 (at)(at)
self.assertEquals(0, len(results))
self.assertEquals((), doc.get_local_roles_for_userid('author'))
self.assertEquals(0, len(doc.getWorkItemsForCurrentUser()))
-
def test_permissions(self):
mod = utils.modifyRolesForPermission
(at)(at) -215,12 +212,11 (at)(at)
self.assertNotEquals('SELECTED', role['selected'])
def test_memberswithroles(self):
-
+
def _test_members(reference, member_list):
member_ids = [ m.getUserName() for m in member_list ]
self.assertEquals(reference, member_ids)
-
-
+
portal = self.portal
lmwr = utils.listMembersWithRoles
self._create_test_users()
(at)(at) -243,7 +239,7 (at)(at)
f1 = portal.f1
f1.manage_addLocalRoles('editor1', ['Reviewer'])
f1.manage_addLocalRoles('author', ['Author'])
-
+
self.login('editor1')
portal = self.portal
f1 = portal.f1
(at)(at) -256,8 +252,7 (at)(at)
voc = schema.getField('write_document_assignees').Vocabulary()
self.assertEquals(1, len(voc))
self.assertEquals('author', voc[0])
-
-
+
def test_actual_assignees(self):
self._import_wf('workflows/actual_assignees.alf')
self._create_test_users()
(at)(at) -277,7 +272,7 (at)(at)
self.assertEquals(2, len(users))
self.assert_('editor2' in users)
self.assert_('editor3' in users)
-
+
def test_fullProcess(self):
self._import_wf('workflows/security_fullProcess.alf')
self._create_test_users()
(at)(at) -339,7 +334,7 (at)(at)
self._import_wf('workflows/expression_assign.alf')
self._create_test_users()
portal = self.portal
-
+
portal.invokeFactory('DummyContent', 'doc')
doc = portal.doc
doc.test_assignees = ['gack']
(at)(at) -357,7 +352,7 (at)(at)
check_assignees(['author'])
check_assignees(['author', 'foobar'])
check_assignees([])
-
+
def test_relevant_users_by_expression_fail(self):
self.assertRaises(ConfigurationError, self._import_wf,
'workflows/expression_assign_fail.alf')
(at)(at) -365,7 +360,7 (at)(at)
def test_relevant_users_by_expression_fail2(self):
self.assertRaises(ConfigurationError, self._import_wf,
'workflows/expression_assign_fail2.alf')
-
+
def test_relevant_users_by_expression_fail3(self):
self.assertRaises(ConfigurationError, self._import_wf,
'workflows/expression_assign_fail3.alf')
(at)(at) -392,7 +387,7 (at)(at)
# wrong keys raise KeyError
self.assertRaises(KeyError, method, obj, 'gaack')
self.assertRaises(KeyError, method, obj2, 'heinrich')
-
+
def _check_afterupdate(exp_roles, obj, method):
# relevant users should have the exp_role roles
(at)(at) -401,10 +396,10 (at)(at)
# wrong keys raise KeyError
self.assertRaises(KeyError, method, obj, 'foobar')
-
+
content = ContentMock('content-uid')
content2 = ContentMock('wuuuuuha')
-
+
_check(['Assignee'], wi, wi2, alf.getDynamicRolesForWorkItem)
_check(['ProcessUser'], wi.getInstance(), InstanceMock('wuuut'),
alf.getDynamicRolesForInstance)
(at)(at) -421,7 +416,7 (at)(at)
_checkrelevant(got)
got = alf.listRelevantUsersForContent(content)
_checkrelevant(got)
-
+
alf.updateCacheByWorkItem(wi2)
_check(['Assignee'], wi, wi2, alf.getDynamicRolesForWorkItem)
_check_afterupdate(['ProcessUser'], wi.getInstance(),
(at)(at) -434,7 +429,7 (at)(at)
self._import_wf('workflows/cachetest.alf')
self._create_test_users()
portal = self.portal
-
+
alf = getToolByName(portal, 'workflow_manager')
portal.invokeFactory('DummyContent', 'doc')
(at)(at) -444,22 +439,22 (at)(at)
instance = doc.getInstance()
instance.start("Los gehts")
wi = instance.getWorkItems()[0]
-
+
self.assertEquals(['Assignee'],
alf.getDynamicRolesForWorkItem(wi, 'hans'))
self.assertEquals(['ProcessUser'],
alf.getDynamicRolesForInstance(instance, 'hans'))
-
+
doc.test_assignees = ['heinrich']
wi.notifyAssigneesChange()
-
+
self.assertRaises(KeyError,
alf.getDynamicRolesForWorkItem, wi, 'hans')
self.assertEquals(['Assignee'],
alf.getDynamicRolesForWorkItem(wi, 'heinrich'))
self.assertEquals(['ProcessUser'],
alf.getDynamicRolesForInstance(instance,
'heinrich'))
-
+
wi_old = wi
assignees = ['Ernie', 'Bert']
doc.test_assignees = assignees
(at)(at) -472,7 +467,6 (at)(at)
for assignee in assignees:
self.assertEquals(['Assignee'],
alf.getDynamicRolesForWorkItem(wi, assignee))
-
self.assertEquals(['ProcessUser'],
alf.getDynamicRolesForInstance(instance,
assignee))
(at)(at) -491,7 +485,7 (at)(at)
self._import_wf('workflows/cachetest_multi.alf')
self._create_test_users()
portal = self.portal
-
+
alf = getToolByName(portal, 'workflow_manager')
portal.invokeFactory('DummyContent', 'doc')
(at)(at) -506,23 +500,23 (at)(at)
alf.getDynamicRolesForContent(doc, 'hans'))
self.assertEquals(['ProcessUser'],
alf.getDynamicRolesForContent(doc, 'hubert'))
-
+
doc.test_assignees2 = ['karlheinz']
alf.updateCacheByContent(doc)
-
+
self.assertEquals(['ProcessUser'],
alf.getDynamicRolesForContent(doc, 'hans'))
self.assertEquals(['ProcessUser'],
alf.getDynamicRolesForContent(doc, 'karlheinz'))
self.assertRaises(KeyError,
alf.getDynamicRolesForContent, doc, 'hubert')
-
+
def test_incrementalpermissions(self):
self.loginAsPortalOwner()
self._import_wf('workflows/permission.alf')
self._create_test_users()
portal = self.portal
-
+
alf = getToolByName(portal, 'workflow_manager')
portal.invokeFactory('DummyContent', 'doc')
(at)(at) -537,7 +531,7 (at)(at)
got_roles = getRolesOfPermission(doc, "Modify portal content")
got_roles.sort()
self.assertEquals(expected_roles, got_roles)
-
+
# step 2
self.login("author")
wi = instance.getWorkItems()[0]
(at)(at) -571,7 +565,7 (at)(at)
self._import_wf('workflows/task_group.alf')
self._create_test_users()
portal = self.portal
-
+
portal.invokeFactory('DummyContent', 'doc')
doc = portal.doc
doc.assignProcess('test')
(at)(at) -588,7 +582,7 (at)(at)
self._import_wf('workflows/expression_member.alf')
self._create_test_users()
portal = self.portal
-
+
portal.invokeFactory('DummyContent', 'doc')
doc = portal.doc
doc.assignProcess('test')
(at)(at) -599,12 +593,8 (at)(at)
self.assertEquals("author", doc.member)
-
+
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(SecurityTest))
return suite
-
-if __name__ == '__main__':
- framework()
-
Modified: AlphaFlow/trunk/tests/test_simpledecision.py
==============================================================================
--- AlphaFlow/trunk/tests/test_simpledecision.py (original)
+++ AlphaFlow/trunk/tests/test_simpledecision.py Thu Mar 1 00:41:17 2007
(at)(at) -9,7 +9,7 (at)(at)
from Products.AlphaFlow.tests.AlphaFlowTestCase import AlphaFlowTestCase
from Products.AlphaFlow.interfaces import IDecisionWorkItem,
ISimpleDecisionActivity
from Products.AlphaFlow.activities.simpledecision import
SimpleDecisionWorkItem, SimpleDecisionActivity
-from Products.AlphaFlow.exception import ConfigurationError
+
class SimpleDecisionTest(AlphaFlowTestCase):
(at)(at) -17,7 +17,7 (at)(at)
(IDecisionWorkItem, SimpleDecisionWorkItem),
(ISimpleDecisionActivity, SimpleDecisionActivity)
]
-
+
def _init_object(self):
# Creates a simple workflow
portal = self.portal
(at)(at) -41,7 +41,6 (at)(at)
doc.assignProcess('test')
return doc
-
def _get_object(self):
portal = self.portal
mtool = getToolByName(portal, 'portal_membership')
(at)(at) -52,45 +51,41 (at)(at)
instance = doc.getInstance()
wi = instance.getWorkItems()[0]
wi.getActionById(action)()
-
def test_simpledecision(self):
doc = self._init_object()
instance = doc.getInstance()
instance.start("testing")
self.assertEqual(instance.state, "active")
-
+
wis = instance.getWorkItems(state='active')
self.assertEqual(1, len(wis)) # configuration
self.assertEqual('config_deci_1', wis[0].getActivity().getId())
instance.deci_1_assignees = ["editor1", "editor3"]
wis[0].configure()
-
+
wis = instance.getWorkItems(state='active')
self.assertEqual(2, len(wis))
wis[0].reject()
wis[1].accept()
-
+
wis = instance.getWorkItems(state='active')
self.assertEqual(3, len(wis))
wis[0].accept()
wis[1].accept()
wis[2].reject()
-
+
wis = instance.getWorkItems(state='active')
self.assertEqual(2, len(wis))
wis[0].accept()
wis[1].accept()
-
+
wis = instance.getWorkItems(state='active')
self.assertEqual(0, len(wis))
self.assertEqual('complete', instance.state)
+
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(SimpleDecisionTest))
return suite
-
-if __name__ == '__main__':
- framework()
-
Modified: AlphaFlow/trunk/tests/test_workitem.py
==============================================================================
--- AlphaFlow/trunk/tests/test_workitem.py (original)
+++ AlphaFlow/trunk/tests/test_workitem.py Thu Mar 1 00:41:17 2007
(at)(at) -4,19 +4,18 (at)(at)
import unittest
-from Products.CMFCore.utils import getToolByName
-
from Products.AlphaFlow.tests.AlphaFlowTestCase import AlphaFlowTestCase
from Products.AlphaFlow.workitem import BaseWorkItem
-from Products.AlphaFlow.instance import Instance
from Acquisition import Implicit
+
class ContentDummy:
def UID(self):
return 1
+
class DummyInstance(Implicit):
def __getitem__(self, key, default=None):
(at)(at) -28,6 +27,7 (at)(at)
def getInstance(self):
return self
+
class WorkItemTest(AlphaFlowTestCase):
interfaces_to_test = []
(at)(at) -63,12 +63,8 (at)(at)
pi["G1a"].generated_by = "W2"
self.failUnless(pi["G1a"].isChildOf("R"))
-
+
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(WorkItemTest))
return suite
-
-if __name__ == '__main__':
- framework()
-
|
SVN: r4509 - in AlphaFlow/trunk: . activities tests
Christian Theune <ct(at)gocept.com> |
2007-03-01 00:49:10 |
[ FULL ]
|
Author: ctheune
Date: Thu Mar 1 00:49:08 2007
New Revision: 4509
Modified:
AlphaFlow/trunk/activities/recursion.py
AlphaFlow/trunk/migration.py
AlphaFlow/trunk/processmanager.py
AlphaFlow/trunk/tests/test_definition.py
AlphaFlow/trunk/tests/test_patch.py
Log:
- fixed transaction API usage
Modified: AlphaFlow/trunk/activities/recursion.py
==============================================================================
--- AlphaFlow/trunk/activities/recursion.py (original)
+++ AlphaFlow/trunk/activities/recursion.py Thu Mar 1 00:49:08 2007
(at)(at) -6,6 +6,7 (at)(at)
# Zope imports
from AccessControl import ClassSecurityInfo
import zLOG
+import transaction
# Plone/AT imports
from Products.CMFCore.utils import getToolByName
(at)(at) -172,7 +173,7 (at)(at)
wi.recordAction("active",
"Activated by recursion for context %s. "
%
uid)
- get_transaction().commit(1)
+ transaction.savepoint()
security.declarePrivate('onStart')
def onStart(self):
Modified: AlphaFlow/trunk/migration.py
==============================================================================
--- AlphaFlow/trunk/migration.py (original)
+++ AlphaFlow/trunk/migration.py Thu Mar 1 00:49:08 2007
(at)(at) -2,6 +2,7 (at)(at)
# See also LICENSE.txt
# $Id$
+import transaction
from BTrees.OOBTree import OOBTree
from Products.CMFCore.utils import getToolByName
(at)(at) -62,11 +63,11 (at)(at)
if candidate in open_route_workitems:
continue
closed_route_workitems.append(candidate)
-
+
del wi.open_routes
wi.closed_routes = closed_route_workitems
-
- get_transaction().commit(1)
+
+ transaction.savepoint()
def migrate_rolecache_to_btree(self):
Modified: AlphaFlow/trunk/processmanager.py
==============================================================================
--- AlphaFlow/trunk/processmanager.py (original)
+++ AlphaFlow/trunk/processmanager.py Thu Mar 1 00:49:08 2007
(at)(at) -10,6 +10,7 (at)(at)
# Zope imports
import zExceptions
import zLOG
+import transaction
from webdav.NullResource import NullResource
from OFS.Folder import Folder
from Products.PageTemplates.PageTemplateFile import PageTemplateFile
(at)(at) -368,7 +369,7 (at)(at)
item.changeState('fallout', 'Fallout on calling
trigger_workitem', info)
getToolByName(self, 'error_log').raising(info)
if config.ENABLE_ZODB_COMMITS:
- get_transaction().commit()
+ transaction.commit()
finally:
ping_lock.release()
(at)(at) -395,7 +396,7 (at)(at)
workitem.changeState("active", "Automatic restart by restart
helper.")
restarted += 1
if config.ENABLE_ZODB_COMMITS:
- get_transaction().commit()
+ transaction.commit()
if REQUEST is not None:
REQUEST.RESPONSE.redirect(self.absolute_url() +
Modified: AlphaFlow/trunk/tests/test_definition.py
==============================================================================
--- AlphaFlow/trunk/tests/test_definition.py (original)
+++ AlphaFlow/trunk/tests/test_definition.py Thu Mar 1 00:49:08 2007
(at)(at) -4,6 +4,7 (at)(at)
import os
import unittest
+import transaction
from random import shuffle
from tempfile import mktemp
from xml.dom import minidom
(at)(at) -538,7 +539,7 (at)(at)
self._import_wf()
portal = self.portal
content = self.create(portal, 'DummyContent', 'doc1')
- get_transaction().commit(1)
+ transaction.savepoint()
content.assignProcess('test')
content.getInstance().start('test')
self.assert_(content.hasInstanceAssigned())
(at)(at) -562,7 +563,7 (at)(at)
instance = folder.getInstance()
instance.edit(recursion_apply=True)
instance.start('test')
- get_transaction().commit(1)
+ transaction.savepoint()
data = portal.manage_exportObject('f1', download=True)
file_name = mktemp()
Modified: AlphaFlow/trunk/tests/test_patch.py
==============================================================================
--- AlphaFlow/trunk/tests/test_patch.py (original)
+++ AlphaFlow/trunk/tests/test_patch.py Thu Mar 1 00:49:08 2007
(at)(at) -3,6 +3,7 (at)(at)
# $Id$
import unittest
+import transaction
from Products.AlphaFlow.interfaces import IAlphaFlowed
from Products.AlphaFlow import config
(at)(at) -27,7 +28,7 (at)(at)
portal.invokeFactory(type, 'testid-%s' % type)
doc = getattr(portal, 'testid-%s' % type)
self.failUnless(hasattr(doc, 'getSuitableProcesses'))
- get_transaction().commit(1)
+ transaction.savepoint()
def test_suite():
|
SVN: r4511 - in AlphaFlow/trunk: . activities doc tests tests/workflows
Christian Theune <ct(at)gocept.com> |
2007-03-01 02:45:02 |
[ FULL ]
|
Author: ctheune
Date: Thu Mar 1 02:44:58 2007
New Revision: 4511
Removed:
AlphaFlow/trunk/activities/condition.py
AlphaFlow/trunk/activities/review.py
AlphaFlow/trunk/tests/test_condition.py
Modified:
AlphaFlow/trunk/__init__.py
AlphaFlow/trunk/activities/alarm.py
AlphaFlow/trunk/activities/interfaces.py
AlphaFlow/trunk/activities/permission.py
AlphaFlow/trunk/activity.py
AlphaFlow/trunk/doc/ROADMAP.txt
AlphaFlow/trunk/interfaces.py
AlphaFlow/trunk/tests/test_configuration.py
AlphaFlow/trunk/tests/test_definition.py
AlphaFlow/trunk/tests/workflows/alarm_review.alf
AlphaFlow/trunk/tests/workflows/catalog_security.alf
AlphaFlow/trunk/tests/workflows/multi_review.alf
AlphaFlow/trunk/tests/workflows/multi_review_with_config.alf
AlphaFlow/trunk/tests/workflows/old_role.alf
AlphaFlow/trunk/tests/workflows/routing_delayed_discriminator.alf
AlphaFlow/trunk/tests/workflows/routing_example.alf
AlphaFlow/trunk/tests/workflows/security_fullProcess.alf
AlphaFlow/trunk/utils.py
AlphaFlow/trunk/workitem.py
Log:
- removed deprecated features
- 4 tests are still failing, this is a snapshot
Modified: AlphaFlow/trunk/__init__.py
==============================================================================
--- AlphaFlow/trunk/__init__.py (original)
+++ AlphaFlow/trunk/__init__.py Thu Mar 1 02:44:58 2007
(at)(at) -34,8 +34,8 (at)(at)
def initialize_activities(context):
from activities import \
- task, review, permission, version, expression, dcworkflow, \
- recursion, notify, alarm, condition, routing, gates, ntask, \
+ task, permission, version, expression, dcworkflow, \
+ recursion, notify, alarm, routing, gates, ntask, \
decision, simpledecision, configuration, parent, switch, roleassign
Modified: AlphaFlow/trunk/activities/alarm.py
==============================================================================
--- AlphaFlow/trunk/activities/alarm.py (original)
+++ AlphaFlow/trunk/activities/alarm.py Thu Mar 1 02:44:58 2007
(at)(at) -8,25 +8,32 (at)(at)
from AccessControl import ClassSecurityInfo
# Sibling imports
-from Products.AlphaFlow.workitem import registerWorkItem, BaseTalesWorkItem
-from Products.AlphaFlow.activity import registerActivity, BaseTalesActivity
+from Products.AlphaFlow.workitem import registerWorkItem,
BaseAutomaticWorkItem
+from Products.AlphaFlow.activity import registerActivity,
BaseAutomaticActivity
from Products.AlphaFlow.interfaces import IAlarmActivity, IAlarmWorkItem
-from Products.AlphaFlow import config
+from Products.AlphaFlow.workflowattr import WorkflowAttribute
+from Products.AlphaFlow import config, utils
-
-class AlarmActivity(BaseTalesActivity):
- __implements__ = BaseTalesActivity.__implements__ + (IAlarmActivity, )
+class AlarmActivity(BaseAutomaticActivity):
+
+ __implements__ = BaseAutomaticActivity.__implements__ + (IAlarmActivity, )
meta_type = "AlphaFlow Alarm Activity"
activity_type = nodeName = "alarm"
icon = "misc_/AlphaFlow/alarm"
-
-class AlarmWorkItem(BaseTalesWorkItem):
+ attributes = BaseAutomaticActivity.attributes + (
+ WorkflowAttribute('due', 'due', '',
+ 'TALES expression that determines the date when '
+ 'this alarm is due.',
+ required=True),)
+
+
+class AlarmWorkItem(BaseAutomaticWorkItem):
- __implements__ = BaseTalesWorkItem.__implements__ + (IAlarmWorkItem, )
+ __implements__ = BaseAutomaticWorkItem.__implements__ + (IAlarmWorkItem, )
security = ClassSecurityInfo()
-
+
activity_type = "alarm"
security.declarePrivate('onStart')
(at)(at) -37,9 +44,9 (at)(at)
security.declarePrivate('trigger_workitem')
def trigger_workitem(self):
"""triggers a workitem if the deadline is exceeded"""
- deadline = self.evaluate()
+ activity = self.getActivity()
+ deadline = utils.evaluateTales(self, activity.due)
if deadline.isPast():
- activity = self.getActivity()
self.createWorkItems(activity.continue_activity)
self.changeState("complete", activity.title_or_id())
(at)(at) -51,8 +58,8 (at)(at)
elif self.state == 'complete':
return "deadline exceeded"
return "Error Status"
-
-
+
+
# register the stuff
registerActivity(AlarmActivity)
registerWorkItem(AlarmWorkItem)
Modified: AlphaFlow/trunk/activities/interfaces.py
==============================================================================
--- AlphaFlow/trunk/activities/interfaces.py (original)
+++ AlphaFlow/trunk/activities/interfaces.py Thu Mar 1 02:44:58 2007
(at)(at) -150,11 +150,13 (at)(at)
"""Implements the permission change"""
-class IAlarmActivity(ITalesActivity):
+class IAlarmActivity(IAutomaticActivity):
""" Triggers a work item on a given DateTime."""
+ due = Attribute('TALES expression when this alarm is due.')
-class IAlarmWorkItem(ITalesWorkItem):
+
+class IAlarmWorkItem(IAutomaticWorkItem):
""" Implements the alarm configuration for the activity """
def trigger_workitem():
(at)(at) -238,38 +240,3 (at)(at)
class IRoleAssignWorkItem(IAutomaticWorkItem):
"""Sets a given set of roles to the configured users."""
-
-
-
-##################
-# deprecated stuff
-
-class IReviewActivity(IAssignableActivity):
- """Makes a consensus vote"""
-
- # XXX deprecated
-
-
-class IReviewWorkItem(IAssignableWorkItem):
-
- # XXX deprecated
-
- def reject():
- """Rejects the review."""
-
- def accept():
- """Accepts the review."""
-
-
-class IConditionActivity(ITalesActivity):
- """Gets a TALES-expression which returns a list of activity ids (defined
- in the current workflow) which get generated as WorkItems.
- """
-
- # XXX deprecated
-
-
-class IConditionWorkItem(ITalesWorkItem):
- """condition workitem"""
-
- # XXX deprecated
Modified: AlphaFlow/trunk/activities/permission.py
==============================================================================
--- AlphaFlow/trunk/activities/permission.py (original)
+++ AlphaFlow/trunk/activities/permission.py Thu Mar 1 02:44:58 2007
(at)(at) -28,11 +28,6 (at)(at)
attributes = (WorkflowAttribute('permission', 'name', '',
'The permission affected.',
encoding="ascii", datatype=str),
- WorkflowAttribute('permission', 'id', '',
- 'id is deprecated, use name!',
- encoding="ascii", datatype=str,
- importHandler='_attr_import_permid',
- exportHandler=None),
WorkflowAttribute('roles', 'roles', '',
'Sequence of affected roles.',
encoding="ascii", datatype=tuple),
(at)(at) -58,13 +53,6 (at)(at)
raise ConfigurationError, \
"The permission %r does not exist." % permission
- def _attr_import_permid(self, attr, node):
- if self.permission == '':
- warn('<permission id="..." /> is deprecated, use name="..."
instead. '
- 'id will get removed in version 1.1.',
- DeprecationWarning, stacklevel=4)
- self._attr_import_simple(attr, node)
-
def apply(self, content):
"""Apply the permission setting on the content object."""
modifyRolesForPermission(content, self.permission, self.roles,
(at)(at) -130,11 +118,6 (at)(at)
def setPermissions(self, permission_setting):
permissions = []
for data in permission_setting:
- if isinstance(data, tuple):
- warn('Using setPermission with a list of tuples is deprecated,
use a list of dictionaries instead.'
- 'Support for tuples will get removed in version 1.1 ',
DeprecationWarning)
- permissions.append(PermissionSetting(self, *data))
- continue
if data['type'] == 'add':
permissions.append(PermissionAddSetting(self,
data['permission'], data['roles']))
elif data['type'] == 'remove':
Modified: AlphaFlow/trunk/activity.py
==============================================================================
--- AlphaFlow/trunk/activity.py (original)
+++ AlphaFlow/trunk/activity.py Thu Mar 1 02:44:58 2007
(at)(at) -11,7 +11,7 (at)(at)
from Products.Archetypes import public as atapi
from Products.AlphaFlow.interfaces import \
- IActivity, IAutomaticActivity, ITalesActivity, IAssignableActivity
+ IActivity, IAutomaticActivity, IAssignableActivity
from Products.AlphaFlow import config, utils
from Products.AlphaFlow.exception import ConfigurationError
from Products.AlphaFlow.workflowattr import \
(at)(at) -297,8 +297,6 (at)(at)
security.declarePrivate('_attr_import_assignees')
def _attr_import_assignees(self, attr, node):
- if node.hasAttribute('roles'):
- raise ConfigurationError, 'The roles attribute is deprecated.'
assignees = node.getElementsByTagName('assignees')
if len(assignees) == 0:
# default behaviour
(at)(at) -339,27 +337,6 (at)(at)
InitializeClass(BaseAssignableActivity)
-class BaseTalesActivity(BaseAutomaticActivity):
- "Activity based on execution of a TALES-expression."
-
- __implements__ = BaseAutomaticActivity.__implements__ + \
- (ITalesActivity, )
- security = ClassSecurityInfo()
- icon = "misc_/AlphaFlow/basetalesactivity"
-
- attributes = BaseAutomaticActivity.attributes + (
- WorkflowAttribute('expression', 'expression', '',
- 'TALES expression which is to be executed.',
- required=True),
- )
-
- _properties = BaseAutomaticActivity._properties + \
- ({'id': 'expression', 'type': 'string', 'mode': 'w'},
- )
-
-InitializeClass(BaseTalesActivity)
-
-
class MultipleExitsMixin:
"Mixin class that collects possible children from a sequence of exits."
Modified: AlphaFlow/trunk/doc/ROADMAP.txt
==============================================================================
--- AlphaFlow/trunk/doc/ROADMAP.txt (original)
+++ AlphaFlow/trunk/doc/ROADMAP.txt Thu Mar 1 02:44:58 2007
(at)(at) -5,12 +5,14 (at)(at)
2.0
---
- - Fix deprecations
+ - check XXX
- - remove get_transaction()
+ - Fix deprecations
- Remove deprecated workitems
+ - make manage_add/delete use events
+
- Remove editor
- Remove XML exporter
Modified: AlphaFlow/trunk/interfaces.py
==============================================================================
--- AlphaFlow/trunk/interfaces.py (original)
+++ AlphaFlow/trunk/interfaces.py Thu Mar 1 02:44:58 2007
(at)(at) -550,13 +550,6 (at)(at)
def getActivityTitleOrId():
"""Return the title or id of the activity this is an instance of."""
- def getActivityConfiguration(field):
- """Return the configuration for this activity in the context of this
- process instance.
-
- Deprecated: use instance.getActivityConfiguration()
- """
-
def getParent():
"""Return the parent work item or None if this is a root work item."""
(at)(at) -681,25 +674,6 (at)(at)
"""Method performing the actual activity."""
-class ITalesActivity(IAutomaticActivity):
- """Activity based on execution of a TALES-expression.
-
- Expressions are run as TALES expressions and have the following contexts:
-
- work item - the current work item
- object - the object associated with this process
- activity - the activity for this work item
- portal - the portal root object
- """
-
-
-class ITalesWorkItem(IAutomaticWorkItem):
- """WorkItem which uses TALES-Expression."""
-
- def evaluate():
- "Evaluate the TALES-Expression."
-
-
##############
# helper stuff
Modified: AlphaFlow/trunk/tests/test_configuration.py
==============================================================================
--- AlphaFlow/trunk/tests/test_configuration.py (original)
+++ AlphaFlow/trunk/tests/test_configuration.py Thu Mar 1 02:44:58 2007
(at)(at) -59,10 +59,9 (at)(at)
wis = instance.getWorkItems()
self.assertEqual(1, len(wis))
gs = wis[0].getGroupedSchema()
- act_ids_expected = ['write_document', 'review_document1',
'config_at_start']
- act_ids_expected.sort()
- act_ids_got = [ g.activity_id for g in gs ]
- act_ids_got.sort()
+ act_ids_expected = sorted(['write_document', 'review_document1',
+ 'review_document2', 'config_at_start'])
+ act_ids_got = sorted([g.activity_id for g in gs])
self.assertEquals(act_ids_expected, act_ids_got)
self.assertEquals(gs[0].Title(), 'Dokument schreiben')
Modified: AlphaFlow/trunk/tests/test_definition.py
==============================================================================
--- AlphaFlow/trunk/tests/test_definition.py (original)
+++ AlphaFlow/trunk/tests/test_definition.py Thu Mar 1 02:44:58 2007
(at)(at) -22,21 +22,21 (at)(at)
from Products.AlphaFlow.tests.content import DummyContent
from Products.AlphaFlow.interfaces import \
- IProcess, IAlphaFlowed, IInstance, IActivity, IWorkItem, ITalesActivity, \
- IAutomaticWorkItem, IAction, IReviewWorkItem, IReviewActivity, \
+ IProcess, IAlphaFlowed, IInstance, IActivity, IWorkItem, \
+ IAutomaticWorkItem, IAction, \
IWorkflowAttribute, IAssignableActivity, IAutomaticActivity, \
IPermissionSetting
from Products.AlphaFlow.workflowedobject import AlphaFlowed
from Products.AlphaFlow.instance import Instance
from Products.AlphaFlow.process import Process
from Products.AlphaFlow.activity import \
- activity_registry, BaseTalesActivity, BaseAssignableActivity, \
+ activity_registry, BaseAssignableActivity, \
BaseActivity, BaseAutomaticActivity
from Products.AlphaFlow.workitem import \
BaseWorkItem, BaseAutomaticWorkItem, workitem_registry
from Products.AlphaFlow.action import Action
-from Products.AlphaFlow.activities.review import ReviewWorkItem,
ReviewActivity
from Products.AlphaFlow.activities.permission import PermissionSetting
+from Products.AlphaFlow.activities.decision import DecisionWorkItem
from Products.AlphaFlow.utils import flexSplit
from Products.AlphaFlow.exception import ConfigurationError
from Products.AlphaFlow.workflowattr import \
(at)(at) -80,19 +80,15 (at)(at)
(IAutomaticWorkItem, BaseAutomaticWorkItem),
(IAction, Action),
(IProcess, Process),
- (IReviewActivity, ReviewActivity),
(IWorkflowAttribute, WorkflowAttribute),
- (ITalesActivity, BaseTalesActivity),
(IAssignableActivity, BaseAssignableActivity),
(IActivity, BaseActivity),
(IAutomaticActivity, BaseAutomaticActivity),
- (IPermissionSetting, PermissionSetting),
- (IReviewWorkItem, ReviewWorkItem)] + \
+ (IPermissionSetting, PermissionSetting)] + \
[(IActivity, activity_registry.get(act_id))
for act_id in activity_registry.keys() ] + \
[(IWorkItem, workitem_registry.get(wi_id))
for wi_id in workitem_registry.keys()]
-
def _check_DOM_equality(self, exp_dom, got_dom, wf_name):
"""Check, if two DOMs are equal
(at)(at) -274,17 +270,20 (at)(at)
# "vote" is an activity, that asks people if something should
# proceed or not
- check_document = process.addActivity("check_document", "review")
+ check_document = process.addActivity("check_document", "decision")
process.check_document.reject_activity = ("write_document",)
process.check_document.accept_activity = ("publish_document",)
+ process.check_document.decision_modus = 'all_yes'
+ process.check_document.decision_notice = u'Decide something!'
# "permission-change" is an activity, that updates the permissions
# to match a publication state
publish_document = process.addActivity("publish_document",
"permission-change")
- publish_document.setPermissions([('View', ['Anonymous'], False),
- ('Modify portal content',
- ['Manager'], True)])
+ publish_document.setPermissions([{'type':'set', 'permission': 'View',
+ 'roles':['Anonymous'],
'acquire':False},
+ {'type':'set', 'permission': 'Modify
portal content',
+ 'roles': ['Manager'],
'acquire':True}])
# Let's create some content
portal.createObject("testdocument", "DummyContent")
(at)(at) -495,7 +494,7 (at)(at)
p.close()
def test_getActionById(self):
- wi = ReviewWorkItem('asdf', 'pups')
+ wi = DecisionWorkItem('asdf', 'pups')
self.assertEqual(wi.getActionById('accept').id, 'accept')
self.assertEqual(wi.getActionById('reject').id, 'reject')
self.assertRaises(KeyError, wi.getActionById, 'asdf')
Modified: AlphaFlow/trunk/tests/workflows/alarm_review.alf
==============================================================================
--- AlphaFlow/trunk/tests/workflows/alarm_review.alf (original)
+++ AlphaFlow/trunk/tests/workflows/alarm_review.alf Thu Mar 1 02:44:58 2007
(at)(at) -4,15 +4,15 (at)(at)
<workflow id="testworkflow"
startActivity="edit_ticket deadline"
onlyAllowRoles="Manager Reviewer Member">
-
+
<task id="edit_ticket"
title="Ticket bearbeiten"
sort="1"
completion_activity="deadline" />
-
+
<alarm id="deadline"
title="Wiedervorlage"
- expression="object/deadline"
+ due="object/deadline"
continue_activity="notify" />
<dcworkflow id="notify"
Modified: AlphaFlow/trunk/tests/workflows/catalog_security.alf
==============================================================================
--- AlphaFlow/trunk/tests/workflows/catalog_security.alf (original)
+++ AlphaFlow/trunk/tests/workflows/catalog_security.alf Thu Mar 1 02:44:58
2007
(at)(at) -33,22 +33,24 (at)(at)
<dcworkflow id="dc_pending" status="pending"/>
<!-- reviewer -->
- <review id="review_document1" title="Dokument prüfen" sort="2"
- review_notice="Bitte auf inhaltliche Ausgestaltung achten."
- reject_activity="make_private"
- accept_activity="review_document2" >
- <assignees kind="possible" roles='Reviewer' />
- </review>
+ <decision id="review_document1" title="Dokument prüfen" sort="2"
+ decision_notice="Bitte auf inhaltliche Ausgestaltung achten."
+ decision_modus="all_yes"
+ reject_activity="make_private"
+ accept_activity="review_document2" >
+ <assignees kind="possible" roles='Reviewer' />
+ </decision>
<!-- chief editor -->
- <rolebased-review id="review_document2"
+ <decision id="review_document2"
title="Dokument prüfen (verantwortlicher Redakteur)"
sort="3"
- review_notice="Bitte auf formelle Kriterien achten."
+ decision_notice="Bitte auf formelle Kriterien achten."
+ decision_modus="all_yes"
reject_activity="make_private"
accept_activity="publish">
<assignees kind="possible" roles="ChiefEditor" />
- </rolebased-review>
+ </decision>
<!-- Publish the document -->
<permission-change id="publish" title="Öffentliche Rechte setzen"
continue_activity="dc_publish">
Modified: AlphaFlow/trunk/tests/workflows/multi_review.alf
==============================================================================
--- AlphaFlow/trunk/tests/workflows/multi_review.alf (original)
+++ AlphaFlow/trunk/tests/workflows/multi_review.alf Thu Mar 1 02:44:58 2007
(at)(at) -67,30 +67,32 (at)(at)
status="pending" />
<!-- reviewer -->
- <review id="review_document1"
+ <decision id="review_document1"
title="Dokument prüfen"
sort="2"
- review_notice="Bitte auf inhaltliche Ausgestaltung achten."
+ decision_notice="Bitte auf inhaltliche Ausgestaltung achten."
+ decision_modus="all_yes"
reject_activity="make_private"
accept_activity="review_document2">
<assignees kind="possible"
roles="Reviewer" />
- </review>
+ </decision>
<!-- chief editor -->
- <rolebased-review id="review_document2"
- title="Dokument prüfen (verantwortlicher Redakteur)"
- sort="3"
- review_notice="Bitte auf formelle Kriterien achten."
- reject_activity="make_private"
- accept_activity="publish">
+ <decision id="review_document2"
+ title="Dokument prüfen (verantwortlicher Redakteur)"
+ sort="3"
+ decision_notice="Bitte auf formelle Kriterien achten."
+ decision_modus="all_yes"
+ reject_activity="make_private"
+ accept_activity="publish">
<assignees kind="actual"
expression="python:['editor3']" />
- </rolebased-review>
+ </decision>
<!-- Publish the document -->
<permission-change id="publish"
Modified: AlphaFlow/trunk/tests/workflows/multi_review_with_config.alf
==============================================================================
--- AlphaFlow/trunk/tests/workflows/multi_review_with_config.alf (original)
+++ AlphaFlow/trunk/tests/workflows/multi_review_with_config.alf Thu Mar 1
02:44:58 2007
(at)(at) -73,30 +73,32 (at)(at)
status="pending" />
<!-- reviewer -->
- <review id="review_document1"
+ <decision id="review_document1"
title="Dokument prüfen"
sort="2"
- review_notice="Bitte auf inhaltliche Ausgestaltung achten."
+ decision_notice="Bitte auf inhaltliche Ausgestaltung achten."
+ decision_modus="all_yes"
reject_activity="make_private"
accept_activity="review_document2">
<assignees kind="possible"
roles="Reviewer" />
- </review>
+ </decision>
<!-- chief editor -->
- <rolebased-review id="review_document2"
+ <decision id="review_document2"
title="Dokument prüfen (verantwortlicher Redakteur)"
sort="3"
- review_notice="Bitte auf formelle Kriterien achten."
+ decision_notice="Bitte auf formelle Kriterien achten."
+ decision_modus="all_yes"
reject_activity="make_private"
accept_activity="publish">
<assignees kind="possible"
roles="ChiefEditor" />
- </rolebased-review>
+ </decision>
<!-- Publish the document -->
<permission-change id="publish"
Modified: AlphaFlow/trunk/tests/workflows/old_role.alf
==============================================================================
--- AlphaFlow/trunk/tests/workflows/old_role.alf (original)
+++ AlphaFlow/trunk/tests/workflows/old_role.alf Thu Mar 1 02:44:58 2007
(at)(at) -36,18 +36,20 (at)(at)
<dcworkflow id="dc_pending" title="" status="pending"/>
<!-- reviewer -->
- <review id="review_document1" title="Dokument prüfen" sort="2"
- review_notice="Bitte auf inhaltliche Ausgestaltung achten."
+ <decision id="review_document1" title="Dokument prüfen" sort="2"
+ decision_notice="Bitte auf inhaltliche Ausgestaltung achten."
roles="Reviewer"
+ decision_modus="all_yes"
reject_activity="make_private"
accept_activity="review_document2"
/>
<!-- chief editor -->
- <rolebased-review id="review_document2"
+ <decision id="review_document2"
title="Dokument prüfen (verantwortlicher Redakteur)"
sort="3"
- review_notice="Bitte auf formelle Kriterien achten."
+ decision_notice="Bitte auf formelle Kriterien achten."
+ decision_modus="all_yes"
roles="ChiefEditor"
reject_activity="make_private"
accept_activity="publish"/>
Modified: AlphaFlow/trunk/tests/workflows/routing_delayed_discriminator.alf
==============================================================================
---
AlphaFlow/trunk/tests/workflows/routing_delayed_discriminator.alf (original)
+++ AlphaFlow/trunk/tests/workflows/routing_delayed_discriminator.alf Thu Mar
1 02:44:58 2007
(at)(at) -9,24 +9,27 (at)(at)
startActivity="visible"
title="Decisions by Marketing, Medical and Legal Departments">
- <rolebased-review id="review_legal"
- title="Check legal issues"
- review_notice="Please check any legal issues that might
occur."
- reject_activity="reject"
- accept_activity="accept" />
-
- <rolebased-review id="review_mkt"
- title="Check Marketing"
- review_notice="Check if this marketing works."
- reject_activity="reject"
- accept_activity="accept" />
-
- <rolebased-review id="review_medical"
- title="Check medical issues"
- review_notice="Please check for medical issues."
- reject_activity="reject"
- accept_activity="accept" />
-
+ <decision id="review_legal"
+ title="Check legal issues"
+ decision_notice="Please check any legal issues that might
occur."
+ decision_modus="all_yes"
+ reject_activity="reject"
+ accept_activity="accept" />
+
+ <decision id="review_mkt"
+ title="Check Marketing"
+ decision_notice="Check if this marketing works."
+ decision_modus="all_yes"
+ reject_activity="reject"
+ accept_activity="accept" />
+
+ <decision id="review_medical"
+ title="Check medical issues"
+ decision_notice="Please check for medical issues."
+ decision_modus="all_yes"
+ reject_activity="reject"
+ accept_activity="accept" />
+
<gate id="reject"
title="Reject review"
mode="delayed-discriminate"
Modified: AlphaFlow/trunk/tests/workflows/routing_example.alf
==============================================================================
--- AlphaFlow/trunk/tests/workflows/routing_example.alf (original)
+++ AlphaFlow/trunk/tests/workflows/routing_example.alf Thu Mar 1 02:44:58
2007
(at)(at) -9,17 +9,24 (at)(at)
<route id="review"
title="Decisions by Marketing, Medical and Legal Departments">
- <rolebased-review id="review_legal"
- title="Check legal issues"
- review_notice="Please check any legal issues that might
occur."
- reject_activity="reject"
- accept_activity="accept" />
-
- <rolebased-review id="review_mkt"
- title="Check Marketing"
- review_notice="Check if this marketing works."
- reject_activity="reject"
- accept_activity="accept" />
+ <decision id="review_legal"
+ title="Check legal issues"
+ decision_notice="Please check any legal issues that might
occur."
+ decision_modus="all_yes"
+ reject_activity="reject"
+ accept_activity="accept">
+ <assignees kind="actual" expression="python:['author']"/>
+ </decision>
+
+ <decision id="review_mkt"
+ title="Check Marketing"
+ decision_notice="Check if this marketing works."
+ decision_modus="all_yes"
+ reject_activity="reject"
+ accept_activity="accept" >
+ <assignees kind="actual" expression="python:['author']"/>
+ </decision>
+
<dcworkflow id="visible"
status="visible"
(at)(at) -37,11 +44,15 (at)(at)
</route>
- <rolebased-review id="review_medical"
- title="Check medical issues"
- review_notice="Please check for medical issues."
- reject_activity="reject"
- accept_activity="accept" />
+ <decision id="review_medical"
+ title="Check medical issues"
+ decision_notice="Please check for medical issues."
+ decision_modus="all_yes"
+ reject_activity="reject"
+ accept_activity="accept">
+ <assignees kind="actual" expression="python:['author']"/>
+ </decision>
+
<dcworkflow id="private"
status="private" />
Modified: AlphaFlow/trunk/tests/workflows/security_fullProcess.alf
==============================================================================
--- AlphaFlow/trunk/tests/workflows/security_fullProcess.alf (original)
+++ AlphaFlow/trunk/tests/workflows/security_fullProcess.alf Thu Mar 1
02:44:58 2007
(at)(at) -72,30 +72,32 (at)(at)
status="pending" />
<!-- reviewer -->
- <review id="review_document1"
+ <decision id="review_document1"
title="Dokument prüfen"
sort="2"
- review_notice="Bitte auf inhaltliche Ausgestaltung achten."
+ decision_notice="Bitte auf inhaltliche Ausgestaltung achten."
+ decision_modus="all_yes"
reject_activity="make_private"
accept_activity="review_document2">
<assignees kind="possible"
roles="Reviewer" />
- </review>
+ </decision>
<!-- chief editor -->
- <rolebased-review id="review_document2"
- title="Dokument prüfen (verantwortlicher Redakteur)"
- sort="3"
- review_notice="Bitte auf formelle Kriterien achten."
- reject_activity="make_private"
- accept_activity="publish">
+ <decision id="review_document2"
+ title="Dokument prüfen (verantwortlicher Redakteur)"
+ sort="3"
+ decision_notice="Bitte auf formelle Kriterien achten."
+ decision_modus="all_yes"
+ reject_activity="make_private"
+ accept_activity="publish">
<assignees kind="possible"
roles="ChiefEditor" />
- </rolebased-review>
+ </decision>
<!-- Publish the document -->
<permission-change id="publish"
Modified: AlphaFlow/trunk/utils.py
==============================================================================
--- AlphaFlow/trunk/utils.py (original)
+++ AlphaFlow/trunk/utils.py Thu Mar 1 02:44:58 2007
(at)(at) -91,21 +91,18 (at)(at)
return r
-def modifyRolesForPermission(ob, pname, roles, acquire=None):
+def modifyRolesForPermission(ob, pname, roles, acquire):
'''
- Modifies multiple role to permission mappings.
-
+ Modifies multiple role to permission mappings.
+
If acquire is None: roles is a list to acquire, a tuple to not acquire.
'''
- if acquire is None:
- warn('Using modifyRolesForPermission without "acquire" parameter '
- 'is depcrecated.', DeprecationWarning, stacklevel=2)
- elif acquire:
+ if acquire:
roles = list(roles)
else:
roles = tuple(roles)
-
+
# This mimics what AccessControl/Role.py does.
data = ()
for perm in ac_inherited_permissions(ob, 1):
Modified: AlphaFlow/trunk/workitem.py
==============================================================================
--- AlphaFlow/trunk/workitem.py (original)
+++ AlphaFlow/trunk/workitem.py Thu Mar 1 02:44:58 2007
(at)(at) -26,7 +26,7 (at)(at)
DynamicLocalRoleSupport, LocalRoleFakeBase, modifyRolesForPermission,
\
ContentObjectRetrieverBase
from Products.AlphaFlow.interfaces import \
- IWorkItem, IAlphaFlowed, IAutomaticWorkItem, ITalesWorkItem, \
+ IWorkItem, IAlphaFlowed, IAutomaticWorkItem, \
IAssignableActivity, IAssignableWorkItem, IFieldGroup
from Products.AlphaFlow.registry import Registry
(at)(at) -372,13 +372,9 (at)(at)
"""Retrieves the configuration for this activity in the context of
this instance.
"""
- warn('Using workitem.getActivityConfiguration is deprecated, use '
- 'instance.getActivityConfiguration instead.',
- DeprecationWarning, stacklevel=2)
instance = self.getInstance()
return instance.getActivityConfiguration(field, self.activity_id,
default=default)
-
security.declarePrivate("createWorkItems")
def createWorkItems(self, activity_ids, content_object=None):
(at)(at) -477,7 +473,7 (at)(at)
def listRelevantUsers(self):
if self.state != "active":
return []
-
+
activity = self.getActivity()
assert IAssignableActivity.isImplementedBy(activity)
if activity.assigneesKind == 'possible':
(at)(at) -636,24 +632,6 (at)(at)
InitializeClass(BaseAutomaticWorkItem)
-class BaseTalesWorkItem(BaseAutomaticWorkItem):
-
- __implements__ = BaseAutomaticWorkItem.__implements__ + \
- (ITalesWorkItem, )
- security = ClassSecurityInfo()
- last_triggered_by = ''
-
- security.declarePrivate('evaluate')
- def evaluate(self):
- "Evaluate the TALES-Expression."
- warn('BaseTalesActivity and BaseTalesWorkItem are deprecated.',
- DeprecationWarning, stacklevel=2)
- self.last_triggered_by = getToolByName(self,
'portal_membership').getAuthenticatedMember()
- activity = self.getActivity()
- return utils.evaluateTales(self, activity.expression)
-
-InitializeClass(BaseTalesWorkItem)
-
################
# Helper classes
|
SVN: r4544 - AlphaFlow/trunk/activities
Christian Theune <ct(at)gocept.com> |
2007-03-01 16:02:49 |
[ FULL ]
|
Author: ctheune
Date: Thu Mar 1 16:02:47 2007
New Revision: 4544
Log:
- whitespace / docs
Modified:
AlphaFlow/trunk/activities/parent.py
AlphaFlow/trunk/activities/switch.py
Modified: AlphaFlow/trunk/activities/parent.py
==============================================================================
--- AlphaFlow/trunk/activities/parent.py (original)
+++ AlphaFlow/trunk/activities/parent.py Thu Mar 1 16:02:47 2007
(at)(at) -40,14 +40,16 (at)(at)
security.declareProtected(config.MANAGE_WORKFLOW, 'getPossibleChildren')
def getPossibleChildren(self):
- # all possible parents of the parentOf could be a spawend by us
-
+ """This activity can start any activity that is a possible
+ parent of the activity in our 'parentOf' attribute.
+ """
process = self.acquireProcess()
parent_name = self.parentOf
possible = []
-
+
for activity_id in process.listActivityIds():
if activity_id == self.getId():
+ # Avoid infinite recursion.
continue
activity = process[activity_id]
if parent_name in activity.getPossibleChildren():
Modified: AlphaFlow/trunk/activities/switch.py
==============================================================================
--- AlphaFlow/trunk/activities/switch.py (original)
+++ AlphaFlow/trunk/activities/switch.py Thu Mar 1 16:02:47 2007
(at)(at) -1,22 +1,21 (at)(at)
# Copyright (c) 2005-2006 gocept gmbh & co. kg
# See also LICENSE.txt
# $Id$
-"""Walk through a list of cases, each of which carries a TALES expression
- which may evaluate to either True (the case being considered a match) or
- False. Depending on the switch mode, either stop after the first match or
- visit all cases. Create WorkItems from the activities of all matches found.
+"""A switch activity.
- toplevel variables for TALES expression see ITalesActivity
- """
+Walk through a list of cases, each of which carries a TALES expression which
+may evaluate to either True (the case being considered a match) or False.
+Depending on the switch mode, either stop after the first match or visit all
+cases. Create WorkItems from the activities of all matches found.
+
+"""
-# Python imports
import sys
-# Zope imports
from AccessControl import ClassSecurityInfo
-# Sibling imports
-from Products.AlphaFlow.workitem import registerWorkItem,
BaseAutomaticWorkItem
+from Products.AlphaFlow.workitem import \
+ registerWorkItem, BaseAutomaticWorkItem
from Products.AlphaFlow.activity import \
registerActivity, BaseAutomaticActivity, MultipleExitsMixin
from Products.AlphaFlow.interfaces import ISwitchActivity, ISwitchWorkItem
(at)(at) -25,15 +24,15 (at)(at)
WorkflowAttribute, InitializeWorkflowAttributes
from Products.AlphaFlow.activities.common import Exit
-
+
class Case(Exit):
+
nodeName = "case"
attributes = Exit.attributes + (
WorkflowAttribute("condition", "condition", None,
- "TALES expression returning True or False."
- ),)
+ "TALES expression returning True or False."),)
+
-
class SwitchActivity(BaseAutomaticActivity, MultipleExitsMixin):
__implements__ = BaseAutomaticActivity.__implements__ + \
(at)(at) -66,8 +65,8 (at)(at)
def graphGetPossibleChildren(self):
"""Return a list of possible following activities with labels."""
return self._graph_get_possible_children_from_exits(self.cases)
-
-
+
+
class SwitchWorkItem(BaseAutomaticWorkItem):
__implements__ = BaseAutomaticWorkItem.__implements__ + \
(at)(at) -103,7 +102,7 (at)(at)
self.createWorkItems(workitems)
self.changeState("complete", activity.title_or_id())
-
+
# register the stuff
InitializeWorkflowAttributes(Case)
registerActivity(SwitchActivity)
|
SVN: r4545 - in AlphaFlow/trunk/tests: . workflows
Christian Theune <ct(at)gocept.com> |
2007-03-01 16:03:16 |
[ FULL ]
|
Author: ctheune
Date: Thu Mar 1 16:03:15 2007
New Revision: 4545
Log:
- fixed two failing tests by removing references to deprecated (and deleted)
activities
Modified:
AlphaFlow/trunk/tests/test_parent.py
AlphaFlow/trunk/tests/workflows/parent.alf
Modified: AlphaFlow/trunk/tests/test_parent.py
==============================================================================
--- AlphaFlow/trunk/tests/test_parent.py (original)
+++ AlphaFlow/trunk/tests/test_parent.py Thu Mar 1 16:03:15 2007
(at)(at) -34,7 +34,7 (at)(at)
doc.setRoute = setRoute
doc.note = note
-
+
doc.assignProcess('test')
doc.route = 'escalate'
instance = doc.getInstance()
(at)(at) -43,16 +43,15 (at)(at)
# escalate again
self.assertEquals('active', instance.state)
ntask = doc.getWorkItemsForCurrentUser()[0].complete('escalate')
-
+
self.assertEquals('active', instance.state)
ntask = doc.getWorkItemsForCurrentUser()[0].complete('finish')
-
+
self.assertEquals('complete', instance.state)
self.assertEquals(['start', 'escalate', 'start', 'normal', 'escalate',
'normal', 'finish'],
notes)
-
def test_possible_children(self):
self._import_wf('workflows/parent.alf')
portal = self.portal
(at)(at) -61,9 +60,7 (at)(at)
parent_activity = proc.exit_escalation
possible = parent_activity.getPossibleChildren()
- possible.sort()
-
- self.assertEquals(['normal', 'start'], possible)
+ self.assertEquals(['normal', 'start'], sorted(possible))
def test_suite():
Modified: AlphaFlow/trunk/tests/workflows/parent.alf
==============================================================================
--- AlphaFlow/trunk/tests/workflows/parent.alf (original)
+++ AlphaFlow/trunk/tests/workflows/parent.alf Thu Mar 1 16:03:15 2007
(at)(at) -15,16 +15,26 (at)(at)
<expression id="change_route_normal"
expression="python: object.setRoute('normal')" />
- <condition id="start"
- startActivity="note_start"
- continue_activity="escalate normal"
- expression="python:[object.route]" />
+ <switch id="start" mode="first"
+ startActivity="note_start">
+ <case id="escalate"
+ activities="escalate"
+ condition="python:object.route == 'escalate'"/>
+ <case id="normal"
+ activities="normal"
+ condition="python:object.route == 'normal'"
+ />
+ </switch>
-
- <condition id="escalate"
- startActivity="change_route_normal note_escalate"
- continue_activity="exit_escalation"
- expression="python:['exit_escalation']"/>
+ <switch id="escalate"
+ mode="first"
+ startActivity="change_route_normal note_escalate">
+ <case
+ id="exit"
+ activities="exit_escalation"
+ condition="python:True"
+ />
+ </switch>
<parent id="exit_escalation"
continue_with_parent_of="escalate" />
|
SVN: r4546 - in AlphaFlow/trunk/tests: . workflows
Christian Theune <ct(at)gocept.com> |
2007-03-01 16:29:25 |
[ FULL ]
|
Author: ctheune
Date: Thu Mar 1 16:29:23 2007
New Revision: 4546
Log:
- fixed remaining broken tests
Removed:
AlphaFlow/trunk/tests/workflows/condition.alf
Modified:
AlphaFlow/trunk/tests/test_security.py
AlphaFlow/trunk/tests/workflows/routing_delayed_discriminator.alf
Modified: AlphaFlow/trunk/tests/test_security.py
==============================================================================
--- AlphaFlow/trunk/tests/test_security.py (original)
+++ AlphaFlow/trunk/tests/test_security.py Thu Mar 1 16:29:23 2007
(at)(at) -319,17 +319,6 (at)(at)
wi.update(comment="Ging so, kleine Aenderungen")
wi.accept()
- # Editor 3 reviews document
- self.login('editor3')
- portal = self.portal
- wftool = getToolByName(portal, "workflow_manager")
- mtool = getToolByName(portal, 'portal_membership')
- home = mtool.getHomeFolder("editor1")
- doc = home.doc
- wi = wftool.getWorkItemsForCurrentUser()[0]
- wi.update(comment="tchoa")
- wi.accept()
-
def test_relevant_users_by_expression(self):
self._import_wf('workflows/expression_assign.alf')
self._create_test_users()
Modified: AlphaFlow/trunk/tests/workflows/routing_delayed_discriminator.alf
==============================================================================
---
AlphaFlow/trunk/tests/workflows/routing_delayed_discriminator.alf (original)
+++ AlphaFlow/trunk/tests/workflows/routing_delayed_discriminator.alf Thu Mar
1 16:29:23 2007
(at)(at) -14,21 +14,28 (at)(at)
decision_notice="Please check any legal issues that might
occur."
decision_modus="all_yes"
reject_activity="reject"
- accept_activity="accept" />
+ accept_activity="accept">
+ <assignees kind="actual" expression="python:['author']"/>
+ </decision>
+
<decision id="review_mkt"
title="Check Marketing"
decision_notice="Check if this marketing works."
decision_modus="all_yes"
reject_activity="reject"
- accept_activity="accept" />
+ accept_activity="accept">
+ <assignees kind="actual" expression="python:['author']"/>
+ </decision>
<decision id="review_medical"
title="Check medical issues"
decision_notice="Please check for medical issues."
decision_modus="all_yes"
reject_activity="reject"
- accept_activity="accept" />
+ accept_activity="accept">
+ <assignees kind="actual" expression="python:['author']"/>
+ </decision>
<gate id="reject"
title="Reject review"
|
SVN: r4547 - in AlphaFlow/trunk: . Extensions activities doc
Christian Theune <ct(at)gocept.com> |
2007-03-01 17:26:46 |
[ FULL ]
|
Author: ctheune
Date: Thu Mar 1 17:26:42 2007
New Revision: 4547
Log:
- removed zLOG to avoid deprecation warnings
- roadmap update
Modified:
AlphaFlow/trunk/Extensions/Install.py
AlphaFlow/trunk/activities/recursion.py
AlphaFlow/trunk/doc/ROADMAP.txt
AlphaFlow/trunk/instance.py
AlphaFlow/trunk/processmanager.py
AlphaFlow/trunk/utils.py
Modified: AlphaFlow/trunk/Extensions/Install.py
==============================================================================
--- AlphaFlow/trunk/Extensions/Install.py (original)
+++ AlphaFlow/trunk/Extensions/Install.py Thu Mar 1 17:26:42 2007
(at)(at) -21,11 +21,9 (at)(at)
# Python imports
import os
+import logging
from StringIO import StringIO
-# Zope imports
-import zLOG
-
# CMF imports
from Products.CMFCore.utils import getToolByName
from Products.CMFCore import permissions
(at)(at) -37,7 +35,7 (at)(at)
# Sibling imports
from Products.AlphaFlow import config, migration
from Products.AlphaFlow.workitem import workitem_registry
-from Products.AlphaFlow.utils import modifyRolesForPermission
+from Products.AlphaFlow.utils import modifyRolesForPermission, logger
from Products.AlphaFlow.Extensions import dcworkflow
(at)(at) -59,9 +57,9 (at)(at)
for field in instance.Schema().fields():
fieldname = field.getName()
if fieldname.endswith('_assignees'):
- zLOG.LOG("AlphaFlow Migration",
- zLOG.INFO,
- "Instance '%s': migrating assignee" %
instance.getId())
+ logger.log(logging.INFO,
+ "Instance '%s': migrating assignee" %
+ instance.getId())
if hasattr(instance, fieldname[:-1]):
# fieldname before update was "assignee"
field.set(instance, getattr(instance, fieldname[:-1]))
Modified: AlphaFlow/trunk/activities/recursion.py
==============================================================================
--- AlphaFlow/trunk/activities/recursion.py (original)
+++ AlphaFlow/trunk/activities/recursion.py Thu Mar 1 17:26:42 2007
(at)(at) -3,9 +3,10 (at)(at)
# $Id$
"""Recursion activity and work item."""
+import logging
+
# Zope imports
from AccessControl import ClassSecurityInfo
-import zLOG
import transaction
# Plone/AT imports
(at)(at) -17,13 +18,11 (at)(at)
from Products.AlphaFlow.workitem import registerWorkItem,
BaseAutomaticWorkItem
from Products.AlphaFlow.activity import \
registerActivity, BaseAutomaticActivity
-from Products.AlphaFlow import config
+from Products.AlphaFlow import config, utils
from Products.AlphaFlow.interfaces import IDaemonActivity
from Products.AlphaFlow.workflowattr import WorkflowAttribute
-
-
class RecursionActivity(BaseAutomaticActivity):
__implements__ = BaseAutomaticActivity.__implements__ + (IDaemonActivity,)
(at)(at) -149,8 +148,8 (at)(at)
all_objects = []
# Build object list first, and don't trust the catalog
- zLOG.LOG("AlphaFlow", zLOG.DEBUG,
- "Building up object list for %s" % root)
+ utils.logger.log(logging.DEBUG,
+ "Building up object list for %s" % root)
stack = [root]
while stack:
obj = stack.pop()
(at)(at) -159,13 +158,13 (at)(at)
stack.extend(values)
all_objects.extend([ ob.UID() for ob in values])
len_all_obs = len(all_objects)
- zLOG.LOG("AlphaFlow", zLOG.DEBUG, "Items found: %s" % len_all_obs)
+ utils.logger.log(logging.DEBUG, "Items found: %s" % len_all_obs)
for item in to_run:
number = 0
for uid in all_objects:
number += 1
- zLOG.LOG("AlphaFlow", zLOG.DEBUG,
- "Number: %s of %s " % (number, len_all_obs))
+ utils.logger.log(logging.DEBUG,
+ "Number: %s of %s " % (number, len_all_obs))
wi_ids = instance.createWorkItems([item], self,
content_object=uid)
for id in wi_ids:
Modified: AlphaFlow/trunk/doc/ROADMAP.txt
==============================================================================
--- AlphaFlow/trunk/doc/ROADMAP.txt (original)
+++ AlphaFlow/trunk/doc/ROADMAP.txt Thu Mar 1 17:26:42 2007
(at)(at) -11,12 +11,6 (at)(at)
- make manage_add/delete use events
- - zLOG
-
- - Remove editor
-
- - Remove XML exporter
-
- Change installation to GenericSetup
- Write MS Visio importer
Modified: AlphaFlow/trunk/instance.py
==============================================================================
--- AlphaFlow/trunk/instance.py (original)
+++ AlphaFlow/trunk/instance.py Thu Mar 1 17:26:42 2007
(at)(at) -6,12 +6,12 (at)(at)
# Python imports
import sys
+import logging
import os
# Zope imports
from zExceptions.ExceptionFormatter import format_exception
import zExceptions
-import zLOG
from Globals import InitializeClass
from AccessControl import getSecurityManager, ClassSecurityInfo
from DateTime import DateTime
(at)(at) -258,9 +258,9 (at)(at)
"""
if not activity_ids:
return ()
-
- zLOG.LOG('AlphaFlow', zLOG.DEBUG,
- 'Creating workitems %r in %r' % (activity_ids, source))
+
+ utils.logger.log(logging.DEBUG,
+ 'Creating workitems %r in %r' % (activity_ids, source))
# During recursion notifyWorkItemStateChange will be deferred until
# this method has been completed (i.e. the recursion ends)
Modified: AlphaFlow/trunk/processmanager.py
==============================================================================
--- AlphaFlow/trunk/processmanager.py (original)
+++ AlphaFlow/trunk/processmanager.py Thu Mar 1 17:26:42 2007
(at)(at) -3,13 +3,14 (at)(at)
# $Id$
"""Process manager"""
+
# Python imports
import sys
+import logging
from threading import Lock
# Zope imports
import zExceptions
-import zLOG
import transaction
from webdav.NullResource import NullResource
from OFS.Folder import Folder
(at)(at) -416,14 +417,16 (at)(at)
ignored += 1
else:
dropped_in += 1
-
+
if REQUEST is not None:
-
REQUEST.RESPONSE.redirect(self.absolute_url()+"/manage_tools?manage_tabs_message=%s+instances+dropped+in.+%s+instances+ignored."
% (dropped_in, ignored))
-
+ REQUEST.RESPONSE.redirect(self.absolute_url()+
+
"/manage_tools?manage_tabs_message=%s+instances+dropped+in.+%s+instances+ignored."
%
+ (dropped_in, ignored))
+
security.declareProtected(config.MANAGE_WORKFLOW, 'sanityCheck')
def sanityCheck(self, REQUEST=None):
"""IProcessManager"""
-
+
def _clean_object(o, path):
local_roles = o.__ac_local_roles__
try:
(at)(at) -451,22 +454,22 (at)(at)
if instance is None:
return
c2 = instance.getContentObject()
-
+
if c1.aq_base is not c2.aq_base:
- zLOG.LOG("AlphaFlow", zLOG.WARNING,
- "Not sane: %r (%r, %r)" % (instance, c1, c2))
+ utils.logger.log(logging.WARN,
+ "Not sane: %r (%r, %r)" % (instance, c1, c2))
c1.alf_clearInstances()
-
+
def _check(o, path):
if IAlphaFlowed.isImplementedBy(o):
_check_double_refs(o, path)
_clean_object(o, path)
-
+
portal = getToolByName(self, 'portal_url').getPortalObject()
cat = getToolByName(self, 'portal_catalog')
cat.ZopeFindAndApply(portal, search_sub=True,
apply_func=_check)
-
+
if REQUEST is not None:
REQUEST.RESPONSE.redirect(
'%s/manage_tools?manage_tabs_message=Sanity+check+done.'\
Modified: AlphaFlow/trunk/utils.py
==============================================================================
--- AlphaFlow/trunk/utils.py (original)
+++ AlphaFlow/trunk/utils.py Thu Mar 1 17:26:42 2007
(at)(at) -5,15 +5,13 (at)(at)
""" Some common utilities.
"""
-# Python imports
import os
import urlparse
import time
import random
-from warnings import warn
+import logging
from types import ListType
-# Zope imports
from Globals import InitializeClass
from App.Common import package_home
from ExtensionClass import Base
(at)(at) -24,10 +22,8 (at)(at)
from AccessControl.Role import gather_permissions
from AccessControl.Permission import Permission, registerPermissions
-# CMF/Plone imports
from Products.CMFCore.utils import getToolByName
-# Sibling imports
from Products.AlphaFlow import config
from Products.AlphaFlow.interfaces import \
IWorkItem, IActivity
(at)(at) -36,18 +32,18 (at)(at)
_www = os.path.join(os.path.dirname(__file__), 'www')
_dtmldir = os.path.join( package_home( globals() ), 'dtml' )
-
+
def getPermissionsOfRole(obj, role):
permissions = obj.permissionsOfRole(role)
permissions = [ perm['name'] for perm in permissions
if perm['selected'] ]
return permissions
-
+
def removePermissionsFromRoles(obj, roles, permissions):
for role in roles:
current_permissions = getPermissionsOfRole(obj, role)
-
+
for permission in permissions:
try:
current_permissions.remove(permission)
(at)(at) -55,7 +51,7 (at)(at)
pass
obj.manage_role(role, current_permissions)
-
+
def addPermissionsToRoles(obj, roles, permissions):
for role in roles:
current_permissions = getPermissionsOfRole(obj, role)
(at)(at) -64,14 +60,14 (at)(at)
current_permissions.append(permission)
obj.manage_role(role, current_permissions)
-
+
def getRolesOfPermission(obj, permission):
roles = obj.rolesOfPermission(permission)
roles = [ role['name'] for role in roles
if role['selected'] ]
return roles
-
+
def ac_inherited_permissions(ob, all=0):
# Get all permissions not defined in ourself that are inherited
# This will be a sequence of tuples with a name as the first item and
(at)(at) -90,7 +86,7 (at)(at)
r = list(perms) + r
return r
-
+
def modifyRolesForPermission(ob, pname, roles, acquire):
'''
Modifies multiple role to permission mappings.
(at)(at) -117,25 +113,24 (at)(at)
return 0
-
def listMembersWithRoles(context, roles=[]):
"""return members who have one of the given roles in context
-
+
roles: if empty, no role restriction
returns sequence of member data objects
-
+
"""
pm = getToolByName(context, 'portal_membership')
members = pm.listMembers()
return _filter_memberdata(context, members, roles)
-
+
def listMembersWithRolesAndLocalRoles(content, roles=[]):
"""return members who have one of the given roles in context
-
+
roles: if empty, no role restriction
returns sequence of member ids
-
+
"""
context = content.getParentNode()
members = listMembersWithRoles(context, roles)
(at)(at) -156,7 +151,7 (at)(at)
intersection = [ r for r in user_roles if r in roles ]
if intersection:
ids.append(username)
-
+
# the 'Owner' role is not in the _original dict
if 'Owner' in roles:
owner = content.getOwnerTuple()
(at)(at) -169,6 +164,7 (at)(at)
ids = unique(ids)
return ids
+
def expandGroups(groupstool, usergrouplist):
"""expands groups in a list of user ids recursively"""
newlist = []
(at)(at) -190,6 +186,7 (at)(at)
return newlist
+
def listGroupsWithRoles(context, roles=[]):
"""return groups who have one of the given roles in context
(at)(at) -200,6 +197,7 (at)(at)
groups = pm.listGroups()
return _filter_memberdata(context, groups, roles)
+
def _filter_memberdata(context, members, roles):
if roles:
# make a dict for performance reasons (should avoid O(n**2))
(at)(at) -214,42 +212,41 (at)(at)
filtered_members = members
return filtered_members
-
+
def registerPermission(permission, default_roles):
registerPermissions([(permission, [])], default_roles)
-
def unique(alist):
d = {}
for item in alist:
d[item] = 1
return d.keys()
-
+
def findFile(name):
search_list = [INSTANCE_HOME, SOFTWARE_HOME]
- if not (isinstance(search_list, ListType) or
+ if not (isinstance(search_list, ListType) or
isinstance(search_list, TypleType)):
- search_list = [search_list]
+ search_list = [search_list]
name_list = []
while name != '':
name, name_end = os.path.split(name)
name_list.insert(0, name_end)
name = name_list
-
+
filepath = None
for path in search_list:
- filepath = os.path.join(path, *name)
+ filepath = os.path.join(path, *name)
if os.path.exists(filepath):
break
else:
filepath = None
- return filepath
+ return filepath
+
-
class DynamicLocalRoleSupport(Base):
local_role_fake_class = None
(at)(at) -266,10 +263,8 (at)(at)
return self.local_role_fake_class(self, local_roles)
__ac_local_roles__ = ComputedAttribute(__ac_local_roles__method, 1)
-
-
- # Those are required until Zope 2.8
+ # XXX Those are required until Zope 2.8
def manage_delLocalRoles(self, userids, REQUEST=None):
"""Remove all local roles for a user."""
(at)(at) -304,7 +299,7 (at)(at)
dict=self.__ac_local_roles__
if dict is None:
self.__ac_local_roles__ = dict = {}
-
+
# make sure we don't blend in dynamic roles:
try:
non_computed_dict = dict._original
(at)(at) -321,7 +316,6 (at)(at)
stat='Your changes have been saved.'
return self.manage_listLocalRoles(self, REQUEST, stat=stat)
-
class LocalRoleFakeBase:
"""fakes a dictionary for local role support"""
(at)(at) -332,19 +326,19 (at)(at)
self._processmanager = getToolByName(context, 'workflow_manager')
def __getitem__(self, user):
-
+
try:
roles = self._get_rolecache_for_user(user)
except KeyError:
roles = []
-
+
# We need to automatically blend in the Owner role,
# as ObjectManager.py is a bit choicy about when to
# add it. Actually you can't revoke the Owner role
# from the Owner anymore ... but who cares.
if user == self._get_owner():
roles.append("Owner")
-
+
try:
roles.extend(self._original[user])
except KeyError:
(at)(at) -366,7 +360,7 (at)(at)
def keys(self):
dict_keys = self._original.keys()
relevant_keys = self._get_users_with_cached_roles()
-
+
owner = self._get_owner()
if owner is not None:
relevant_keys.append(owner)
(at)(at) -394,9 +388,8 (at)(at)
def __getattr__(self, name):
return getattr(self._original, name)
-
-
+
def makeBoolFromUnicode(s):
mapping = {
'false': False,
(at)(at) -416,7 +409,7 (at)(at)
raise ValueError, "Do not know how to convert %r to bool" % (s, )
return b
-
+
def killWorkItemRecursively(wi, reason):
if wi.state in ['active', 'fallout']:
wi.changeState("terminated", reason)
(at)(at) -427,17 +420,17 (at)(at)
if wi.state in ['active', 'fallout']:
wi.changeState("terminated", reason + " (recursively terminated)")
-
+
def flexSplit(string):
string = string.replace(',', ' ')
result = string.split(' ')
result = [ x for x in result if x ] # filter out empty
return result
-
-
+
+
def importWorkflows(self, out, product_globals):
"""install workflows from Product/xxx/workflow directory
-
+
This is a helper function for the quickinstaller. It installes all
workflows (*.alf) with * as id
"""
(at)(at) -453,13 +446,12 (at)(at)
alf.deleteProcess(base)
print >>out, "Installing %r workflow" % base
alf.importWorkflowFromXML(base, wf_file)
-
-
+
def evaluateTales(context, expression):
"Evaluate the TALES-Expression as SuperUser"
return evaluateTalesAs(context, expression, SpecialUsers.system)
-
+
def evaluateTalesAs(context, expression, run_as):
"Evaluate the TALES-Expression a s a given user"
expression_compiled = getEngine().compile(expression)
(at)(at) -476,11 +468,11 (at)(at)
object = context.getContentObject()
if object is None:
object = context
-
+
portal = pu.getPortalObject()
workitem = None
activity = None
-
+
if IWorkItem.isImplementedBy(context):
workitem = context
activity = workitem.getActivity()
(at)(at) -511,7 +503,7 (at)(at)
'currentUser': member.getUser(),
'systemUser': SpecialUsers.system,
}
-
+
engine = getEngine()
variables = {'request': None,
'content': object,
(at)(at) -528,19 +520,17 (at)(at)
return context
-
def urlAppendToQueryString(url, extend):
"""Append the extendstring to the querystring of the url."""
schema, netloc, path, parameters, query, fragment = urlparse.urlparse(url)
return urlparse.urlunparse((schema, netloc, path, parameters,
query+'&'+extend, fragment))
-
-
+
def generateUniqueId(prefix=None):
"""generate unique id like plone does
-
+
we do not care about readability, but about speed
-
+
preifx: optional string, not containing whitespace or strange
characters
"""
(at)(at) -550,7 +540,7 (at)(at)
id = str(now) + str(random.randint(0, 100000))
return prefix + '.' + id
-
+
class ContentObjectRetrieverBase:
"""stub for implementing IContentObjectRetriever"""
(at)(at) -583,7 +573,6 (at)(at)
ob_path = brain.getPath()
path = '%s/%s' % (portal.absolute_url(), ob_path)
return path
-
security.declareProtected(config.WORK_WITH_PROCESS,
'getContentObjectPath')
def getContentObjectPath(self):
(at)(at) -608,11 +597,10 (at)(at)
if brains:
brain = brains[0]
return brain
-
+
InitializeClass(ContentObjectRetrieverBase)
-
from types import FunctionType, ClassType
from ExtensionClass import Base
(at)(at) -631,7 +619,7 (at)(at)
self.model = model
self.field = field
self.field_class = field.__class__
-
+
def copy(self):
"""Return a copy."""
return self.field.copy()
(at)(at) -644,7 +632,7 (at)(at)
installmethod(attr, self, name)
attr = getattr(self, name)
return attr
-
+
def __repr__(self):
"""Return string repr"""
return "<MultiplexedField %s>" % repr(self.field)
(at)(at) -656,7 +644,7 (at)(at)
# we don't have generated accessors on the instance (because we're
# working around class generation), therefore we need to return our
# own accessors and mutators:
-
+
def getAccessor(self, instance):
return self.accessor
(at)(at) -676,10 +664,9 (at)(at)
self.field_class.set(self, self.model, value, **kw)
-
def installmethod(function, object, name = None):
"""Add a bound method to an instance
-
+
If name is ommited it defaults to the name of the given function.
"""
from types import ClassType, MethodType, InstanceType
(at)(at) -689,6 +676,7 (at)(at)
function = renamefunction(function, name)
setattr(object, name, MethodType(function, object, object.__class__))
+
def renamefunction(function, name):
"""
This function returns a function identical to the given one, but
(at)(at) -708,6 +696,7 (at)(at)
function.func_defaults)
return FunctionType(c, function.func_globals, name)
+
def runAs(user, call, *args, **kw):
"""Switch security manager (safely) to a manager user and back"""
old_security_manager = getSecurityManager()
(at)(at) -717,8 +706,10 (at)(at)
finally:
setSecurityManager(old_security_manager)
+
def mailhostTestingModePatch():
- """Patch mailhost to prevent sending mails, save them in attribute
'outbox' (a list)"""
+ """Patch mailhost to prevent sending mails, save them in attribute
+ 'outbox' (a list)"""
from Products.MailHost.MailHost import MailHost
def _send(self, mfrom, mto, messageText, debug=False):
outbox = getattr(self, 'outbox', [])
(at)(at) -727,9 +718,12 (at)(at)
MailHost._send = _send
- #plone2.1 compatiblity
+ # XXX plone2.1 compatiblity
try:
from Products.SecureMailHost.SecureMailHost import SecureMailBase
SecureMailBase._send = _send
except ImportError:
pass
+
+
+logger = logging.getLogger('AlphaFlow')
|
SVN: r4549 - AlphaFlow/trunk/tests
Christian Theune <ct(at)gocept.com> |
2007-03-01 17:39:42 |
[ FULL ]
|
Author: ctheune
Date: Thu Mar 1 17:39:40 2007
New Revision: 4549
Log:
- fixe deprecation
Modified:
AlphaFlow/trunk/tests/test_roleassign.py
Modified: AlphaFlow/trunk/tests/test_roleassign.py
==============================================================================
--- AlphaFlow/trunk/tests/test_roleassign.py (original)
+++ AlphaFlow/trunk/tests/test_roleassign.py Thu Mar 1 17:39:40 2007
(at)(at) -22,7 +22,7 (at)(at)
def test_roleassign(self):
self.loginAsPortalOwner()
self._create_test_users()
- portal = self.getPortal()
+ portal = self.portal
doc = self.create(portal, 'DummyContent', 'doc1')
wi = RoleAssignWorkItem('myid', 'my-activity')
|
SVN: r4550 - AlphaFlow/trunk/activities
Christian Theune <ct(at)gocept.com> |
2007-03-01 17:39:47 |
[ FULL ]
|
Author: ctheune
Date: Thu Mar 1 17:39:46 2007
New Revision: 4550
Log:
- removed print debugging code
Modified:
AlphaFlow/trunk/activities/notify.py
Modified: AlphaFlow/trunk/activities/notify.py
==============================================================================
--- AlphaFlow/trunk/activities/notify.py (original)
+++ AlphaFlow/trunk/activities/notify.py Thu Mar 1 17:39:46 2007
(at)(at) -154,7 +154,7 (at)(at)
# XXX do not send email if member has no email address
set.
# XXX maybe we should log this.
continue
-
+
mail_variables = {'member': member,
'work_items': work_items}
mail_body = template(self, self.REQUEST, **mail_variables)
(at)(at) -165,7 +165,6 (at)(at)
mail = MIMEText.MIMEText(mail_body, 'plain', siteEncoding)
for key, val in mail_header_data.items():
mail[key] = val
- print "sending email to %s" % member.getProperty('email')
portal.MailHost._send(portal_properties.email_from_address,
member.getProperty('email'),
mail.as_string())
|
SVN: r4551 - AlphaFlow/trunk
Christian Theune <ct(at)gocept.com> |
2007-03-01 18:08:02 |
[ FULL ]
|
SVN: r4552 - AlphaFlow/trunk
Christian Theune <ct(at)gocept.com> |
2007-03-01 18:13:32 |
[ FULL ]
|
Author: ctheune
Date: Thu Mar 1 18:13:30 2007
New Revision: 4552
Log:
- removed BBB class
Modified:
AlphaFlow/trunk/workitem.py
Modified: AlphaFlow/trunk/workitem.py
==============================================================================
--- AlphaFlow/trunk/workitem.py (original)
+++ AlphaFlow/trunk/workitem.py Thu Mar 1 18:13:30 2007
(at)(at) -31,18 +31,8 (at)(at)
from Products.AlphaFlow.registry import Registry
-
DEBUG_FALLOUT = os.getenv('ALPHAFLOW_RAISE_ON_FALLOUT')
-
-class LocalRoleFake(dict):
- """backward compatibility
-
- instances get removed during cleanup (in glome, yuck!)
-
- XXX: remove this class after cleanup is out for some versions
- """
-
class WorkItemLocalRoleFake(LocalRoleFakeBase):
(at)(at) -53,7 +43,7 (at)(at)
workitem = self._context
roles = alf.getDynamicRolesForWorkItem(workitem, user)
return roles
-
+
def _get_users_with_cached_roles(self):
return
self._processmanager.listRelevantUsersForWorkItem(self._context)
|
SVN: r4553 - AlphaFlow/trunk
Christian Theune <ct(at)gocept.com> |
2007-03-01 18:14:16 |
[ FULL ]
|
Author: ctheune
Date: Thu Mar 1 18:14:14 2007
New Revision: 4553
Log:
- removed superfluous XXX
Modified:
AlphaFlow/trunk/utils.py
Modified: AlphaFlow/trunk/utils.py
==============================================================================
--- AlphaFlow/trunk/utils.py (original)
+++ AlphaFlow/trunk/utils.py Thu Mar 1 18:14:14 2007
(at)(at) -429,7 +429,7 (at)(at)
def importWorkflows(self, out, product_globals):
- """install workflows from Product/xxx/workflow directory
+ """install workflows from Product/<xyz>/workflow directory
This is a helper function for the quickinstaller. It installes all
workflows (*.alf) with * as id
|
SVN: r4554 - AlphaFlow/trunk
Christian Theune <ct(at)gocept.com> |
2007-03-01 18:15:22 |
[ FULL ]
|
Author: ctheune
Date: Thu Mar 1 18:15:21 2007
New Revision: 4554
Log:
- removed superfluous XXX statement (security comes from the base class)
Modified:
AlphaFlow/trunk/workitem.py
Modified: AlphaFlow/trunk/workitem.py
==============================================================================
--- AlphaFlow/trunk/workitem.py (original)
+++ AlphaFlow/trunk/workitem.py Thu Mar 1 18:15:21 2007
(at)(at) -335,7 +335,6 (at)(at)
actions.append(("", "No action"))
return actions
- # XXX security declaration?
def absolute_url(self, inner=False):
"""A hackish way to use content objects as views.
|
SVN: r4556 - in AlphaFlow/trunk: skins/alphaflow www
Christian Theune <ct(at)gocept.com> |
2007-03-01 22:47:14 |
[ FULL ]
|
Author: ctheune
Date: Thu Mar 1 22:47:11 2007
New Revision: 4556
Log:
- fixed deprecation for toLocalizedTime
Modified:
AlphaFlow/trunk/skins/alphaflow/af_details.pt
AlphaFlow/trunk/www/instanceOverview.zpt
AlphaFlow/trunk/www/workitemOverview.zpt
Modified: AlphaFlow/trunk/skins/alphaflow/af_details.pt
==============================================================================
--- AlphaFlow/trunk/skins/alphaflow/af_details.pt (original)
+++ AlphaFlow/trunk/skins/alphaflow/af_details.pt Thu Mar 1 22:47:11 2007
(at)(at) -30,7 +30,7 (at)(at)
<tr tal:repeat="wi wis">
<td
tal:content="python:wi.getActivity().title_or_id()"></td>
<td tal:content="wi/getShortInfo"></td>
- <td tal:content="python:here.toLocalizedTime(wi.begin,
True)"></td>
+ <td
tal:content="python:path('context/(at)(at)plone').toLocalizedTime(wi.begin,
True)"></td>
<td tal:content="wi/estimateRelevantUsers"></td>
<td i18n:translate=""
tal:content="wi/getStatusInfo"></td>
</tr>
(at)(at) -63,7 +63,7 (at)(at)
<td
tal:content="python:wi.getActivity().title_or_id()"></td>
<td i18n:translate=""
tal:content="wi/getShortInfo"></td>
<td
-
tal:content="python:here.toLocalizedTime(wi.bobobase_modification_time(),
1)">n/a</td>
+
tal:content="python:path('context/(at)(at)plone').toLocalizedTime(wi.bobobase_modification_time(),
1)">n/a</td>
<td i18n:translate=""
tal:content="wi/getStatusInfo"></td>
</tr>
</tbody>
Modified: AlphaFlow/trunk/www/instanceOverview.zpt
==============================================================================
--- AlphaFlow/trunk/www/instanceOverview.zpt (original)
+++ AlphaFlow/trunk/www/instanceOverview.zpt Thu Mar 1 22:47:11 2007
(at)(at) -86,9 +86,9 (at)(at)
</td>
<td class="form-text">
- <span tal:replace="python:workitem.begin and
here.toLocalizedTime(workitem.begin, True) or ''"/>
+ <span tal:replace="python:workitem.begin and
path('context/(at)(at)plone').toLocalizedTime(workitem.begin, True) or ''"/>
–
- <span tal:replace="python:workitem.end and
here.toLocalizedTime(workitem.end, True) or ''"/>
+ <span tal:replace="python:workitem.end and
path('context/(at)(at)plone').toLocalizedTime(workitem.end, True) or ''"/>
</td>
</tr>
</tbody>
(at)(at) -110,7 +110,7 (at)(at)
</tr>
<tal:repeat repeat="log logs">
<tr class="row-hilite">
- <td class="form-text"
tal:content="python:here.toLocalizedTime(log[0], True)"/>
+ <td class="form-text"
tal:content="python:path('context/(at)(at)plone').toLocalizedTime(log[0],
True)"/>
<td class="form-text" tal:content="python:log[1]"/>
<td class="form-text" tal:content="python:log[2]"/>
</tr>
Modified: AlphaFlow/trunk/www/workitemOverview.zpt
==============================================================================
--- AlphaFlow/trunk/www/workitemOverview.zpt (original)
+++ AlphaFlow/trunk/www/workitemOverview.zpt Thu Mar 1 22:47:11 2007
(at)(at) -43,7 +43,7 (at)(at)
<ul tal:condition="workitems">
<li tal:repeat="workitem workitems">
<metal:activity
use-macro="here/manage_linkmacros/macros/to_workitem" />
- (<span tal:replace="python:workitem.begin and
here.toLocalizedTime(workitem.begin, True) or ''"/>):
+ (<span tal:replace="python:workitem.begin and
path('context/(at)(at)plone').toLocalizedTime(workitem.begin, True) or
''"/>):
<metal:activity
use-macro="here/manage_linkmacros/macros/workitem_to_activity" />
</li>
</ul>
(at)(at) -118,9 +118,9 (at)(at)
</tr>
<tal:repeat repeat="log logs">
<tr class="row-hilite">
- <td class="form-text"
tal:content="python:here.toLocalizedTime(log[0],True)"/>
- <td class="form-text" tal:content="python:log[1]"/>
- <td class="form-text" tal:content="python:log[2]"/>
+ <td class="form-text"
tal:content="python:path('context/(at)(at)plone').toLocalizedTime(log[0],True)"/>
+ <td class="form-text" tal:content="python:log[1]"/>
+ <td class="form-text" tal:content="python:log[2]"/>
</tr>
<tr class="row-normal">
<td class="form-text" colspan="3" tal:content="structure
python:log[3]"/>
|
SVN: r4564 - in AlphaFlow/trunk: . activities adapters
Thomas Lotze <tl(at)gocept.com> |
2007-03-13 13:35:35 |
[ FULL ]
|
Author: thomas
Date: Tue Mar 13 13:35:32 2007
New Revision: 4564
Log:
ripping out activity_exits stuff
Removed:
AlphaFlow/trunk/adapters/referencemanager.py
Modified:
AlphaFlow/trunk/activities/common.py
AlphaFlow/trunk/activities/ntask.py
AlphaFlow/trunk/activities/task.py
AlphaFlow/trunk/activity.py
AlphaFlow/trunk/interfaces.py
Modified: AlphaFlow/trunk/activities/common.py
==============================================================================
--- AlphaFlow/trunk/activities/common.py (original)
+++ AlphaFlow/trunk/activities/common.py Tue Mar 13 13:35:32 2007
(at)(at) -24,12 +24,6 (at)(at)
encoding='ascii', datatype=tuple),
)
- def deleteId(self, id):
- """Removes an id of any configured activity exits"""
- if id in self.activities:
- temp = list(self.activities)
- temp.remove(id)
- self.activities = tuple(temp)
# register the stuff
InitializeWorkflowAttributes(Exit)
Modified: AlphaFlow/trunk/activities/ntask.py
==============================================================================
--- AlphaFlow/trunk/activities/ntask.py (original)
+++ AlphaFlow/trunk/activities/ntask.py Tue Mar 13 13:35:32 2007
(at)(at) -27,8 +27,6 (at)(at)
meta_type = "AlphaFlow NTask Activity"
activity_type = nodeName = "ntask"
icon = "misc_/AlphaFlow/ntask"
- activity_exits = BaseAssignableActivity.activity_exits + \
- ('exits', )
attributes = BaseAssignableActivity.attributes + (
WorkflowAttribute('exits', '', (),
Modified: AlphaFlow/trunk/activities/task.py
==============================================================================
--- AlphaFlow/trunk/activities/task.py (original)
+++ AlphaFlow/trunk/activities/task.py Tue Mar 13 13:35:32 2007
(at)(at) -26,8 +26,6 (at)(at)
meta_type = "AlphaFlow Task Activity"
activity_type = nodeName = "task"
icon = "misc_/AlphaFlow/task"
- activity_exits = BaseAssignableActivity.activity_exits + \
- ('completion_activity', )
attributes = BaseAssignableActivity.attributes + (
WorkflowAttribute('completion_activity', 'completion_activity', (),
Modified: AlphaFlow/trunk/activity.py
==============================================================================
--- AlphaFlow/trunk/activity.py (original)
+++ AlphaFlow/trunk/activity.py Tue Mar 13 13:35:32 2007
(at)(at) -28,7 +28,6 (at)(at)
security = ClassSecurityInfo()
activity_type = nodeName = None
- activity_exits = ('startActivity',)
configurationSchema = None
icon = "misc_/AlphaFlow/generic"
commentfield = ""
(at)(at) -105,26 +104,6 (at)(at)
wi = wi_class(w_id, self.getId(), content_object)
return [wi]
- security.declareProtected(config.MANAGE_WORKFLOW, 'deleteId')
- def deleteId(self, id):
- """Removes an id of any configured activity exits"""
- for act_exit in self.activity_exits:
- attr = getattr(self, act_exit, None)
-
- if attr is not () and id in attr:
- temp = list(attr)
- temp.remove(id)
- setattr(self, act_exit, tuple(temp))
-
- if act_exit == 'exits':
- for e in attr:
- e.deleteId(id)
- # if the exit has no activities anymore, remove it
- if e.activities == ():
- temp = list(self.exits)
- temp.remove(e)
- self.exits = temp
-
InitializeClass(BaseActivity)
(at)(at) -137,8 +116,6 (at)(at)
meta_type = "AlphaFlow Automatic Activity"
security = ClassSecurityInfo()
icon = "misc_/AlphaFlow/baseautomaticactivity"
- activity_exits = BaseActivity.activity_exits + \
- ('continue_activity', )
manage_options = (PropertyManager.manage_options + \
SimpleItem.manage_options)
Modified: AlphaFlow/trunk/interfaces.py
==============================================================================
--- AlphaFlow/trunk/interfaces.py (original)
+++ AlphaFlow/trunk/interfaces.py Tue Mar 13 13:35:32 2007
(at)(at) -258,9 +258,6 (at)(at)
def acquireActivity():
"""returns the activity instance from the acquisition chain"""
- def deleteId(id):
- """Removes an id of any configured activity exits"""
-
def generateWorkItems(source, content_object):
"""Instanciates work items for this activity.
|
SVN: r4565 - in AlphaFlow/trunk: . activities tests
Thomas Lotze <tl(at)gocept.com> |
2007-03-13 13:58:51 |
[ FULL ]
|
Author: thomas
Date: Tue Mar 13 13:58:48 2007
New Revision: 4565
Log:
merged MultipleExitsMixin into BaseActivity, moved Exit class
Removed:
AlphaFlow/trunk/activities/common.py
Modified:
AlphaFlow/trunk/activities/ntask.py
AlphaFlow/trunk/activities/switch.py
AlphaFlow/trunk/activity.py
AlphaFlow/trunk/tests/test_definition.py
AlphaFlow/trunk/tests/test_ntask.py
Modified: AlphaFlow/trunk/activities/ntask.py
==============================================================================
--- AlphaFlow/trunk/activities/ntask.py (original)
+++ AlphaFlow/trunk/activities/ntask.py Tue Mar 13 13:58:48 2007
(at)(at) -13,13 +13,13 (at)(at)
from Products.AlphaFlow.interfaces import INTaskActivity, INTaskWorkItem
from Products.AlphaFlow.workitem import registerWorkItem,
BaseAssignableWorkItem
from Products.AlphaFlow.activity import \
- registerActivity, BaseAssignableActivity, MultipleExitsMixin
+ registerActivity, BaseAssignableActivity
from Products.AlphaFlow import config
from Products.AlphaFlow.action import Action
from Products.AlphaFlow.workflowattr import WorkflowAttribute
-class NTaskActivity(BaseAssignableActivity, MultipleExitsMixin):
+class NTaskActivity(BaseAssignableActivity):
__implements__ = BaseAssignableActivity.__implements__ + (INTaskActivity,
)
security = ClassSecurityInfo()
Modified: AlphaFlow/trunk/activities/switch.py
==============================================================================
--- AlphaFlow/trunk/activities/switch.py (original)
+++ AlphaFlow/trunk/activities/switch.py Tue Mar 13 13:58:48 2007
(at)(at) -17,12 +17,12 (at)(at)
from Products.AlphaFlow.workitem import \
registerWorkItem, BaseAutomaticWorkItem
from Products.AlphaFlow.activity import \
- registerActivity, BaseAutomaticActivity, MultipleExitsMixin
+ registerActivity, BaseAutomaticActivity
from Products.AlphaFlow.interfaces import ISwitchActivity, ISwitchWorkItem
from Products.AlphaFlow import config, utils
from Products.AlphaFlow.workflowattr import \
WorkflowAttribute, InitializeWorkflowAttributes
-from Products.AlphaFlow.activities.common import Exit
+from Products.AlphaFlow.activity import Exit
class Case(Exit):
(at)(at) -33,7 +33,7 (at)(at)
"TALES expression returning True or False."),)
-class SwitchActivity(BaseAutomaticActivity, MultipleExitsMixin):
+class SwitchActivity(BaseAutomaticActivity):
__implements__ = BaseAutomaticActivity.__implements__ + \
(ISwitchActivity, )
Modified: AlphaFlow/trunk/activity.py
==============================================================================
--- AlphaFlow/trunk/activity.py (original)
+++ AlphaFlow/trunk/activity.py Tue Mar 13 13:58:48 2007
(at)(at) -4,6 +4,7 (at)(at)
"""Activity definitions"""
from Globals import InitializeClass
+from Persistence import Persistent
from AccessControl import ClassSecurityInfo, getSecurityManager, Unauthorized
from OFS.PropertyManager import PropertyManager
from OFS.SimpleItem import SimpleItem
(at)(at) -11,7 +12,7 (at)(at)
from Products.Archetypes import public as atapi
from Products.AlphaFlow.interfaces import \
- IActivity, IAutomaticActivity, IAssignableActivity
+ IActivity, IAutomaticActivity, IAssignableActivity, IExit
from Products.AlphaFlow import config, utils
from Products.AlphaFlow.exception import ConfigurationError
from Products.AlphaFlow.workflowattr import \
(at)(at) -20,7 +21,28 (at)(at)
from Products.AlphaFlow.registry import Registry
from Products.AlphaFlow.workitem import workitem_registry
+
+class Exit(Persistent, DOMImporter):
+
+ __implements__ = (IExit, )
+
+ nodeName = "exit"
+ attributes = (
+ WorkflowAttribute('id', 'id', None,
+ 'Id of the exit.',
+ encoding="ascii", datatype=str),
+ WorkflowAttribute('title', 'title', None,
+ 'Title of the exit.'),
+ WorkflowAttribute('activities', 'activities', (),
+ 'Continue activities if this exit gets chosen.',
+ encoding='ascii', datatype=tuple),
+ )
+
+# register the stuff
+InitializeWorkflowAttributes(Exit)
+
+
class BaseActivity(PropertyManager, SimpleItem, DOMImporter):
"""A base class to implement activities"""
(at)(at) -104,10 +126,28 (at)(at)
wi = wi_class(w_id, self.getId(), content_object)
return [wi]
+ security.declarePrivate("_get_possible_children_from_exits")
+ def _get_possible_children_from_exits(self, exits):
+ """Return a list of possible following activities. (List of ids)"""
+ possible_children = {}
+ for exit in exits:
+ possible_children.update(dict.fromkeys(exit.activities))
+ return possible_children.keys()
-InitializeClass(BaseActivity)
+ security.declarePrivate("_graph_get_possible_children_from_exits")
+ def _graph_get_possible_children_from_exits(self, exits):
+ """Return a list of possible following activities with labels."""
+ possible_children = []
+ for exit in exits:
+ for activity in exit.activities:
+ possible_children.append({'id': activity,
+ 'label': exit.id})
+ return possible_children
+InitializeClass(BaseActivity)
+
+
class BaseAutomaticActivity(BaseActivity):
"""A base class for automatic activities (single exit)"""
(at)(at) -313,31 +353,7 (at)(at)
InitializeClass(BaseAssignableActivity)
-
-class MultipleExitsMixin:
- "Mixin class that collects possible children from a sequence of exits."
-
- security = ClassSecurityInfo()
-
- security.declarePrivate("_get_possible_children_from_exits")
- def _get_possible_children_from_exits(self, exits):
- """Return a list of possible following activities. (List of ids)"""
- possible_children = {}
- for exit in exits:
- possible_children.update(dict.fromkeys(exit.activities))
- return possible_children.keys()
-
- security.declarePrivate("_graph_get_possible_children_from_exits")
- def _graph_get_possible_children_from_exits(self, exits):
- """Return a list of possible following activities with labels."""
- possible_children = []
- for exit in exits:
- for activity in exit.activities:
- possible_children.append({'id': activity,
- 'label': exit.id})
- return possible_children
-
-
+
#############################
# Registry for all activities
activity_registry = Registry()
Modified: AlphaFlow/trunk/tests/test_definition.py
==============================================================================
--- AlphaFlow/trunk/tests/test_definition.py (original)
+++ AlphaFlow/trunk/tests/test_definition.py Tue Mar 13 13:58:48 2007
(at)(at) -22,7 +22,7 (at)(at)
from Products.AlphaFlow.tests.content import DummyContent
from Products.AlphaFlow.interfaces import \
- IProcess, IAlphaFlowed, IInstance, IActivity, IWorkItem, \
+ IProcess, IAlphaFlowed, IInstance, IActivity, IExit, IWorkItem, \
IAutomaticWorkItem, IAction, \
IWorkflowAttribute, IAssignableActivity, IAutomaticActivity, \
IPermissionSetting
(at)(at) -31,7 +31,7 (at)(at)
from Products.AlphaFlow.process import Process
from Products.AlphaFlow.activity import \
activity_registry, BaseAssignableActivity, \
- BaseActivity, BaseAutomaticActivity
+ BaseActivity, BaseAutomaticActivity, Exit
from Products.AlphaFlow.workitem import \
BaseWorkItem, BaseAutomaticWorkItem, workitem_registry
from Products.AlphaFlow.action import Action
(at)(at) -82,6 +82,7 (at)(at)
(IProcess, Process),
(IWorkflowAttribute, WorkflowAttribute),
(IAssignableActivity, BaseAssignableActivity),
+ (IExit, Exit),
(IActivity, BaseActivity),
(IAutomaticActivity, BaseAutomaticActivity),
(IPermissionSetting, PermissionSetting)] + \
Modified: AlphaFlow/trunk/tests/test_ntask.py
==============================================================================
--- AlphaFlow/trunk/tests/test_ntask.py (original)
+++ AlphaFlow/trunk/tests/test_ntask.py Tue Mar 13 13:58:48 2007
(at)(at) -10,10 +10,9 (at)(at)
from Products.CMFCore.utils import getToolByName
from Products.AlphaFlow.tests.AlphaFlowTestCase import AlphaFlowTestCase
-from Products.AlphaFlow.interfaces import INTaskWorkItem, INTaskActivity,
IExit
+from Products.AlphaFlow.interfaces import INTaskWorkItem, INTaskActivity
from Products.AlphaFlow.activities.ntask import \
NTaskWorkItem, NTaskActivity
-from Products.AlphaFlow.activities.common import Exit
from Products.AlphaFlow.exception import ConfigurationError
class NTaskTest(AlphaFlowTestCase):
(at)(at) -21,7 +20,6 (at)(at)
interfaces_to_test = [
(INTaskWorkItem, NTaskWorkItem),
(INTaskActivity, NTaskActivity),
- (IExit, Exit)
]
def _init_object(self):
|
SVN: r4566 - in AlphaFlow/trunk: . activities
Thomas Lotze <tl(at)gocept.com> |
2007-03-14 11:22:11 |
[ FULL ]
|
Author: thomas
Date: Wed Mar 14 11:22:08 2007
New Revision: 4566
Log:
use exits for all activities, stop overwriting getPossibleChildren
Modified:
AlphaFlow/trunk/activities/configuration.py
AlphaFlow/trunk/activities/decision.py
AlphaFlow/trunk/activities/ntask.py
AlphaFlow/trunk/activities/parent.py
AlphaFlow/trunk/activities/recursion.py
AlphaFlow/trunk/activities/routing.py
AlphaFlow/trunk/activities/simpledecision.py
AlphaFlow/trunk/activities/switch.py
AlphaFlow/trunk/activities/task.py
AlphaFlow/trunk/activity.py
Modified: AlphaFlow/trunk/activities/configuration.py
==============================================================================
--- AlphaFlow/trunk/activities/configuration.py (original)
+++ AlphaFlow/trunk/activities/configuration.py Wed Mar 14 11:22:08 2007
(at)(at) -11,7 +11,8 (at)(at)
IConfigurationActivity, IConfigurationWorkItem
from Products.AlphaFlow.workitem import \
registerWorkItem, BaseAssignableWorkItem, Group
-from Products.AlphaFlow.activity import registerActivity,
BaseAssignableActivity
+from Products.AlphaFlow.activity import \
+ Exit, registerActivity, BaseAssignableActivity
from Products.AlphaFlow import config
from Products.AlphaFlow.exception import ConfigurationError
from Products.AlphaFlow.action import Action
(at)(at) -50,24 +51,13 (at)(at)
importHandler='_attr_import_configure',
exportHandler='_attr_export_configure'),
)
-
-
- security.declareProtected(config.MANAGE_WORKFLOW, "getPossibleChildren")
- def getPossibleChildren(self):
- """Return a list of possible following activities. (List of ids)"""
- return self.continue_activity
-
- security.declareProtected(config.MANAGE_WORKFLOW,
- "graphGetPossibleChildren")
- def graphGetPossibleChildren(self):
- "Return a list of possible following activities. (List of ids)"
- acts = []
- for act in self.continue_activity:
- acts.append({'id':act,
- 'label':'on completion'})
- return acts
-
+ security.declarePrivate('manage_afterAdd')
+ def manage_afterAdd(self, item, container):
+ completion = Exit("completion")
+ completion.title = "on completion"
+ completion.activities = self.continue_activity
+ self.exits += (completion, )
#########
# private
Modified: AlphaFlow/trunk/activities/decision.py
==============================================================================
--- AlphaFlow/trunk/activities/decision.py (original)
+++ AlphaFlow/trunk/activities/decision.py Wed Mar 14 11:22:08 2007
(at)(at) -12,7 +12,8 (at)(at)
# Sibling imports
from Products.AlphaFlow.interfaces import IDecisionActivity, IDecisionWorkItem
from Products.AlphaFlow.workitem import BaseAssignableWorkItem,
registerWorkItem
-from Products.AlphaFlow.activity import BaseAssignableActivity,
registerActivity
+from Products.AlphaFlow.activity import \
+ Exit, BaseAssignableActivity, registerActivity
from Products.AlphaFlow import config
from Products.AlphaFlow.action import Action
from Products.AlphaFlow.workflowattr import WorkflowAttribute
(at)(at) -77,26 +78,27 (at)(at)
format='checkbox',
)
- security.declareProtected(config.MANAGE_WORKFLOW, "getPossibleChildren")
- def getPossibleChildren(self):
- """Return a list of possible following activities. (List of ids)"""
- return self.reject_activity + self.accept_activity
+ security.declarePrivate('manage_afterAdd')
+ def manage_afterAdd(self, item, container):
+ accept = Exit("accept")
+ accept.title = "on accept"
+ accept.activities = self.accept_activity
+ reject = Exit("reject")
+ reject.title = "on reject"
+ reject.activities = self.reject_activity
+ self.exits += (accept, reject)
security.declareProtected(config.MANAGE_WORKFLOW,
"graphGetPossibleChildren")
def graphGetPossibleChildren(self):
"""Return a list of possible following activities. (List of ids)"""
- acts = []
- for act in self.reject_activity:
- acts.append({'id':act,
- 'label':'on reject',
- 'color':'red'})
- for act in self.accept_activity:
- acts.append({'id':act,
- 'color':'green',
- 'label':'on accept'})
- return acts
-
+ activities = super(DecisionActivity, self).graphGetPossibleChildren()
+ for act in activities:
+ if act["exit"] == "accept":
+ act["color"] = "green"
+ elif act["exit"] == "reject":
+ act["color"] = "red"
+ return activities
class DecisionWorkItem(BaseAssignableWorkItem):
Modified: AlphaFlow/trunk/activities/ntask.py
==============================================================================
--- AlphaFlow/trunk/activities/ntask.py (original)
+++ AlphaFlow/trunk/activities/ntask.py Wed Mar 14 11:22:08 2007
(at)(at) -47,18 +47,6 (at)(at)
)),
)) + BaseAssignableActivity.configurationSchema
-
- security.declareProtected(config.MANAGE_WORKFLOW, "getPossibleChildren")
- def getPossibleChildren(self):
- """Return a list of possible following activities. (List of ids)"""
- return self._get_possible_children_from_exits(self.exits)
-
- security.declareProtected(config.MANAGE_WORKFLOW,
- "graphGetPossibleChildren")
- def graphGetPossibleChildren(self):
- """Return a list of possible following activities with labels."""
- return self._graph_get_possible_children_from_exits(self.exits)
-
class NTaskWorkItem(BaseAssignableWorkItem):
Modified: AlphaFlow/trunk/activities/parent.py
==============================================================================
--- AlphaFlow/trunk/activities/parent.py (original)
+++ AlphaFlow/trunk/activities/parent.py Wed Mar 14 11:22:08 2007
(at)(at) -14,12 +14,37 (at)(at)
# Sibling imports
from Products.AlphaFlow.workitem import registerWorkItem,
BaseAutomaticWorkItem
-from Products.AlphaFlow.activity import registerActivity,
BaseAutomaticActivity
+from Products.AlphaFlow.activity import \
+ Exit, registerActivity, BaseAutomaticActivity
from Products.AlphaFlow.interfaces import IParentActivity, IParentWorkItem
from Products.AlphaFlow import config
from Products.AlphaFlow.workflowattr import WorkflowAttribute
+class ParentExit(Exit):
+ id = title = "parent"
+
+ def __init__(self, id, activity):
+ super(ParentExit, self).__init__(id)
+ self._activity = activity
+
+ def __get_activities(self):
+ process = self._activity.acquireProcess()
+ parent_name = self._activity.parentOf
+ self_id = self._activity.getId()
+
+ return [
+ activity_id
+ for activity_id in process.listActivityIds()
+ if activity_id != self_id # Avoid infinite recursion.
+ and parent_name in process[activity_id].getPossibleChildren()]
+
+ def __set_activities(self, value):
+ pass
+
+ activities = property(__get_activities, __set_activities)
+
+
class ParentActivity(BaseAutomaticActivity):
__implements__ = BaseAutomaticActivity.__implements__ + \
(at)(at) -36,36 +61,14 (at)(at)
),
)
-
-
- security.declareProtected(config.MANAGE_WORKFLOW, 'getPossibleChildren')
- def getPossibleChildren(self):
+ security.declarePrivate('manage_afterAdd')
+ def manage_afterAdd(self, item, container):
"""This activity can start any activity that is a possible
parent of the activity in our 'parentOf' attribute.
"""
- process = self.acquireProcess()
- parent_name = self.parentOf
- possible = []
-
- for activity_id in process.listActivityIds():
- if activity_id == self.getId():
- # Avoid infinite recursion.
- continue
- activity = process[activity_id]
- if parent_name in activity.getPossibleChildren():
- possible.append(activity_id)
- return possible
-
- security.declareProtected(config.MANAGE_WORKFLOW,
- "graphGetPossibleChildren")
- def graphGetPossibleChildren(self):
- """Return a list of possible following activities. (List of ids)"""
- acts = []
- for act in self.getPossibleChildren():
- acts.append({'id': act,
- 'label': 'parent'})
- return acts
-
+ parent = ParentExit("parent", self)
+ self.exits = (parent, )
+
class ParentWorkItem(BaseAutomaticWorkItem):
Modified: AlphaFlow/trunk/activities/recursion.py
==============================================================================
--- AlphaFlow/trunk/activities/recursion.py (original)
+++ AlphaFlow/trunk/activities/recursion.py Wed Mar 14 11:22:08 2007
(at)(at) -17,7 +17,7 (at)(at)
# Sibling imports
from Products.AlphaFlow.workitem import registerWorkItem,
BaseAutomaticWorkItem
from Products.AlphaFlow.activity import \
- registerActivity, BaseAutomaticActivity
+ Exit, registerActivity, BaseAutomaticActivity
from Products.AlphaFlow import config, utils
from Products.AlphaFlow.interfaces import IDaemonActivity
from Products.AlphaFlow.workflowattr import WorkflowAttribute
(at)(at) -61,24 +61,16 (at)(at)
{'id': 'break_activities', 'type':'multiple selection',
'mode':'w', 'select_variable':'listActivityIds'}
)
-
- security.declareProtected(config.MANAGE_WORKFLOW, "getPossibleChildren")
- def getPossibleChildren(self):
- """Return a list of possible following activities. (List of ids)"""
- return self.recursion_activity + self.continue_activity
-
- security.declareProtected(config.MANAGE_WORKFLOW,
- "graphGetPossibleChildren")
- def graphGetPossibleChildren(self):
- """Return a list of possible following activities. (List of ids)"""
- acts = []
- for act in self.recursion_activity:
- acts.append({'id':act,
- 'label':'recursively'})
- for act in self.continue_activity:
- acts.append({'id':act,
- 'label':'after recursion'})
- return acts
+
+ security.declarePrivate('manage_afterAdd')
+ def manage_afterAdd(self, item, container):
+ recursion = Exit("recursion")
+ recursion.title = "recursively"
+ recursion.activities = self.recursion_activity
+ continuation = Exit("continuation")
+ continuation.title = "after recursion"
+ continuation.activities = self.continue_activity
+ self.exits += (recursion, continuation)
security.declarePrivate("getConfigurationSchema")
def getConfigurationSchema(self, content):
Modified: AlphaFlow/trunk/activities/routing.py
==============================================================================
--- AlphaFlow/trunk/activities/routing.py (original)
+++ AlphaFlow/trunk/activities/routing.py Wed Mar 14 11:22:08 2007
(at)(at) -10,7 +10,7 (at)(at)
# Sibling imports
from Products.AlphaFlow.workitem import registerWorkItem, BaseWorkItem
from Products.AlphaFlow.activity import \
- registerActivity, BaseActivity, activity_registry
+ Exit, registerActivity, BaseActivity, activity_registry
from Products.AlphaFlow import config
from Products.AlphaFlow.utils import killWorkItemRecursively
from Products.AlphaFlow.interfaces import \
(at)(at) -58,21 +58,12 (at)(at)
'select_variable': 'listActivityIds'},
)
-
- security.declareProtected(config.MANAGE_WORKFLOW, "getPossibleChildren")
- def getPossibleChildren(self):
- """Return a list of possible following activities. (List of ids)"""
- return self.routes
-
- security.declareProtected(config.MANAGE_WORKFLOW,
- "graphGetPossibleChildren")
- def graphGetPossibleChildren(self):
- """Return a list of possible following activities. (List of ids)"""
- acts = []
- for act in self.routes:
- acts.append({'id':act,
- 'label':'Route start'})
- return acts
+ security.declarePrivate('manage_afterAdd')
+ def manage_afterAdd(self, item, container):
+ routes = Exit("routes")
+ routes.title = "route start"
+ routes.activities = self.routes
+ self.exits += (routes, )
#########
# private
Modified: AlphaFlow/trunk/activities/simpledecision.py
==============================================================================
--- AlphaFlow/trunk/activities/simpledecision.py (original)
+++ AlphaFlow/trunk/activities/simpledecision.py Wed Mar 14 11:22:08 2007
(at)(at) -14,7 +14,8 (at)(at)
from Products.AlphaFlow.interfaces import \
ISimpleDecisionActivity, IDecisionWorkItem
from Products.AlphaFlow.workitem import BaseAssignableWorkItem,
registerWorkItem
-from Products.AlphaFlow.activity import BaseAssignableActivity,
registerActivity
+from Products.AlphaFlow.activity import \
+ Exit, BaseAssignableActivity, registerActivity
from Products.AlphaFlow import config, utils
from Products.AlphaFlow.action import Action
from Products.AlphaFlow.workflowattr import WorkflowAttribute
(at)(at) -68,25 +69,27 (at)(at)
format='checkbox',
)
- security.declareProtected(config.MANAGE_WORKFLOW, "getPossibleChildren")
- def getPossibleChildren(self):
- """Return a list of possible following activities. (List of ids)"""
- return self.reject_activity + self.accept_activity
+ security.declarePrivate('manage_afterAdd')
+ def manage_afterAdd(self, item, container):
+ accept = Exit("accept")
+ accept.title = "on accept"
+ accept.activities = self.accept_activity
+ reject = Exit("reject")
+ reject.title = "on reject"
+ reject.activities = self.reject_activity
+ self.exits += (accept, reject)
security.declareProtected(config.MANAGE_WORKFLOW,
"graphGetPossibleChildren")
def graphGetPossibleChildren(self):
"""Return a list of possible following activities. (List of ids)"""
- acts = []
- for act in self.reject_activity:
- acts.append({'id':act,
- 'label':'on reject',
- 'color':'red'})
- for act in self.accept_activity:
- acts.append({'id':act,
- 'color':'green',
- 'label':'on accept'})
- return acts
+ activities = super(DecisionActivity, self).graphGetPossibleChildren()
+ for act in activities:
+ if act["exit"] == "accept":
+ act["color"] = "green"
+ elif act["exit"] == "reject":
+ act["color"] = "red"
+ return activities
def generateWorkItems(self, source, content_object):
"""Instanciates a SimpleDecisionWorkItem for every assignee."""
Modified: AlphaFlow/trunk/activities/switch.py
==============================================================================
--- AlphaFlow/trunk/activities/switch.py (original)
+++ AlphaFlow/trunk/activities/switch.py Wed Mar 14 11:22:08 2007
(at)(at) -55,16 +55,10 (at)(at)
exportHandler="_attr_export_as_childnodes"),
)
- security.declareProtected(config.MANAGE_WORKFLOW, "getPossibleChildren")
- def getPossibleChildren(self):
- """Return a list of possible following activities. (List of ids)"""
- return self._get_possible_children_from_exits(self.cases)
-
- security.declareProtected(config.MANAGE_WORKFLOW,
- "graphGetPossibleChildren")
- def graphGetPossibleChildren(self):
- """Return a list of possible following activities with labels."""
- return self._graph_get_possible_children_from_exits(self.cases)
+ security.declarePrivate('manage_afterAdd')
+ def manage_afterAdd(self, item, container):
+ super(SwitchActivity, self).manage_afterAdd(item, container)
+ self.exits += tuple(self.cases)
class SwitchWorkItem(BaseAutomaticWorkItem):
Modified: AlphaFlow/trunk/activities/task.py
==============================================================================
--- AlphaFlow/trunk/activities/task.py (original)
+++ AlphaFlow/trunk/activities/task.py Wed Mar 14 11:22:08 2007
(at)(at) -12,7 +12,8 (at)(at)
# Sibling imports
from Products.AlphaFlow.interfaces import ITaskActivity, ITaskWorkItem
from Products.AlphaFlow.workitem import registerWorkItem,
BaseAssignableWorkItem
-from Products.AlphaFlow.activity import registerActivity,
BaseAssignableActivity
+from Products.AlphaFlow.activity import \
+ Exit, registerActivity, BaseAssignableActivity
from Products.AlphaFlow import config
from Products.AlphaFlow.action import Action
from Products.AlphaFlow.workflowattr import WorkflowAttribute
(at)(at) -51,21 +52,12 (at)(at)
'select_variable': 'listActivityIds'},
)
- security.declareProtected(config.MANAGE_WORKFLOW, "getPossibleChildren")
- def getPossibleChildren(self):
- """Return a list of possible following activities. (List of ids)"""
- return self.completion_activity
-
- security.declareProtected(config.MANAGE_WORKFLOW,
- "graphGetPossibleChildren")
- def graphGetPossibleChildren(self):
- """Return a list of possible following activities. (List of ids)"""
- acts = []
- for act in self.completion_activity:
- acts.append({'id':act,
- 'label':'on completion'})
- return acts
-
+ security.declarePrivate('manage_afterAdd')
+ def manage_afterAdd(self, item, container):
+ completion = Exit("completion")
+ completion.title = "on completion"
+ completion.activities = self.completion_activity
+ self.exits += (completion, )
class TaskWorkItem(BaseAssignableWorkItem):
Modified: AlphaFlow/trunk/activity.py
==============================================================================
--- AlphaFlow/trunk/activity.py (original)
+++ AlphaFlow/trunk/activity.py Wed Mar 14 11:22:08 2007
(at)(at) -38,6 +38,10 (at)(at)
encoding='ascii', datatype=tuple),
)
+ def __init__(self, id, *args, **kwargs):
+ super(Exit, self).__init__(id, *args, **kwargs)
+ self.id = self.title = id
+
# register the stuff
InitializeWorkflowAttributes(Exit)
(at)(at) -80,6 +84,7 (at)(at)
datatype=str),
)
+ exits = ()
security.declareProtected(config.MANAGE_WORKFLOW, "acquireActivity")
def acquireActivity(self):
(at)(at) -101,13 +106,22 (at)(at)
def getPossibleChildren(self):
"""Return a list of all ids of activities that can be instantiated as
successors by instances of this activity."""
- return [] # to be overwritten by subclasses
+ possible_children = set()
+ for exit in self.exits:
+ possible_children.update(exit.activities)
+ return possible_children
security.declareProtected(config.MANAGE_WORKFLOW,
"graphGetPossibleChildren")
def graphGetPossibleChildren(self):
"Return a list of possible successor activities as dictionaries."
- return [] # to be overwritten by subclasses
+ possible_children = []
+ for exit in self.exits:
+ possible_children.extend({'id': activity,
+ 'exit': exit.id,
+ 'label': exit.id,
+ } for activity in exit.activities)
+ return possible_children
security.declareProtected(config.MANAGE_WORKFLOW,
'graphGetStartActivities')
def graphGetStartActivities(self):
(at)(at) -126,24 +140,6 (at)(at)
wi = wi_class(w_id, self.getId(), content_object)
return [wi]
- security.declarePrivate("_get_possible_children_from_exits")
- def _get_possible_children_from_exits(self, exits):
- """Return a list of possible following activities. (List of ids)"""
- possible_children = {}
- for exit in exits:
- possible_children.update(dict.fromkeys(exit.activities))
- return possible_children.keys()
-
- security.declarePrivate("_graph_get_possible_children_from_exits")
- def _graph_get_possible_children_from_exits(self, exits):
- """Return a list of possible following activities with labels."""
- possible_children = []
- for exit in exits:
- for activity in exit.activities:
- possible_children.append({'id': activity,
- 'label': exit.id})
- return possible_children
-
InitializeClass(BaseActivity)
(at)(at) -172,21 +168,14 (at)(at)
({'id': 'continue_activity', 'type': 'multiple selection',
'mode': 'w', 'select_variable': 'listActivityIds'},
)
-
- security.declareProtected(config.MANAGE_WORKFLOW, "getPossibleChildren")
- def getPossibleChildren(self):
- """Return a list of possible following activities. (List of ids)"""
- return self.continue_activity
- security.declareProtected(config.MANAGE_WORKFLOW,
- "graphGetPossibleChildren")
- def graphGetPossibleChildren(self):
- """Return a list of possible following activities. (List of ids)"""
- acts = []
- for act in self.continue_activity:
- acts.append({'id':act,
- 'label':'continuation'})
- return acts
+ security.declarePrivate('manage_afterAdd')
+ def manage_afterAdd(self, item, container):
+ super(BaseAutomaticActivity, self).manage_afterAdd(item, container)
+ continuation = Exit("continuation")
+ continuation.activities = self.continue_activity
+ self.exits = (continuation, ) + self.exits
+
InitializeClass(BaseAutomaticActivity)
|
SVN: r4571 - in AlphaFlow/trunk: . activities
Christian Theune <ct(at)gocept.com> |
2007-03-14 12:02:25 |
[ FULL ]
|
Author: ctheune
Date: Wed Mar 14 12:02:22 2007
New Revision: 4571
Log:
- snapshot to allow thomas to continue
Modified:
AlphaFlow/trunk/activities/configuration.py
AlphaFlow/trunk/activities/decision.py
AlphaFlow/trunk/activities/ntask.py
AlphaFlow/trunk/activities/parent.py
AlphaFlow/trunk/activity.py
AlphaFlow/trunk/importexport.py
AlphaFlow/trunk/workitem.py
Modified: AlphaFlow/trunk/activities/configuration.py
==============================================================================
--- AlphaFlow/trunk/activities/configuration.py (original)
+++ AlphaFlow/trunk/activities/configuration.py Wed Mar 14 12:02:22 2007
(at)(at) -54,10 +54,7 (at)(at)
security.declarePrivate('manage_afterAdd')
def manage_afterAdd(self, item, container):
- completion = Exit("completion")
- completion.title = "on completion"
- completion.activities = self.continue_activity
- self.exits += (completion, )
+ self.exits['completion'] = Exit("completion", self.continue_activity)
#########
# private
Modified: AlphaFlow/trunk/activities/decision.py
==============================================================================
--- AlphaFlow/trunk/activities/decision.py (original)
+++ AlphaFlow/trunk/activities/decision.py Wed Mar 14 12:02:22 2007
(at)(at) -80,13 +80,8 (at)(at)
security.declarePrivate('manage_afterAdd')
def manage_afterAdd(self, item, container):
- accept = Exit("accept")
- accept.title = "on accept"
- accept.activities = self.accept_activity
- reject = Exit("reject")
- reject.title = "on reject"
- reject.activities = self.reject_activity
- self.exits += (accept, reject)
+ self.exits['accept'] = Exit("accept", self.accept_activity)
+ self.exits['reject'] = Exit("reject", self.reject_activity)
security.declareProtected(config.MANAGE_WORKFLOW,
"graphGetPossibleChildren")
Modified: AlphaFlow/trunk/activities/ntask.py
==============================================================================
--- AlphaFlow/trunk/activities/ntask.py (original)
+++ AlphaFlow/trunk/activities/ntask.py Wed Mar 14 12:02:22 2007
(at)(at) -29,13 +29,14 (at)(at)
icon = "misc_/AlphaFlow/ntask"
attributes = BaseAssignableActivity.attributes + (
- WorkflowAttribute('exits', '', (),
+ # XXX The import mechanism for this should be revisited.
+ WorkflowAttribute('_exits', '', (),
'Tuple of IExit objects',
datatype=tuple,
importHandler="_attr_import_from_all_childnodes",
exportHandler="_attr_export_as_childnodes"),
)
-
+
configurationSchema = atapi.Schema((
atapi.TextField("task",
widget=atapi.TextAreaWidget(
(at)(at) -47,7 +48,14 (at)(at)
)),
)) + BaseAssignableActivity.configurationSchema
-
+ security.declarePrivate('manage_afterAdd')
+ def manage_afterAdd(self, item, container):
+ super(NTaskActivity, self).manage_afterAdd(item, container)
+ # Make data structure that stores the exits after the import
+ # compatible with the real exit infrastructure.
+ self.exits.update((exit.id, exit) for exit in self._exits)
+
+
class NTaskWorkItem(BaseAssignableWorkItem):
__implements__ = (INTaskWorkItem,) + BaseAssignableWorkItem.__implements__
(at)(at) -62,7 +70,7 (at)(at)
def getActions(self):
"""Determine all possible actions."""
return [self._get_action(exit)
- for exit in self.getActivity().exits]
+ for exit in self.getActivity().exits.values()]
security.declarePrivate('_get_action')
def _get_action(self, exit):
(at)(at) -75,11 +83,10 (at)(at)
exit.id),
callback)
return a
-
################
# INTaskWorkItem
-
+
security.declareProtected(config.HANDLE_WORKITEM, "complete")
def complete(self, exit, REQUEST=None):
"""Complete this workitem"""
Modified: AlphaFlow/trunk/activities/parent.py
==============================================================================
--- AlphaFlow/trunk/activities/parent.py (original)
+++ AlphaFlow/trunk/activities/parent.py Wed Mar 14 12:02:22 2007
(at)(at) -33,11 +33,17 (at)(at)
parent_name = self._activity.parentOf
self_id = self._activity.getId()
+ activities = []
+ for activity_id in process.listActivityIds():
+ if activity_id == self_id:
+ # Avoid infinite recursion when getting possible children in
+ # the next step
+ continue
+ if parent_name in process[activity_id].getPossibleChildren():
+
return [
activity_id
- for activity_id in process.listActivityIds()
- if activity_id != self_id # Avoid infinite recursion.
- and parent_name in process[activity_id].getPossibleChildren()]
+ and parent_name in ]
def __set_activities(self, value):
pass
Modified: AlphaFlow/trunk/activity.py
==============================================================================
--- AlphaFlow/trunk/activity.py (original)
+++ AlphaFlow/trunk/activity.py Wed Mar 14 12:02:22 2007
(at)(at) -23,6 +23,11 (at)(at)
class Exit(Persistent, DOMImporter):
+ """A class that (unfortunately) has two meanings:
+
+ - represent exits as configured via XML for switches and ntasks
+ - represent the general concept of exits
+ """
__implements__ = (IExit, )
(at)(at) -38,9 +43,10 (at)(at)
encoding='ascii', datatype=tuple),
)
- def __init__(self, id, *args, **kwargs):
+ def __init__(self, id, activities=()):
super(Exit, self).__init__(id, *args, **kwargs)
self.id = self.title = id
+ self.activities = activities
# register the stuff
(at)(at) -84,7 +90,13 (at)(at)
datatype=str),
)
- exits = ()
+ exits = None # Is set to {} in __init__. This is None to satisfy
+ # interface validation requirements and avoid working
+ # with a class-attribute dict accidentally.
+
+ def __init__(self, *args, **kw):
+ super(BaseActivity, self).__init__(*args, **kw)
+ self.exits = {}
security.declareProtected(config.MANAGE_WORKFLOW, "acquireActivity")
def acquireActivity(self):
(at)(at) -107,7 +119,7 (at)(at)
"""Return a list of all ids of activities that can be instantiated as
successors by instances of this activity."""
possible_children = set()
- for exit in self.exits:
+ for exit in self.exits.values():
possible_children.update(exit.activities)
return possible_children
(at)(at) -116,7 +128,7 (at)(at)
def graphGetPossibleChildren(self):
"Return a list of possible successor activities as dictionaries."
possible_children = []
- for exit in self.exits:
+ for exit in self.exits.values():
possible_children.extend({'id': activity,
'exit': exit.id,
'label': exit.id,
(at)(at) -172,21 +184,18 (at)(at)
security.declarePrivate('manage_afterAdd')
def manage_afterAdd(self, item, container):
super(BaseAutomaticActivity, self).manage_afterAdd(item, container)
- continuation = Exit("continuation")
- continuation.activities = self.continue_activity
- self.exits = (continuation, ) + self.exits
+ self.exits['continuation'] = Exit('continuation',
self.continue_activity)
InitializeClass(BaseAutomaticActivity)
-
class BaseAssignableActivity(BaseActivity):
"Workflow activity instances of which may be assigned to a member."
-
+
__implements__ = BaseActivity.__implements__ + (IAssignableActivity, )
security = ClassSecurityInfo()
-
+
_properties = BaseActivity._properties + (
{ 'id': 'roles', 'type': 'lines', 'mode': 'w' },
)
Modified: AlphaFlow/trunk/importexport.py
==============================================================================
--- AlphaFlow/trunk/importexport.py (original)
+++ AlphaFlow/trunk/importexport.py Wed Mar 14 12:02:22 2007
(at)(at) -22,11 +22,6 (at)(at)
context = None
- security.declareProtected(config.EDIT_WORKFLOW, "__init__")
- def __init__(self, id, *args, **kw):
- "Constructor"
- self.id = id
-
security.declareProtected(config.EDIT_WORKFLOW, "configureFromXML")
def configureFromXML(self, REQUEST):
"""Saves the properties to the activity."""
Modified: AlphaFlow/trunk/workitem.py
==============================================================================
--- AlphaFlow/trunk/workitem.py (original)
+++ AlphaFlow/trunk/workitem.py Wed Mar 14 12:02:22 2007
(at)(at) -281,9 +281,13 (at)(at)
elif self.state == "complete":
self.end = DateTime()
except Exception, m:
- self.changeState('fallout',
- "Error while changing state to %s." %
self.state,
- sys.exc_info())
+ if isinstance(m, AlphaFlowException):
+ message = str(m)
+ exc_info = None
+ else:
+ message = "Error while changing state to %s." % self.state
+ exc_info = sys.exc_info()
+ self.changeState('fallout', message, exc_info)
getToolByName(self, 'error_log').raising(sys.exc_info())
self.getInstance().notifyWorkItemStateChange(self)
|
SVN: r4572 - in AlphaFlow/trunk: . activities tests
Thomas Lotze <tl(at)gocept.com> |
2007-03-14 13:11:23 |
[ FULL ]
|
Author: thomas
Date: Wed Mar 14 13:11:20 2007
New Revision: 4572
Log:
changed exits tuples on activities to mappings
Modified:
AlphaFlow/trunk/activities/ntask.py
AlphaFlow/trunk/activities/parent.py
AlphaFlow/trunk/activities/recursion.py
AlphaFlow/trunk/activities/routing.py
AlphaFlow/trunk/activities/simpledecision.py
AlphaFlow/trunk/activities/switch.py
AlphaFlow/trunk/activities/task.py
AlphaFlow/trunk/activity.py
AlphaFlow/trunk/importexport.py
AlphaFlow/trunk/tests/test_ntask.py
Modified: AlphaFlow/trunk/activities/ntask.py
==============================================================================
--- AlphaFlow/trunk/activities/ntask.py (original)
+++ AlphaFlow/trunk/activities/ntask.py Wed Mar 14 13:11:20 2007
(at)(at) -94,7 +94,7 (at)(at)
raise ValueError, "Can't complete a task that isn't active."
created = False
- for exit_ in self.getActivity().exits:
+ for exit_ in self.getActivity().exits.values():
if exit_.id == exit:
self.createWorkItems(exit_.activities)
created=True
Modified: AlphaFlow/trunk/activities/parent.py
==============================================================================
--- AlphaFlow/trunk/activities/parent.py (original)
+++ AlphaFlow/trunk/activities/parent.py Wed Mar 14 13:11:20 2007
(at)(at) -40,10 +40,8 (at)(at)
# the next step
continue
if parent_name in process[activity_id].getPossibleChildren():
-
- return [
- activity_id
- and parent_name in ]
+ activities.append(activity_id)
+ return activities
def __set_activities(self, value):
pass
(at)(at) -72,8 +70,7 (at)(at)
"""This activity can start any activity that is a possible
parent of the activity in our 'parentOf' attribute.
"""
- parent = ParentExit("parent", self)
- self.exits = (parent, )
+ self.exits["parent"] = ParentExit("parent", self)
class ParentWorkItem(BaseAutomaticWorkItem):
Modified: AlphaFlow/trunk/activities/recursion.py
==============================================================================
--- AlphaFlow/trunk/activities/recursion.py (original)
+++ AlphaFlow/trunk/activities/recursion.py Wed Mar 14 13:11:20 2007
(at)(at) -64,13 +64,9 (at)(at)
security.declarePrivate('manage_afterAdd')
def manage_afterAdd(self, item, container):
- recursion = Exit("recursion")
- recursion.title = "recursively"
- recursion.activities = self.recursion_activity
- continuation = Exit("continuation")
- continuation.title = "after recursion"
- continuation.activities = self.continue_activity
- self.exits += (recursion, continuation)
+ self.exits.update(
+ recursion=Exit("recursion", self.recursion_activity),
+ continuation=Exit("continuation", self.continue_activity))
security.declarePrivate("getConfigurationSchema")
def getConfigurationSchema(self, content):
Modified: AlphaFlow/trunk/activities/routing.py
==============================================================================
--- AlphaFlow/trunk/activities/routing.py (original)
+++ AlphaFlow/trunk/activities/routing.py Wed Mar 14 13:11:20 2007
(at)(at) -60,10 +60,7 (at)(at)
security.declarePrivate('manage_afterAdd')
def manage_afterAdd(self, item, container):
- routes = Exit("routes")
- routes.title = "route start"
- routes.activities = self.routes
- self.exits += (routes, )
+ self.exits["routes"] = Exit("routes", self.routes)
#########
# private
Modified: AlphaFlow/trunk/activities/simpledecision.py
==============================================================================
--- AlphaFlow/trunk/activities/simpledecision.py (original)
+++ AlphaFlow/trunk/activities/simpledecision.py Wed Mar 14 13:11:20 2007
(at)(at) -71,13 +71,9 (at)(at)
security.declarePrivate('manage_afterAdd')
def manage_afterAdd(self, item, container):
- accept = Exit("accept")
- accept.title = "on accept"
- accept.activities = self.accept_activity
- reject = Exit("reject")
- reject.title = "on reject"
- reject.activities = self.reject_activity
- self.exits += (accept, reject)
+ self.exits.update(
+ accept=Exit("accept", self.accept_activity),
+ reject=Exit("reject", self.reject_activity))
security.declareProtected(config.MANAGE_WORKFLOW,
"graphGetPossibleChildren")
Modified: AlphaFlow/trunk/activities/switch.py
==============================================================================
--- AlphaFlow/trunk/activities/switch.py (original)
+++ AlphaFlow/trunk/activities/switch.py Wed Mar 14 13:11:20 2007
(at)(at) -58,7 +58,7 (at)(at)
security.declarePrivate('manage_afterAdd')
def manage_afterAdd(self, item, container):
super(SwitchActivity, self).manage_afterAdd(item, container)
- self.exits += tuple(self.cases)
+ self.exits.update((exit.id, exit) for exit in self.cases)
class SwitchWorkItem(BaseAutomaticWorkItem):
Modified: AlphaFlow/trunk/activities/task.py
==============================================================================
--- AlphaFlow/trunk/activities/task.py (original)
+++ AlphaFlow/trunk/activities/task.py Wed Mar 14 13:11:20 2007
(at)(at) -54,10 +54,8 (at)(at)
security.declarePrivate('manage_afterAdd')
def manage_afterAdd(self, item, container):
- completion = Exit("completion")
- completion.title = "on completion"
- completion.activities = self.completion_activity
- self.exits += (completion, )
+ self.exits["completion"] = Exit("completion",
+ self.completion_activity)
class TaskWorkItem(BaseAssignableWorkItem):
Modified: AlphaFlow/trunk/activity.py
==============================================================================
--- AlphaFlow/trunk/activity.py (original)
+++ AlphaFlow/trunk/activity.py Wed Mar 14 13:11:20 2007
(at)(at) -44,7 +44,7 (at)(at)
)
def __init__(self, id, activities=()):
- super(Exit, self).__init__(id, *args, **kwargs)
+ super(Exit, self).__init__(id)
self.id = self.title = id
self.activities = activities
Modified: AlphaFlow/trunk/importexport.py
==============================================================================
--- AlphaFlow/trunk/importexport.py (original)
+++ AlphaFlow/trunk/importexport.py Wed Mar 14 13:11:20 2007
(at)(at) -22,6 +22,9 (at)(at)
context = None
+ def __init__(self, id, *args, **kw):
+ self.id = id
+
security.declareProtected(config.EDIT_WORKFLOW, "configureFromXML")
def configureFromXML(self, REQUEST):
"""Saves the properties to the activity."""
Modified: AlphaFlow/trunk/tests/test_ntask.py
==============================================================================
--- AlphaFlow/trunk/tests/test_ntask.py (original)
+++ AlphaFlow/trunk/tests/test_ntask.py Wed Mar 14 13:11:20 2007
(at)(at) -60,8 +60,8 (at)(at)
actions = ntaskitem.getActions()
self.assertEquals(3, len(actions))
- expected_titles = ["Freigeben", "Prufen lassen", "Privat schalten"]
- titles_got = [ x.title for x in actions ]
+ expected_titles = ["Freigeben", "Privat schalten", "Prufen lassen"]
+ titles_got = sorted(x.title for x in actions)
self.assertEquals(expected_titles, titles_got)
doc.getInstance().terminate("peng!")
|
SVN: r4573 - AlphaFlow/trunk/doc/proposals
Christian Theune <ct(at)gocept.com> |
2007-03-14 16:40:28 |
[ FULL ]
|
Author: ctheune
Date: Wed Mar 14 16:40:26 2007
New Revision: 4573
Log:
- updated activity/aspect ratio
Modified:
AlphaFlow/trunk/doc/proposals/ASPECTS.txt
Modified: AlphaFlow/trunk/doc/proposals/ASPECTS.txt
==============================================================================
--- AlphaFlow/trunk/doc/proposals/ASPECTS.txt (original)
+++ AlphaFlow/trunk/doc/proposals/ASPECTS.txt Wed Mar 14 16:40:26 2007
(at)(at) -82,6 +82,7 (at)(at)
expression
ntask
email
+ configuration
Aspects
(at)(at) -90,7 +91,6 (at)(at)
dcworkflow
recursion
route
- configuration
Redefining Aspect Activities
|
SVN: r4574 - in AlphaFlow/trunk: . activities adapters doc/examples/Procurement tests
Christian Theune <ct(at)gocept.com> |
2007-03-14 16:40:47 |
[ FULL ]
|
Author: ctheune
Date: Wed Mar 14 16:40:42 2007
New Revision: 4574
Log:
- switched to zope 3 interfaces
Modified:
AlphaFlow/trunk/action.py
AlphaFlow/trunk/activities/alarm.py
AlphaFlow/trunk/activities/configuration.py
AlphaFlow/trunk/activities/dcworkflow.py
AlphaFlow/trunk/activities/decision.py
AlphaFlow/trunk/activities/expression.py
AlphaFlow/trunk/activities/gates.py
AlphaFlow/trunk/activities/interfaces.py
AlphaFlow/trunk/activities/notify.py
AlphaFlow/trunk/activities/ntask.py
AlphaFlow/trunk/activities/parent.py
AlphaFlow/trunk/activities/permission.py
AlphaFlow/trunk/activities/recursion.py
AlphaFlow/trunk/activities/roleassign.py
AlphaFlow/trunk/activities/routing.py
AlphaFlow/trunk/activities/simpledecision.py
AlphaFlow/trunk/activities/switch.py
AlphaFlow/trunk/activities/task.py
AlphaFlow/trunk/activity.py
AlphaFlow/trunk/adapters/alphaflowable.py
AlphaFlow/trunk/adapters/renderableadapter.py
AlphaFlow/trunk/doc/examples/Procurement/request.py
AlphaFlow/trunk/importexport.py
AlphaFlow/trunk/instance.py
AlphaFlow/trunk/interfaces.py
AlphaFlow/trunk/interfaces_importexport.py
AlphaFlow/trunk/patch_plone_types.py
AlphaFlow/trunk/process.py
AlphaFlow/trunk/processmanager.py
AlphaFlow/trunk/registry.py
AlphaFlow/trunk/rolecache.py
AlphaFlow/trunk/tests/AlphaFlowTestCase.py
AlphaFlow/trunk/tests/test_alarm.py
AlphaFlow/trunk/tests/test_definition.py
AlphaFlow/trunk/tests/test_email.py
AlphaFlow/trunk/tests/test_ntask.py
AlphaFlow/trunk/tests/test_security.py
AlphaFlow/trunk/utils.py
AlphaFlow/trunk/workflowattr.py
AlphaFlow/trunk/workflowedobject.py
AlphaFlow/trunk/workitem.py
Modified: AlphaFlow/trunk/action.py
==============================================================================
--- AlphaFlow/trunk/action.py (original)
+++ AlphaFlow/trunk/action.py Wed Mar 14 16:40:42 2007
(at)(at) -5,12 +5,14 (at)(at)
"""Action class
"""
+import zope.interface
from Products.AlphaFlow.interfaces import IAction
+
class Action(object):
"""An action to be performed on a workitem."""
- __implements__ = (IAction, )
+ zope.interface.implements(IAction)
__allow_access_to_unprotected_subobjects__ = 1
Modified: AlphaFlow/trunk/activities/alarm.py
==============================================================================
--- AlphaFlow/trunk/activities/alarm.py (original)
+++ AlphaFlow/trunk/activities/alarm.py Wed Mar 14 16:40:42 2007
(at)(at) -4,10 +4,9 (at)(at)
"""Implements alarm activities.
"""
-# Zope imports
+import zope.interface
from AccessControl import ClassSecurityInfo
-# Sibling imports
from Products.AlphaFlow.workitem import registerWorkItem,
BaseAutomaticWorkItem
from Products.AlphaFlow.activity import registerActivity,
BaseAutomaticActivity
from Products.AlphaFlow.interfaces import IAlarmActivity, IAlarmWorkItem
(at)(at) -17,7 +16,8 (at)(at)
class AlarmActivity(BaseAutomaticActivity):
- __implements__ = BaseAutomaticActivity.__implements__ + (IAlarmActivity, )
+ zope.interface.implements(IAlarmActivity)
+
meta_type = "AlphaFlow Alarm Activity"
activity_type = nodeName = "alarm"
icon = "misc_/AlphaFlow/alarm"
(at)(at) -31,7 +31,8 (at)(at)
class AlarmWorkItem(BaseAutomaticWorkItem):
- __implements__ = BaseAutomaticWorkItem.__implements__ + (IAlarmWorkItem, )
+ zope.interface.implements(IAlarmWorkItem)
+
security = ClassSecurityInfo()
activity_type = "alarm"
Modified: AlphaFlow/trunk/activities/configuration.py
==============================================================================
--- AlphaFlow/trunk/activities/configuration.py (original)
+++ AlphaFlow/trunk/activities/configuration.py Wed Mar 14 16:40:42 2007
(at)(at) -3,10 +3,9 (at)(at)
# $Id$
"""Configuration activity and work item."""
-# Zope imports
+import zope.interface
from AccessControl import ClassSecurityInfo
-# Sibling imports
from Products.AlphaFlow.interfaces import \
IConfigurationActivity, IConfigurationWorkItem
from Products.AlphaFlow.workitem import \
(at)(at) -21,9 +20,9 (at)(at)
class ConfigurationActivity(BaseAssignableActivity):
-
- __implements__ = BaseAssignableActivity.__implements__ + \
- (IConfigurationActivity, )
+
+ zope.interface.implements(IConfigurationActivity)
+
security = ClassSecurityInfo()
meta_type = "AlphaFlow Configuration Activity"
(at)(at) -81,8 +80,8 (at)(at)
class ConfigurationWorkItem(BaseAssignableWorkItem):
- __implements__ = BaseAssignableWorkItem.__implements__ + \
- (IConfigurationWorkItem,)
+ zope.interface.implements(IConfigurationWorkItem)
+
security = ClassSecurityInfo()
activity_type = "configuration"
Modified: AlphaFlow/trunk/activities/dcworkflow.py
==============================================================================
--- AlphaFlow/trunk/activities/dcworkflow.py (original)
+++ AlphaFlow/trunk/activities/dcworkflow.py Wed Mar 14 16:40:42 2007
(at)(at) -4,13 +4,11 (at)(at)
"""Emulate the DCWorkFlow status interface."""
-# Python imports
from DateTime import DateTime
-# Zope imports
+import zope.interface
from AccessControl import ClassSecurityInfo
-# Sibling imports
from Products.AlphaFlow.workitem import registerWorkItem,
BaseAutomaticWorkItem
from Products.AlphaFlow.activity import registerActivity,
BaseAutomaticActivity
from Products.AlphaFlow.interfaces import IDCWorkFlowActivity
(at)(at) -29,9 +27,8 (at)(at)
class DCWorkFlowActivity(BaseAutomaticActivity):
- __implements__ = BaseAutomaticActivity.__implements__ + (
- IDCWorkFlowActivity,)
-
+ zope.interface.implements(IDCWorkFlowActivity)
+
meta_type = "AlphaFlow DCWorkFlow Activity"
activity_type = nodeName = "dcworkflow"
icon = "misc_/AlphaFlow/dcworkflow"
Modified: AlphaFlow/trunk/activities/decision.py
==============================================================================
--- AlphaFlow/trunk/activities/decision.py (original)
+++ AlphaFlow/trunk/activities/decision.py Wed Mar 14 16:40:42 2007
(at)(at) -3,13 +3,11 (at)(at)
# $Id$
"""Decision activity and work item."""
-# Zope imports
+import zope.interface
from AccessControl import ClassSecurityInfo, getSecurityManager
-# Plone/AT imports
from Products.Archetypes import public as atapi
-# Sibling imports
from Products.AlphaFlow.interfaces import IDecisionActivity, IDecisionWorkItem
from Products.AlphaFlow.workitem import BaseAssignableWorkItem,
registerWorkItem
from Products.AlphaFlow.activity import \
(at)(at) -26,8 +24,8 (at)(at)
decision_modus says how many 'yes' are needed for a 'yes' result.
"""
- __implements__ = (IDecisionActivity,) + \
- BaseAssignableActivity.__implements__
+ zope.interface.implements(IDecisionActivity)
+
security = ClassSecurityInfo()
meta_type = "AlphaFlow Decision Activity"
(at)(at) -98,8 +96,7 (at)(at)
class DecisionWorkItem(BaseAssignableWorkItem):
- __implements__ = (IDecisionWorkItem,) + \
- BaseAssignableWorkItem.__implements__
+ zope.interface.implements(IDecisionWorkItem)
activity_type = "decision"
security = ClassSecurityInfo()
Modified: AlphaFlow/trunk/activities/expression.py
==============================================================================
--- AlphaFlow/trunk/activities/expression.py (original)
+++ AlphaFlow/trunk/activities/expression.py Wed Mar 14 16:40:42 2007
(at)(at) -3,10 +3,9 (at)(at)
# $Id$
"""Execute a TALES expression -- activity and work item."""
-# Zope imports
+import zope.interface
from AccessControl import ClassSecurityInfo
-# Sibling imports
from Products.AlphaFlow.workitem import registerWorkItem,
BaseAutomaticWorkItem
from Products.AlphaFlow.activity import registerActivity,
BaseAutomaticActivity
from Products.AlphaFlow.interfaces import \
(at)(at) -16,11 +15,9 (at)(at)
from Products.AlphaFlow.utils import evaluateTales, evaluateTalesAs
-
class ExpressionActivity(BaseAutomaticActivity):
- __implements__ = BaseAutomaticActivity.__implements__ + (
- IExpressionActivity, )
+ zope.interface.implements(IExpressionActivity)
attributes = BaseAutomaticActivity.attributes + (
WorkflowAttribute('expression', 'expression', '',
(at)(at) -37,8 +34,8 (at)(at)
class ExpressionWorkItem(BaseAutomaticWorkItem):
- __implements__ = BaseAutomaticWorkItem.__implements__ + (
- IExpressionWorkItem, )
+ zope.interface.implements(IExpressionWorkItem)
+
security = ClassSecurityInfo()
activity_type = "expression"
Modified: AlphaFlow/trunk/activities/gates.py
==============================================================================
--- AlphaFlow/trunk/activities/gates.py (original)
+++ AlphaFlow/trunk/activities/gates.py Wed Mar 14 16:40:42 2007
(at)(at) -4,10 +4,9 (at)(at)
"""Gates to support routing mechanisms
"""
-# Zope imports
+import zope.interface
from AccessControl import ClassSecurityInfo
-# Sibling imports
from Products.AlphaFlow.workitem import registerWorkItem, BaseWorkItem
from Products.AlphaFlow.activity import registerActivity,
BaseAutomaticActivity
from Products.AlphaFlow.interfaces import \
(at)(at) -20,11 +19,11 (at)(at)
MULTI_MERGE = "multi-merge"
SYNCHRONIZING_MERGE = "synchronizing-merge"
-
+
class GateActivity(BaseAutomaticActivity):
- __implements__ = BaseAutomaticActivity.__implements__ + (IDaemonActivity,
- IGateActivity)
+ zope.interface.implements(IDaemonActivity, IGateActivity)
+
meta_type = "AlphaFlow Gate Activity"
activity_type = nodeName = "gate"
icon = "misc_/AlphaFlow/gate"
(at)(at) -55,7 +54,7 (at)(at)
security = ClassSecurityInfo()
- __implements__ = (IGateWorkItem,) + BaseWorkItem.__implements__
+ zope.interface.implements(IGateWorkItem)
activity_type = "gate"
Modified: AlphaFlow/trunk/activities/interfaces.py
==============================================================================
--- AlphaFlow/trunk/activities/interfaces.py (original)
+++ AlphaFlow/trunk/activities/interfaces.py Wed Mar 14 16:40:42 2007
(at)(at) -4,10 +4,8 (at)(at)
"""Interfaces of and related to specific activities and work items.
"""
-# Zope imports
-from Interface import Attribute
+import zope.interface
-# Sibling imports
from Products.AlphaFlow.interfaces import *
(at)(at) -58,7 +56,7 (at)(at)
class IRoutingWorkItem(IWorkItem):
"""a Routing workitem"""
- opened_routes = Attribute("A list of work item ids that are opened
routes.")
+ opened_routes = zope.interface.Attribute("A list of work item ids that are
opened routes.")
##############################################
(at)(at) -83,7 +81,7 (at)(at)
class ITaskWorkItem(IAssignableWorkItem):
- task = Attribute("The description, what the user should do.")
+ task = zope.interface.Attribute("The description, what the user should
do.")
def complete():
"""Call this to signal when the user is done."""
(at)(at) -106,7 +104,7 (at)(at)
"""Decide to accept or reject something.
"""
- decision_notice = Attribute(
+ decision_notice = zope.interface.Attribute(
"Describes what the user(s) have to decide about.")
class IDecisionActivity(ISimpleDecisionActivity):
(at)(at) -116,7 +114,7 (at)(at)
decision_modus says how many 'yes' are needed for a 'yes' result.
"""
- decision_modus = Attribute("One of 'first_yes' or 'all_yes'.")
+ decision_modus = zope.interface.Attribute("One of 'first_yes' or
'all_yes'.")
class IDecisionWorkItem(IAssignableWorkItem):
"""WorkItem for DecisionActivity."""
(at)(at) -153,7 +151,7 (at)(at)
class IAlarmActivity(IAutomaticActivity):
""" Triggers a work item on a given DateTime."""
- due = Attribute('TALES expression when this alarm is due.')
+ due = zope.interface.Attribute('TALES expression when this alarm is due.')
class IAlarmWorkItem(IAutomaticWorkItem):
(at)(at) -222,7 +220,7 (at)(at)
class IParentActivity(IAutomaticActivity):
"""continue with parent of a certain activity"""
- parentOf = Attribute("continue with parent of these activities")
+ parentOf = zope.interface.Attribute("continue with parent of these
activities")
class IParentWorkItem(IAutomaticWorkItem):
Modified: AlphaFlow/trunk/activities/notify.py
==============================================================================
--- AlphaFlow/trunk/activities/notify.py (original)
+++ AlphaFlow/trunk/activities/notify.py Wed Mar 14 16:40:42 2007
(at)(at) -4,19 +4,16 (at)(at)
"""Implement the email activities.
"""
-# python imports
from email import Header as email_header
from email import MIMEText
import sys
-# Zope imports
+import zope.interface
from AccessControl import ClassSecurityInfo
from Persistence import Persistent
-# Plone/AT imports
from Products.CMFCore.utils import getToolByName
-# Sibling imports
from Products.AlphaFlow.utils import \
unique, listMembersWithRolesAndLocalRoles
from Products.AlphaFlow.workitem import registerWorkItem,
BaseAutomaticWorkItem
(at)(at) -29,14 +26,14 (at)(at)
from Products.AlphaFlow.importexport import DOMImporter
from Products.AlphaFlow.registry import Registry
-
+
class EMailRegistry(Registry):
"""Registry for email recipents."""
def _compute_key(self, klass):
"Compute the search key from a class object."
return klass.mode_name
-
+
def getFromDOMNode(self, node):
"""Get a class object from data given in DOM-Node.
(at)(at) -54,8 +51,8 (at)(at)
class EMailActivity(BaseAutomaticActivity):
- __implements__ = BaseAutomaticActivity.__implements__ + \
- (IEMailActivity, )
+ zope.interface.implements(IEMailActivity)
+
security = ClassSecurityInfo()
meta_type = "AlphaFlow EMail Activity"
(at)(at) -105,7 +102,8 (at)(at)
class EMailWorkItem(BaseAutomaticWorkItem):
- __implements__ = (IEMailWorkItem,)
+ zope.interface.implements(IEMailWorkItem)
+
security = ClassSecurityInfo()
activity_type = "email"
(at)(at) -191,12 +189,10 (at)(at)
email)
-
-
class AbstractRecipent(Persistent, DOMImporter):
"""Abstract recipient class."""
- __implements__ = (IEMailRecipientMode, )
+ zope.interface.implements(IEMailRecipientMode)
nodeName = "recipient"
attributes = ()
Modified: AlphaFlow/trunk/activities/ntask.py
==============================================================================
--- AlphaFlow/trunk/activities/ntask.py (original)
+++ AlphaFlow/trunk/activities/ntask.py Wed Mar 14 16:40:42 2007
(at)(at) -3,13 +3,11 (at)(at)
# $Id$
"""NTask activity and work item."""
-# Zope imports
+import zope.interface
from AccessControl import ClassSecurityInfo
-# Plone/AT imports
from Products.Archetypes import public as atapi
-# Sibling imports
from Products.AlphaFlow.interfaces import INTaskActivity, INTaskWorkItem
from Products.AlphaFlow.workitem import registerWorkItem,
BaseAssignableWorkItem
from Products.AlphaFlow.activity import \
(at)(at) -21,7 +19,8 (at)(at)
class NTaskActivity(BaseAssignableActivity):
- __implements__ = BaseAssignableActivity.__implements__ + (INTaskActivity,
)
+ zope.interface.implements(INTaskActivity)
+
security = ClassSecurityInfo()
meta_type = "AlphaFlow NTask Activity"
(at)(at) -58,7 +57,8 (at)(at)
class NTaskWorkItem(BaseAssignableWorkItem):
- __implements__ = (INTaskWorkItem,) + BaseAssignableWorkItem.__implements__
+ zope.interface.implements(INTaskWorkItem)
+
security = ClassSecurityInfo()
activity_type = "ntask"
Modified: AlphaFlow/trunk/activities/parent.py
==============================================================================
--- AlphaFlow/trunk/activities/parent.py (original)
+++ AlphaFlow/trunk/activities/parent.py Wed Mar 14 16:40:42 2007
(at)(at) -9,10 +9,9 (at)(at)
workflow can continue exactly where the error occoured in the first place.
"""
-# Zope imports
+import zope.interface
from AccessControl import ClassSecurityInfo
-# Sibling imports
from Products.AlphaFlow.workitem import registerWorkItem,
BaseAutomaticWorkItem
from Products.AlphaFlow.activity import \
Exit, registerActivity, BaseAutomaticActivity
(at)(at) -51,8 +50,8 (at)(at)
class ParentActivity(BaseAutomaticActivity):
- __implements__ = BaseAutomaticActivity.__implements__ + \
- (IParentActivity, )
+ zope.interface.implements(IParentActivity)
+
security = ClassSecurityInfo()
meta_type = "AlphaFlow Parent Activity"
(at)(at) -75,8 +74,8 (at)(at)
class ParentWorkItem(BaseAutomaticWorkItem):
- __implements__ = BaseAutomaticWorkItem.__implements__ + \
- (IParentWorkItem, )
+ zope.interface.implements(IParentWorkItem)
+
security = ClassSecurityInfo()
activity_type = "parent"
Modified: AlphaFlow/trunk/activities/permission.py
==============================================================================
--- AlphaFlow/trunk/activities/permission.py (original)
+++ AlphaFlow/trunk/activities/permission.py Wed Mar 14 16:40:42 2007
(at)(at) -5,6 +5,7 (at)(at)
from warnings import warn
+import zope.interface
from AccessControl import ClassSecurityInfo
from Products.AlphaFlow.interfaces import \
(at)(at) -22,7 +23,7 (at)(at)
class PermissionSetting(DOMImporter):
- __implements__ = (IPermissionSetting, )
+ zope.interface.implements(IPermissionSetting)
nodeName = "permission"
attributes = (WorkflowAttribute('permission', 'name', '',
(at)(at) -98,8 +99,8 (at)(at)
class PermissionActivity(BaseAutomaticActivity):
- __implements__ = ((IPermissionActivity, ) +
- BaseAutomaticActivity.__implements__)
+ zope.interface.implements(IPermissionActivity)
+
security = ClassSecurityInfo()
meta_type = "AlphaFlow Permission Activity"
(at)(at) -138,9 +139,9 (at)(at)
class PermissionWorkItem(BaseAutomaticWorkItem):
-
- __implements__ = ((IPermissionWorkItem, ) +
- BaseAutomaticWorkItem.__implements__)
+
+ zope.interface.implements(IPermissionWorkItem)
+
security = ClassSecurityInfo()
activity_type = "permission-change"
Modified: AlphaFlow/trunk/activities/recursion.py
==============================================================================
--- AlphaFlow/trunk/activities/recursion.py (original)
+++ AlphaFlow/trunk/activities/recursion.py Wed Mar 14 16:40:42 2007
(at)(at) -5,16 +5,14 (at)(at)
import logging
-# Zope imports
+import zope.interface
from AccessControl import ClassSecurityInfo
import transaction
-# Plone/AT imports
from Products.CMFCore.utils import getToolByName
from Products.Archetypes.public import \
Schema, BooleanField, BooleanWidget
-# Sibling imports
from Products.AlphaFlow.workitem import registerWorkItem,
BaseAutomaticWorkItem
from Products.AlphaFlow.activity import \
Exit, registerActivity, BaseAutomaticActivity
(at)(at) -24,10 +22,11 (at)(at)
class RecursionActivity(BaseAutomaticActivity):
-
- __implements__ = BaseAutomaticActivity.__implements__ + (IDaemonActivity,)
+
+ zope.interface.implements(IDaemonActivity)
+
security = ClassSecurityInfo()
-
+
meta_type = "AlphaFlow Recursion Activity"
activity_type = nodeName = "recursion"
icon = "misc_/AlphaFlow/recursion"
Modified: AlphaFlow/trunk/activities/roleassign.py
==============================================================================
--- AlphaFlow/trunk/activities/roleassign.py (original)
+++ AlphaFlow/trunk/activities/roleassign.py Wed Mar 14 16:40:42 2007
(at)(at) -3,14 +3,12 (at)(at)
# $Id$
"""Task activity and work item."""
-# Zope imports
+import zope.interface
from AccessControl import ClassSecurityInfo, Unauthorized
-# Plone/AT imports
from Products.CMFCore.utils import getToolByName
from Products.Archetypes import public as atapi
-# Sibling imports
from Products.AlphaFlow.workitem import registerWorkItem,
BaseAutomaticWorkItem
from Products.AlphaFlow.activity import registerActivity,
BaseAutomaticActivity
from Products.AlphaFlow import config
(at)(at) -20,9 +18,9 (at)(at)
class RoleAssignActivity(BaseAutomaticActivity):
-
- __implements__ = BaseAutomaticActivity.__implements__ + \
- (IRoleAssignActivity,)
+
+ zope.interface.implements(IRoleAssignActivity)
+
security = ClassSecurityInfo()
meta_type = "AlphaFlow Task Activity"
(at)(at) -77,8 +75,8 (at)(at)
class RoleAssignWorkItem(BaseAutomaticWorkItem):
- __implements__ = BaseAutomaticWorkItem.__implements__ + \
- (IRoleAssignWorkItem, )
+ zope.interface.implements(IRoleAssignWorkItem)
+
security = ClassSecurityInfo()
activity_type = "roleassign"
Modified: AlphaFlow/trunk/activities/routing.py
==============================================================================
--- AlphaFlow/trunk/activities/routing.py (original)
+++ AlphaFlow/trunk/activities/routing.py Wed Mar 14 16:40:42 2007
(at)(at) -4,10 +4,9 (at)(at)
"""Complex routing mechanisms
"""
-# Zope imports
+import zope.interface
from AccessControl import ClassSecurityInfo
-# Sibling imports
from Products.AlphaFlow.workitem import registerWorkItem, BaseWorkItem
from Products.AlphaFlow.activity import \
Exit, registerActivity, BaseActivity, activity_registry
(at)(at) -17,7 +16,7 (at)(at)
IRoutingActivity, IRoutingWorkItem
from Products.AlphaFlow.workflowattr import WorkflowAttribute
-
+
class RoutingActivity(BaseActivity):
"""Routing activity
(at)(at) -32,8 +31,8 (at)(at)
this routing activity.
"""
- __implements__ = BaseActivity.__implements__ + \
- (IRoutingActivity, )
+ zope.interface.implements(IRoutingActivity)
+
security = ClassSecurityInfo()
meta_type = "AlphaFlow Routing Activity"
(at)(at) -83,11 +82,11 (at)(at)
class RoutingWorkItem(BaseWorkItem):
- __implements__ = BaseWorkItem.__implements__ + (IRoutingWorkItem, )
+ zope.interface.implements(IRoutingWorkItem)
+
security = ClassSecurityInfo()
activity_type = "route"
-
######################
# IWorkItem
Modified: AlphaFlow/trunk/activities/simpledecision.py
==============================================================================
--- AlphaFlow/trunk/activities/simpledecision.py (original)
+++ AlphaFlow/trunk/activities/simpledecision.py Wed Mar 14 16:40:42 2007
(at)(at) -3,14 +3,12 (at)(at)
# $Id$
"""Simple Decision activity and work item."""
-# Zope imports
+import zope.interface
from AccessControl import ClassSecurityInfo
-# Plone/AT imports
from Products.Archetypes import public as atapi
from Products.CMFCore.utils import getToolByName
-# Sibling imports
from Products.AlphaFlow.interfaces import \
ISimpleDecisionActivity, IDecisionWorkItem
from Products.AlphaFlow.workitem import BaseAssignableWorkItem,
registerWorkItem
(at)(at) -25,8 +23,8 (at)(at)
"""Decide to accept or reject.
"""
- __implements__ = (ISimpleDecisionActivity,) + \
- BaseAssignableActivity.__implements__
+ zope.interface.implements(ISimpleDecisionActivity)
+
security = ClassSecurityInfo()
meta_type = "AlphaFlow Simple Decision Activity"
(at)(at) -120,8 +118,7 (at)(at)
class SimpleDecisionWorkItem(BaseAssignableWorkItem):
- __implements__ = (IDecisionWorkItem,) + \
- BaseAssignableWorkItem.__implements__
+ zope.interface.implements(IDecisionWorkItem)
activity_type = "simpledecision"
security = ClassSecurityInfo()
Modified: AlphaFlow/trunk/activities/switch.py
==============================================================================
--- AlphaFlow/trunk/activities/switch.py (original)
+++ AlphaFlow/trunk/activities/switch.py Wed Mar 14 16:40:42 2007
(at)(at) -12,6 +12,7 (at)(at)
import sys
+import zope.interface
from AccessControl import ClassSecurityInfo
from Products.AlphaFlow.workitem import \
(at)(at) -35,8 +36,8 (at)(at)
class SwitchActivity(BaseAutomaticActivity):
- __implements__ = BaseAutomaticActivity.__implements__ + \
- (ISwitchActivity, )
+ zope.interface.implements(ISwitchActivity)
+
security = ClassSecurityInfo()
meta_type = "AlphaFlow Switch Activity"
(at)(at) -63,8 +64,8 (at)(at)
class SwitchWorkItem(BaseAutomaticWorkItem):
- __implements__ = BaseAutomaticWorkItem.__implements__ + \
- (ISwitchWorkItem, )
+ zope.interface.implements(ISwitchWorkItem)
+
security = ClassSecurityInfo()
activity_type = "switch"
Modified: AlphaFlow/trunk/activities/task.py
==============================================================================
--- AlphaFlow/trunk/activities/task.py (original)
+++ AlphaFlow/trunk/activities/task.py Wed Mar 14 16:40:42 2007
(at)(at) -3,13 +3,11 (at)(at)
# $Id$
"""Task activity and work item."""
-# Zope imports
+import zope.interface
from AccessControl import ClassSecurityInfo
-# Plone/AT imports
from Products.Archetypes import public as atapi
-# Sibling imports
from Products.AlphaFlow.interfaces import ITaskActivity, ITaskWorkItem
from Products.AlphaFlow.workitem import registerWorkItem,
BaseAssignableWorkItem
from Products.AlphaFlow.activity import \
(at)(at) -18,10 +16,11 (at)(at)
from Products.AlphaFlow.action import Action
from Products.AlphaFlow.workflowattr import WorkflowAttribute
-
+
class TaskActivity(BaseAssignableActivity):
-
- __implements__ = BaseAssignableActivity.__implements__ + (ITaskActivity, )
+
+ zope.interface.implements(ITaskActivity)
+
security = ClassSecurityInfo()
meta_type = "AlphaFlow Task Activity"
(at)(at) -33,7 +32,7 (at)(at)
'Activity to start after completion.',
encoding="ascii", datatype=tuple),
)
-
+
configurationSchema = atapi.Schema((
atapi.TextField("task",
widget=atapi.TextAreaWidget(
(at)(at) -57,10 +56,11 (at)(at)
self.exits["completion"] = Exit("completion",
self.completion_activity)
-
+
class TaskWorkItem(BaseAssignableWorkItem):
- __implements__ = (ITaskWorkItem,) + BaseAssignableWorkItem.__implements__
+ zope.interface.implements(ITaskWorkItem)
+
security = ClassSecurityInfo()
activity_type = "task"
Modified: AlphaFlow/trunk/activity.py
==============================================================================
--- AlphaFlow/trunk/activity.py (original)
+++ AlphaFlow/trunk/activity.py Wed Mar 14 16:40:42 2007
(at)(at) -3,6 +3,7 (at)(at)
# $Id$
"""Activity definitions"""
+import zope.interface
from Globals import InitializeClass
from Persistence import Persistent
from AccessControl import ClassSecurityInfo, getSecurityManager, Unauthorized
(at)(at) -29,7 +30,7 (at)(at)
- represent the general concept of exits
"""
- __implements__ = (IExit, )
+ zope.interface.implements(IExit)
nodeName = "exit"
attributes = (
(at)(at) -56,7 +57,8 (at)(at)
class BaseActivity(PropertyManager, SimpleItem, DOMImporter):
"""A base class to implement activities"""
- __implements__ = SimpleItem.__implements__ + (IActivity,)
+ zope.interface.implements(IActivity)
+
security = ClassSecurityInfo()
activity_type = nodeName = None
(at)(at) -159,7 +161,7 (at)(at)
class BaseAutomaticActivity(BaseActivity):
"""A base class for automatic activities (single exit)"""
- __implements__ = BaseActivity.__implements__ + (IAutomaticActivity,)
+ zope.interface.implements(IAutomaticActivity)
meta_type = "AlphaFlow Automatic Activity"
security = ClassSecurityInfo()
(at)(at) -193,7 +195,8 (at)(at)
class BaseAssignableActivity(BaseActivity):
"Workflow activity instances of which may be assigned to a member."
- __implements__ = BaseActivity.__implements__ + (IAssignableActivity, )
+ zope.interface.implements(IAssignableActivity)
+
security = ClassSecurityInfo()
_properties = BaseActivity._properties + (
Modified: AlphaFlow/trunk/adapters/alphaflowable.py
==============================================================================
--- AlphaFlow/trunk/adapters/alphaflowable.py (original)
+++ AlphaFlow/trunk/adapters/alphaflowable.py Wed Mar 14 16:40:42 2007
(at)(at) -79,5 +79,5 (at)(at)
def getAlphaFlowableAdapter(context):
- if IProcessManager.isImplementedBy(context):
+ if IProcessManager.providedBy(context):
return ProcessManagerAdapter(context).__of__(context)
Modified: AlphaFlow/trunk/adapters/renderableadapter.py
==============================================================================
--- AlphaFlow/trunk/adapters/renderableadapter.py (original)
+++ AlphaFlow/trunk/adapters/renderableadapter.py Wed Mar 14 16:40:42 2007
(at)(at) -12,6 +12,7 (at)(at)
except ImportError:
have_lxml = False
+import zope.interface
from Products.AlphaFlow.interfaces import IProcess, IInstance,
IRenderableAdapter
from Products.AlphaFlow.adapters import adapter
from Products.AlphaFlow import config
(at)(at) -390,7 +391,7 (at)(at)
class RenderableAdapter(adapter.Adapter):
- __implements__ = IRenderableAdapter
+ zope.interface.implements(IRenderableAdapter)
def renderGraph(self, format, kind, REQUEST=None):
contenttype = format_contenttype.get(format)
(at)(at) -413,8 +414,8 (at)(at)
return instance_to_dot.get(kind)(process)
def getRenderableAdapter(context):
- if IProcess.isImplementedBy(context):
+ if IProcess.providedBy(context):
return ProcessRenderableAdapter(context)
- if IInstance.isImplementedBy(context):
+ if IInstance.providedBy(context):
return InstanceRenderableAdapter(context)
Modified: AlphaFlow/trunk/doc/examples/Procurement/request.py
==============================================================================
--- AlphaFlow/trunk/doc/examples/Procurement/request.py (original)
+++ AlphaFlow/trunk/doc/examples/Procurement/request.py Wed Mar 14 16:40:42
2007
(at)(at) -3,11 +3,13 (at)(at)
# $Id$
from AccessControl import getSecurityManager
+import zope.interface
from Products.CMFCore.utils import getToolByName
from Products.Archetypes import public as atapi
from Products.ATContentTypes.content.base import ATCTContent as BaseContent
from Products.AlphaFlow import public as afapi
+from Products.AlphaFlow.interfaces import IAlphaFlowed
from Products.Procurement import utils, config
(at)(at) -16,8 +18,7 (at)(at)
"""A procurement request.
"""
- __implements__ = (afapi.AlphaFlowed.__implements__ +
- BaseContent.__implements__)
+ zope.interface.implement(IAlphaFlowed)
schema = atapi.BaseSchema.copy() + atapi.Schema((
atapi.StringField(
Modified: AlphaFlow/trunk/importexport.py
==============================================================================
--- AlphaFlow/trunk/importexport.py (original)
+++ AlphaFlow/trunk/importexport.py Wed Mar 14 16:40:42 2007
(at)(at) -5,6 +5,7 (at)(at)
from xml.dom import minidom
+import zope.interface
from Globals import InitializeClass
from AccessControl import ClassSecurityInfo
(at)(at) -17,7 +18,8 (at)(at)
class DOMImporter:
"""Mixin class with capabilities to import attributes from DOM."""
- __implements__ = (IDOMConfigurable, )
+ zope.interface.implements(IDOMConfigurable)
+
security = ClassSecurityInfo()
context = None
Modified: AlphaFlow/trunk/instance.py
==============================================================================
--- AlphaFlow/trunk/instance.py (original)
+++ AlphaFlow/trunk/instance.py Wed Mar 14 16:40:42 2007
(at)(at) -10,8 +10,9 (at)(at)
import os
# Zope imports
-from zExceptions.ExceptionFormatter import format_exception
+import zope.interface
import zExceptions
+from zExceptions.ExceptionFormatter import format_exception
from Globals import InitializeClass
from AccessControl import getSecurityManager, ClassSecurityInfo
from DateTime import DateTime
(at)(at) -58,7 +59,8 (at)(at)
class Instance(utils.DynamicLocalRoleSupport,
utils.ContentObjectRetrieverBase,
BaseFolder):
- __implements__ = BaseFolder.__implements__ + (IInstance,)
+ zope.interface.implements(IInstance)
+
security = ClassSecurityInfo()
state = "initiated"
(at)(at) -133,7 +135,7 (at)(at)
if len(self.aq_chain) < 2:
return absurl(self)
- if IAlphaFlowed.isImplementedBy(self.aq_chain[1]):
+ if IAlphaFlowed.providedBy(self.aq_chain[1]):
return self.aq_chain[1].absolute_url()
return absurl(self)
(at)(at) -578,7 +580,7 (at)(at)
reasons)
"""
daemons = [ wi for wi in workitems
- if IDaemonActivity.isImplementedBy(wi.getActivity()) ]
+ if IDaemonActivity.providedBy(wi.getActivity()) ]
items_active = len(workitems)
daemons_active = len(daemons)
Modified: AlphaFlow/trunk/interfaces.py
==============================================================================
--- AlphaFlow/trunk/interfaces.py (original)
+++ AlphaFlow/trunk/interfaces.py Wed Mar 14 16:40:42 2007
(at)(at) -5,17 +5,15 (at)(at)
concrete activities and work items found in activities.interfaces.
"""
-# Zope imports
-from Interface import Interface, Attribute
+import zope.interface
-# Sibling imports
from Products.AlphaFlow.interfaces_importexport import *
############
# management
-class IRoleCache(Interface):
+class IRoleCache(zope.interface.Interface):
def updateCacheByWorkItem(workitem):
"""updates cache for work item
(at)(at) -81,10 +79,10 (at)(at)
class IProcessManager(IRoleCache):
"""Manages workflow definitions and instances."""
- id = Attribute("Must be 'workflow_manager'.")
- instances = Attribute("Folder-like object containing workflow instances.")
- processes = Attribute("Folder-like object containing workflow
definitions.")
- schema = Attribute("Path to RelaxNG schema for ALF validation.")
+ id = zope.interface.Attribute("Must be 'workflow_manager'.")
+ instances = zope.interface.Attribute("Folder-like object containing
workflow instances.")
+ processes = zope.interface.Attribute("Folder-like object containing
workflow definitions.")
+ schema = zope.interface.Attribute("Path to RelaxNG schema for ALF
validation.")
def initProcess(process_id, object):
"""Create a new process instance from the definition
<process_id> and
(at)(at) -202,8 +200,8 (at)(at)
class IProcess(IWorkflowAttributeAware, IDOMConfigurable):
"""A process definition."""
- id = Attribute("Id of this process definition.")
- validation_errors = Attribute("String indicating validation errors.")
+ id = zope.interface.Attribute("Id of this process definition.")
+ validation_errors = zope.interface.Attribute("String indicating validation
errors.")
def listActivityIds():
"""Return a list of all activity ids used in this process
definition."""
(at)(at) -225,7 +223,7 (at)(at)
These are the building blocks for process definitions.
"""
- configurationSchema = Attribute(
+ configurationSchema = zope.interface.Attribute(
"An AT schema that can be used to configure a process instance "
"including this activity.")
(at)(at) -268,10 +266,10 (at)(at)
#######################
# content related stuff
-class IAlphaFlowed(Interface):
+class IAlphaFlowed(zope.interface.Interface):
"""A content object manageable by AlphaFlow."""
- instance_id = Attribute("Process instance this object is assigned to.")
+ instance_id = zope.interface.Attribute("Process instance this object is
assigned to.")
def getSuitableProcesses():
"""Return a list of suitable process definitions."""
(at)(at) -319,7 +317,7 (at)(at)
"""detach all (current and old) instances"""
-class IContentObjectRetriever(Interface):
+class IContentObjectRetriever(zope.interface.Interface):
"""Get the content object in various representations."""
def getContentObject():
(at)(at) -351,10 +349,10 (at)(at)
"""A workflow instance.
"""
- process_id = Attribute("Id of the process definition.")
- state = Attribute("Current state of this process instance: one of "
+ process_id = zope.interface.Attribute("Id of the process definition.")
+ state = zope.interface.Attribute("Current state of this process instance:
one of "
"initiated, active, complete, fallout, terminated.")
- event_log = Attribute("A log of events for this work item. A list "
+ event_log = zope.interface.Attribute("A log of events for this work item.
A list "
"of the form (DateTime, user, action, comment)")
def __init__(id, object, process_id):
(at)(at) -484,20 +482,20 (at)(at)
This is an instance of an activity.
"""
- activity_id = Attribute("Id of the activity this is an instance of.")
- activity_type = Attribute("Identifier for this kind of work item.")
+ activity_id = zope.interface.Attribute("Id of the activity this is an
instance of.")
+ activity_type = zope.interface.Attribute("Identifier for this kind of work
item.")
- generated_by = Attribute(
+ generated_by = zope.interface.Attribute(
"Id of the parent work item, None if this is a root work item.")
- generated_workitems = Attribute(
+ generated_workitems = zope.interface.Attribute(
"A list of work item ids this work item has generated.")
- event_log = Attribute(
+ event_log = zope.interface.Attribute(
"A log of events for this work item. "
"A list of the form (DateTime, user, action, comment).")
- state = Attribute("Current state of the work item: "
+ state = zope.interface.Attribute("Current state of the work item: "
"One of active, complete, fallout, terminated.")
- begin = Attribute("DateTime when this work item was created.")
- end = Attribute("DateTime when this work item ended.")
+ begin = zope.interface.Attribute("DateTime when this work item was
created.")
+ end = zope.interface.Attribute("DateTime when this work item ended.")
def getGeneratedWorkItems():
"""Return a list of work items this work item has generated."""
(at)(at) -674,14 +672,14 (at)(at)
##############
# helper stuff
-class IFieldGroup(Interface):
+class IFieldGroup(zope.interface.Interface):
"""Helper class to support a specific sort order when
grouping multiple schemas into a single schema.
"""
- instance = Attribute("IInstance this schema relates to")
- activity_id = Attribute("Id of activity the fields originate from")
- fields = Attribute("sequence of archetype fields")
+ instance = zope.interface.Attribute("IInstance this schema relates to")
+ activity_id = zope.interface.Attribute("Id of activity the fields
originate from")
+ fields = zope.interface.Attribute("sequence of archetype fields")
def __cmp__(other):
"""compares IFieldGroups by getSortPriority()"""
(at)(at) -699,12 +697,12 (at)(at)
"""returns sort priority of activity"""
-class IAction(Interface):
+class IAction(zope.interface.Interface):
"""An action to be performed on a work item."""
- id = Attribute('ID of the action. Must be unique for each work item.')
- title = Attribute('Title of the action. May be unicode.')
- url = Attribute('URL to trigger the action.')
+ id = zope.interface.Attribute('ID of the action. Must be unique for each
work item.')
+ title = zope.interface.Attribute('Title of the action. May be unicode.')
+ url = zope.interface.Attribute('URL to trigger the action.')
def __call__():
"""Execute the action.
(at)(at) -713,7 +711,7 (at)(at)
"""
-class IRenderableAdapter(Interface):
+class IRenderableAdapter(zope.interface.Interface):
"""Adapter to render an object as graph."""
def renderGraph(format, kind, REQUEST=None):
(at)(at) -727,7 +725,7 (at)(at)
"""
-class IReferenceManager(Interface):
+class IReferenceManager(zope.interface.Interface):
"""Adapter to manage references between activities"""
def manageActivityReference(to):
(at)(at) -736,6 +734,4 (at)(at)
"""
-# Need the activity interface here after a refactoring for backwards
-# compatibility
from Products.AlphaFlow.activities.interfaces import *
Modified: AlphaFlow/trunk/interfaces_importexport.py
==============================================================================
--- AlphaFlow/trunk/interfaces_importexport.py (original)
+++ AlphaFlow/trunk/interfaces_importexport.py Wed Mar 14 16:40:42 2007
(at)(at) -5,14 +5,13 (at)(at)
resp. to ALF.
"""
-# Zope imports
-from Interface import Interface, Attribute
+import zope.interface
+
-
#####################
# import/export stuff
-class IDOMConfigurable(Interface):
+class IDOMConfigurable(zope.interface.Interface):
"""Implemented by objects which are configurable by DOM nodes."""
def __init__(id, *args, **kw):
(at)(at) -44,38 +43,38 (at)(at)
"""
-class IWorkflowAttributeAware(Interface):
+class IWorkflowAttributeAware(zope.interface.Interface):
"""Class implementing this interface uses IWorkflowAttributes."""
- attributes = Attribute("Tuple of IWorkflowAttributes")
- nodeName = Attribute("NodeName in DOM.")
- context = Attribute("""\
+ attributes = zope.interface.Attribute("Tuple of IWorkflowAttributes")
+ nodeName = zope.interface.Attribute("NodeName in DOM.")
+ context = zope.interface.Attribute("""\
Parent node name in DOM which, if matching, makes this class be
preferred to any class registered for the same nodeName but with
another or no parent node name specified.""")
-class IWorkflowAttribute(Interface):
+class IWorkflowAttribute(zope.interface.Interface):
"""Attribute on objects in workflow (activity, process, ...)
data used for import and export
"""
- classAttr = Attribute("Name of the attribute in the python class.")
- domAttr = Attribute("Name of the attribute in the dom.")
- default = Attribute("Default value.")
- description = Attribute("Description for the attribute.")
- required = Attribute("Is this Attribute required?")
- encoding = Attribute("Encode value with this encoding before converting to
"
+ classAttr = zope.interface.Attribute("Name of the attribute in the python
class.")
+ domAttr = zope.interface.Attribute("Name of the attribute in the dom.")
+ default = zope.interface.Attribute("Default value.")
+ description = zope.interface.Attribute("Description for the attribute.")
+ required = zope.interface.Attribute("Is this Attribute required?")
+ encoding = zope.interface.Attribute("Encode value with this encoding
before converting to "
"datatype. May be None if no encoding needed.")
- datatype = Attribute("Datatype of value as type.")
- vocabulary = Attribute("List or tuple of allowed values or None.")
- importHandler = Attribute("Name of the method which handles the import "
+ datatype = zope.interface.Attribute("Datatype of value as type.")
+ vocabulary = zope.interface.Attribute("List or tuple of allowed values or
None.")
+ importHandler = zope.interface.Attribute("Name of the method which handles
the import "
"of this attribute or None for no import. "
"The method must accept exactly two parameters:"
" - the WorkflowAttribute"
" - the dom node to be read from")
- exportHandler = Attribute("Name of the method which handles the export "
+ exportHandler = zope.interface.Attribute("Name of the method which handles
the export "
"of this attribute or None for no export. "
"The method must accept exactly two parameters:"
" - the WorkflowAttribute"
(at)(at) -89,7 +88,7 (at)(at)
"Constructor."
-class IRegistry(Interface):
+class IRegistry(zope.interface.Interface):
"""Registry for class objects."""
def register(klass):
Modified: AlphaFlow/trunk/patch_plone_types.py
==============================================================================
--- AlphaFlow/trunk/patch_plone_types.py (original)
+++ AlphaFlow/trunk/patch_plone_types.py Wed Mar 14 16:40:42 2007
(at)(at) -4,6 +4,7 (at)(at)
from Products.AlphaFlow.config import PATCH_PLONE_TYPES
+import zope.interface
_already_patched = False
(at)(at) -14,42 +15,34 (at)(at)
from Products.ATContentTypes.content import document, event,\
file, image, link, newsitem, folder, topic
from Products.AlphaFlow.workflowedobject import AlphaFlowed
+ from Products.AlphaFlow.interfaces import IAlphaFlowed
class ATDocument(AlphaFlowed, document.ATDocument):
- __implements__ = (AlphaFlowed.__implements__,) + \
- document.ATDocument.__implements__
+ zope.interface.implements(IAlphaFlowed)
class ATEvent(AlphaFlowed, event.ATEvent):
- __implements__ = (AlphaFlowed.__implements__,) + \
- event.ATEvent.__implements__
+ zope.interface.implements(IAlphaFlowed)
class ATFile(AlphaFlowed, file.ATFile):
- __implements__ = (AlphaFlowed.__implements__,) + \
- file.ATFile.__implements__
+ zope.interface.implements(IAlphaFlowed)
class ATImage(AlphaFlowed, image.ATImage):
- __implements__ = (AlphaFlowed.__implements__,) + \
- image.ATImage.__implements__
+ zope.interface.implements(IAlphaFlowed)
class ATLink(AlphaFlowed, link.ATLink):
- __implements__ = (AlphaFlowed.__implements__,) + \
- link.ATLink.__implements__
+ zope.interface.implements(IAlphaFlowed)
class ATNewsItem(AlphaFlowed, newsitem.ATNewsItem):
- __implements__ = (AlphaFlowed.__implements__,) + \
- newsitem.ATNewsItem.__implements__
+ zope.interface.implements(IAlphaFlowed)
class ATFolder(AlphaFlowed, folder.ATFolder):
- __implements__ = (AlphaFlowed.__implements__,) + \
- folder.ATFolder.__implements__
+ zope.interface.implements(IAlphaFlowed)
class ATTopic(AlphaFlowed, topic.ATTopic):
- __implements__ = (AlphaFlowed.__implements__,) + \
- topic.ATTopic.__implements__
+ zope.interface.implements(IAlphaFlowed)
class ATBTreeFolder(AlphaFlowed, folder.ATBTreeFolder):
- __implements__ = (AlphaFlowed.__implements__,) + \
- folder.ATBTreeFolder.__implements__
+ zope.interface.implements(IAlphaFlowed)
document.ATDocument = ATDocument
document.ATDocument.__module__ = \
Modified: AlphaFlow/trunk/process.py
==============================================================================
--- AlphaFlow/trunk/process.py (original)
+++ AlphaFlow/trunk/process.py Wed Mar 14 16:40:42 2007
(at)(at) -3,6 +3,7 (at)(at)
# $Id$
"""Process definitions"""
+import zope.interface
from OFS.Folder import Folder
from AccessControl import ClassSecurityInfo
from Globals import InitializeClass
(at)(at) -23,7 +24,8 (at)(at)
class Process(Folder, DOMImporter):
- __implements__ = Folder.__implements__ + (IProcess,)
+ zope.interface.implements(IProcess)
+
meta_type = "AlphaFlow Process"
security = ClassSecurityInfo()
Modified: AlphaFlow/trunk/processmanager.py
==============================================================================
--- AlphaFlow/trunk/processmanager.py (original)
+++ AlphaFlow/trunk/processmanager.py Wed Mar 14 16:40:42 2007
(at)(at) -10,6 +10,7 (at)(at)
from threading import Lock
# Zope imports
+import zope.interface
import zExceptions
import transaction
from webdav.NullResource import NullResource
(at)(at) -42,8 +43,8 (at)(at)
class ProcessManager(RoleCache, UniqueObject, ActionProviderBase, Folder):
"""A process management object."""
- __implements__ = Folder.__implements__ + (IProcessManager,)
-
+ zope.interface.implements(IProcessManager)
+
id = 'workflow_manager'
meta_type = "AlphaFlow Process Manager"
schema = file(config.LOCATION + config.schemapath).read()
(at)(at) -461,7 +462,7 (at)(at)
c1.alf_clearInstances()
def _check(o, path):
- if IAlphaFlowed.isImplementedBy(o):
+ if IAlphaFlowed.providedBy(o):
_check_double_refs(o, path)
_clean_object(o, path)
Modified: AlphaFlow/trunk/registry.py
==============================================================================
--- AlphaFlow/trunk/registry.py (original)
+++ AlphaFlow/trunk/registry.py Wed Mar 14 16:40:42 2007
(at)(at) -3,19 +3,18 (at)(at)
# $Id$
"""Registry for activities etc."""
-# Python imports
from types import ClassType
-# Zope imports
+import zope.interface
from ExtensionClass import ExtensionClass
-# sibling imports
from Products.AlphaFlow.interfaces import IRegistry
+
class Registry:
"""Registry for class objects which implement IWorkflowAttributeAware."""
- __implements__ = (IRegistry, )
+ zope.interface.implements(IRegistry)
_registry = None
Modified: AlphaFlow/trunk/rolecache.py
==============================================================================
--- AlphaFlow/trunk/rolecache.py (original)
+++ AlphaFlow/trunk/rolecache.py Wed Mar 14 16:40:42 2007
(at)(at) -5,22 +5,25 (at)(at)
from BTrees.OOBTree import OOBTree
+import zope.interface
+
from Products.AlphaFlow.interfaces import IRoleCache
class RoleCache:
"""support for caching roles in a fast efficient manner"""
- __implements__ = (IRoleCache, )
-
+
+ zope.interface.implements(IRoleCache)
+
cache_names = ['_workitem_role_cache', '_content_role_cache',
'_instance_workitem_cache', '_instance_role_cache']
-
+
def initializeRoleCache(self):
for name in self.cache_names:
if hasattr(self, name):
continue
setattr(self, name, OOBTree())
-
+
def updateCacheByWorkItem(self, workitem):
"""updates cache for workitem"""
instance = workitem.getInstance()
(at)(at) -28,7 +31,7 (at)(at)
self._aggregate_role_cache(instance)
content = workitem.getContentObject()
content.reindexObjectSecurity()
-
+
def updateCacheByContent(self, content):
if not hasattr(content.aq_base, 'getInstance'):
return
(at)(at) -44,7 +47,7 (at)(at)
content = instance.getContentObject()
if index_content:
content.reindexObjectSecurity()
-
+
def getDynamicRolesForWorkItem(self, workitem, user):
return self._workitem_role_cache[workitem.getId()][user]
(at)(at) -53,7 +56,7 (at)(at)
def getDynamicRolesForContent(self, content, user):
return self._content_role_cache[content.UID()][user]
-
+
def listRelevantUsersForWorkItem(self, workitem):
"""return a list with all relevant users for a workitem
relevant are all assigned users
(at)(at) -87,11 +90,11 (at)(at)
"""
workitem_role_cache = self._workitem_role_cache
instance_workitem_cache = self._instance_workitem_cache
-
+
workitem_id = workitem.getId()
instance_id = instance.getId()
relevant_users = workitem.listRelevantUsers()
-
+
if relevant_users:
iwc = instance_workitem_cache.get(instance_id)
if iwc is None:
(at)(at) -109,12 +112,11 (at)(at)
else:
if not instance_workitem_cache[instance_id]:
del instance_workitem_cache[instance_id]
-
+
try:
del workitem_role_cache[workitem_id]
except KeyError:
pass
-
def _aggregate_role_cache(self, instance):
"""update instance_role_cache and content_role_cache from
Modified: AlphaFlow/trunk/tests/AlphaFlowTestCase.py
==============================================================================
--- AlphaFlow/trunk/tests/AlphaFlowTestCase.py (original)
+++ AlphaFlow/trunk/tests/AlphaFlowTestCase.py Wed Mar 14 16:40:42 2007
(at)(at) -44,6 +44,8 (at)(at)
('group1', ['editor1', 'editor2', 'editor3']),
]
+ z2_interfaces_to_test = []
+
def afterSetUp(self):
ArcheSiteTestCase.afterSetUp(self)
uf = self.portal.acl_users
(at)(at) -92,10 +94,23 (at)(at)
context.invokeFactory(type, id)
return getattr(context, id)
+ def test_z2interface(self):
+ failed = []
+ for i, c in self.z2_interfaces_to_test:
+ self.failUnless(i.isImplementedByInstancesOf(c),
+ "%r is not implemented by %r" % (i,c))
+ methlist = i.namesAndDescriptions(all=True)
+ for meth in methlist:
+ if not hasattr(c, meth[0]):
+ failed.append('Method %r not implemented by %s' % (
+ meth[0], c))
+ self.assertEquals(failed, [], 'Interface tests failed:\n%s' % (
+ '\n'.join(failed), ))
+
def test_interface(self):
failed = []
for i, c in self.interfaces_to_test:
- self.failUnless(i.isImplementedByInstancesOf(c),
+ self.failUnless(i.implementedBy(c),
"%r is not implemented by %r" % (i,c))
methlist = i.namesAndDescriptions(all=True)
for meth in methlist:
Modified: AlphaFlow/trunk/tests/test_alarm.py
==============================================================================
--- AlphaFlow/trunk/tests/test_alarm.py (original)
+++ AlphaFlow/trunk/tests/test_alarm.py Wed Mar 14 16:40:42 2007
(at)(at) -41,7 +41,7 (at)(at)
def _getAlarmWorkItem(self, workitems):
for wi in workitems:
- if IAlarmWorkItem.isImplementedBy(wi):
+ if IAlarmWorkItem.providedBy(wi):
return wi
raise RuntimeError
Modified: AlphaFlow/trunk/tests/test_definition.py
==============================================================================
--- AlphaFlow/trunk/tests/test_definition.py (original)
+++ AlphaFlow/trunk/tests/test_definition.py Wed Mar 14 16:40:42 2007
(at)(at) -342,7 +342,7 (at)(at)
self.assert_(alf.getProcess(pid, default) is default)
alf.addProcess(pid)
process = alf.getProcess(pid)
- self.assert_(IProcess.isImplementedBy(process))
+ self.assert_(IProcess.providedBy(process))
self.assertEquals(alf.getProcess(pid, default), process)
self.failUnless(process in alf.listProcesses())
Modified: AlphaFlow/trunk/tests/test_email.py
==============================================================================
--- AlphaFlow/trunk/tests/test_email.py (original)
+++ AlphaFlow/trunk/tests/test_email.py Wed Mar 14 16:40:42 2007
(at)(at) -58,7 +58,7 (at)(at)
instance = doc.getInstance()
instance.start("comment")
wi = instance.getWorkItems(state="complete")[0]
- self.assert_(IEMailWorkItem.isImplementedBy(wi))
+ self.assert_(IEMailWorkItem.providedBy(wi))
ro = RecipientOwner('ro')
rna = RecipientNextAssignees('rna')
Modified: AlphaFlow/trunk/tests/test_ntask.py
==============================================================================
--- AlphaFlow/trunk/tests/test_ntask.py (original)
+++ AlphaFlow/trunk/tests/test_ntask.py Wed Mar 14 16:40:42 2007
(at)(at) -55,7 +55,7 (at)(at)
self.assertEquals(1, len(wis))
ntaskitem = wis[0]
- self.assert_(INTaskWorkItem.isImplementedBy(ntaskitem))
+ self.assert_(INTaskWorkItem.providedBy(ntaskitem))
actions = ntaskitem.getActions()
self.assertEquals(3, len(actions))
Modified: AlphaFlow/trunk/tests/test_security.py
==============================================================================
--- AlphaFlow/trunk/tests/test_security.py (original)
+++ AlphaFlow/trunk/tests/test_security.py Wed Mar 14 16:40:42 2007
(at)(at) -86,9 +86,9 (at)(at)
class SecurityTest(AlphaFlowTestCase):
interfaces_to_test = [(IInstance, Instance),
- (IProcess, Process),
- (PluggableIndexInterface, EventChannelIndex),
- ]
+ (IProcess, Process),]
+ z2_interfaces_to_test = [(PluggableIndexInterface, EventChannelIndex),
+ ]
def _create_instance(self):
portal = self.portal
Modified: AlphaFlow/trunk/utils.py
==============================================================================
--- AlphaFlow/trunk/utils.py (original)
+++ AlphaFlow/trunk/utils.py Wed Mar 14 16:40:42 2007
(at)(at) -473,10 +473,10 (at)(at)
workitem = None
activity = None
- if IWorkItem.isImplementedBy(context):
+ if IWorkItem.providedBy(context):
workitem = context
activity = workitem.getActivity()
- elif IActivity.isImplementedBy(context):
+ elif IActivity.providedBy(context):
workitem = None
activity = context
Modified: AlphaFlow/trunk/workflowattr.py
==============================================================================
--- AlphaFlow/trunk/workflowattr.py (original)
+++ AlphaFlow/trunk/workflowattr.py Wed Mar 14 16:40:42 2007
(at)(at) -3,17 +3,19 (at)(at)
# $Id$
"""WorkflowAttribute definitions and helpers"""
-# Sibling imports
+import zope.interface
+
from Products.AlphaFlow.interfaces import IWorkflowAttribute
from Products.AlphaFlow.registry import Registry
+
class WorkflowAttribute:
"""Attribute on objects in workflow (activity, process, ...)
data used for import and export
"""
- __implements__ = (IWorkflowAttribute,)
+ zope.interface.implements(IWorkflowAttribute)
classAttr = None
domAttr = None
Modified: AlphaFlow/trunk/workflowedobject.py
==============================================================================
--- AlphaFlow/trunk/workflowedobject.py (original)
+++ AlphaFlow/trunk/workflowedobject.py Wed Mar 14 16:40:42 2007
(at)(at) -3,7 +3,7 (at)(at)
# $Id$
"""Base workflowed object"""
-# Zope imports
+import zope.interface
import Globals
from AccessControl import getSecurityManager, ClassSecurityInfo
(at)(at) -16,7 +16,6 (at)(at)
from Products.AlphaFlow import config, utils
-
class LocalRoleFake(dict):
"""backward compatibility
(at)(at) -24,26 +23,25 (at)(at)
XXX: remove this class after cleanup is out for some versions
"""
-
-
+
+
class AlphaFlowedLocalRoleFake(utils.LocalRoleFakeBase):
-
+
def _get_rolecache_for_user(self, user):
alf = self._processmanager
content = self._context
roles = alf.getDynamicRolesForContent(content, user)
return roles
-
+
def _get_users_with_cached_roles(self):
return self._processmanager.listRelevantUsersForContent(self._context)
-
class AlphaFlowed(utils.DynamicLocalRoleSupport):
"""Mixin for 'AlphaFlowed' content"""
- __implements__ = (IAlphaFlowed, )
-
+ zope.interface.implements(IAlphaFlowed)
+
instance_id = None
alf_old_instances = [] # XXX this is currently updated
# from outside when the instance completes
Modified: AlphaFlow/trunk/workitem.py
==============================================================================
--- AlphaFlow/trunk/workitem.py (original)
+++ AlphaFlow/trunk/workitem.py Wed Mar 14 16:40:42 2007
(at)(at) -3,24 +3,21 (at)(at)
# $Id$
"""Workitem definitions"""
-# Python imports
import sys
import os
from warnings import warn
-# Zope imports
+import zope.interface
from AccessControl import getSecurityManager, ClassSecurityInfo
from Globals import InitializeClass
from DateTime import DateTime
from Products.PageTemplates.PageTemplateFile import PageTemplateFile
from zExceptions.ExceptionFormatter import format_exception
-# Plone/AT imports
from Products.CMFCore.utils import getToolByName
from Products.CMFCore import permissions
from Products.Archetypes import public as atapi
-# Sibling imports
from Products.AlphaFlow import config, utils
from Products.AlphaFlow.utils import \
DynamicLocalRoleSupport, LocalRoleFakeBase, modifyRolesForPermission,
\
(at)(at) -33,7 +30,7 (at)(at)
DEBUG_FALLOUT = os.getenv('ALPHAFLOW_RAISE_ON_FALLOUT')
-
+
class WorkItemLocalRoleFake(LocalRoleFakeBase):
"""fakes a dictionary for local role support"""
(at)(at) -46,11 +43,12 (at)(at)
def _get_users_with_cached_roles(self):
return
self._processmanager.listRelevantUsersForWorkItem(self._context)
-
+
class BaseWorkItem(DynamicLocalRoleSupport, ContentObjectRetrieverBase,
atapi.BaseContent):
- __implements__ = atapi.BaseContent.__implements__ + (IWorkItem,)
+ zope.interface.implements(IWorkItem)
+
security = ClassSecurityInfo()
global_allow = False
(at)(at) -226,7 +224,7 (at)(at)
parent = self.getInstance()[self.generated_by]
# XXX This is a work-around; generated_by should never contain
# the id of an instance.
- if not IWorkItem.isImplementedBy(parent):
+ if not IWorkItem.providedBy(parent):
return None
else:
return parent
(at)(at) -348,7 +346,7 (at)(at)
if len(self.aq_chain) < 2:
return absurl(self)
- if IAlphaFlowed.isImplementedBy(self.aq_chain[1]):
+ if IAlphaFlowed.providedBy(self.aq_chain[1]):
return self.aq_chain[1].absolute_url()
return absurl(self)
(at)(at) -447,12 +445,10 (at)(at)
InitializeClass(BaseWorkItem)
-
class BaseAssignableWorkItem(BaseWorkItem):
"""workitems which are assignable to users subclass this"""
- __implements__ = BaseWorkItem.__implements__ + \
- (IAssignableWorkItem, )
+ zope.interface.implements(IAssignableWorkItem)
security = ClassSecurityInfo()
(at)(at) -462,7 +458,7 (at)(at)
return []
activity = self.getActivity()
- assert IAssignableActivity.isImplementedBy(activity)
+ assert IAssignableActivity.providedBy(activity)
if activity.assigneesKind == 'possible':
relevant = self.getActivityConfiguration("assignees")
if not isinstance(relevant, (list, tuple)):
(at)(at) -561,14 +557,14 (at)(at)
InitializeClass(BaseAssignableWorkItem)
-
+
class BaseAutomaticWorkItem(BaseWorkItem):
"""A base class for work items that work automatically."""
security = ClassSecurityInfo()
- __implements__ = BaseWorkItem.__implements__ + \
- (IAutomaticWorkItem, )
-
+
+ zope.interface.implements(IAutomaticWorkItem)
+
security.declareProtected(config.WORK_WITH_PROCESS, "getActions")
def getActions(self):
"""Determine all possible actions."""
(at)(at) -628,34 +624,34 (at)(at)
grouping multiple schemas into a single schema.
"""
- __implements__ = (IFieldGroup, )
-
+ zope.interface.implements(IFieldGroup)
+
__allow_access_to_unprotected_subobjects__ = 1
def __init__(self, instance, activity_id, fields):
self.instance = instance
self.activity_id = activity_id
self.fields = fields
-
+
def __cmp__(self, other):
return cmp(self.getSortPriority(), other.getSortPriority())
-
+
def Title(self):
return self.getActivity().title_or_id()
-
+
def getProcess(self):
return self.instance.getProcess()
def getActivity(self):
return self.getProcess()[self.activity_id]
-
+
def getSortPriority(self):
return self.getActivity().sortPriority
class WorkItemRegistry(Registry):
"""Registry for workitems."""
-
+
def _compute_key(self, klass):
"Compute the search key from a class object."
return klass.activity_type
|
SVN: r4575 - in AlphaFlow/trunk: . activities
Christian Theune <ct(at)gocept.com> |
2007-03-15 09:55:52 |
[ FULL ]
|
Author: ctheune
Date: Thu Mar 15 09:55:50 2007
New Revision: 4575
Log:
- moved computation of exits into properties
Modified:
AlphaFlow/trunk/activities/configuration.py
AlphaFlow/trunk/activities/decision.py
AlphaFlow/trunk/activities/ntask.py
AlphaFlow/trunk/activities/parent.py
AlphaFlow/trunk/activities/recursion.py
AlphaFlow/trunk/activities/routing.py
AlphaFlow/trunk/activities/simpledecision.py
AlphaFlow/trunk/activities/switch.py
AlphaFlow/trunk/activities/task.py
AlphaFlow/trunk/activity.py
Modified: AlphaFlow/trunk/activities/configuration.py
==============================================================================
--- AlphaFlow/trunk/activities/configuration.py (original)
+++ AlphaFlow/trunk/activities/configuration.py Thu Mar 15 09:55:50 2007
(at)(at) -51,9 +51,11 (at)(at)
exportHandler='_attr_export_configure'),
)
- security.declarePrivate('manage_afterAdd')
- def manage_afterAdd(self, item, container):
- self.exits['completion'] = Exit("completion", self.continue_activity)
+ (at)property
+ def exits(self):
+ exits = {}
+ exits['completion'] = Exit("completion", self.continue_activity)
+ return exits
#########
# private
Modified: AlphaFlow/trunk/activities/decision.py
==============================================================================
--- AlphaFlow/trunk/activities/decision.py (original)
+++ AlphaFlow/trunk/activities/decision.py Thu Mar 15 09:55:50 2007
(at)(at) -76,10 +76,12 (at)(at)
format='checkbox',
)
- security.declarePrivate('manage_afterAdd')
- def manage_afterAdd(self, item, container):
- self.exits['accept'] = Exit("accept", self.accept_activity)
- self.exits['reject'] = Exit("reject", self.reject_activity)
+ (at)property
+ def exits(self):
+ exits = {}
+ exits['accept'] = Exit("accept", self.accept_activity)
+ exits['reject'] = Exit("reject", self.reject_activity)
+ return exits
security.declareProtected(config.MANAGE_WORKFLOW,
"graphGetPossibleChildren")
Modified: AlphaFlow/trunk/activities/ntask.py
==============================================================================
--- AlphaFlow/trunk/activities/ntask.py (original)
+++ AlphaFlow/trunk/activities/ntask.py Thu Mar 15 09:55:50 2007
(at)(at) -47,12 +47,13 (at)(at)
)),
)) + BaseAssignableActivity.configurationSchema
- security.declarePrivate('manage_afterAdd')
- def manage_afterAdd(self, item, container):
- super(NTaskActivity, self).manage_afterAdd(item, container)
+ (at)property
+ def exits(self):
+ exits = {}
# Make data structure that stores the exits after the import
# compatible with the real exit infrastructure.
- self.exits.update((exit.id, exit) for exit in self._exits)
+ exits.update((exit.id, exit) for exit in self._exits)
+ return exits
class NTaskWorkItem(BaseAssignableWorkItem):
Modified: AlphaFlow/trunk/activities/parent.py
==============================================================================
--- AlphaFlow/trunk/activities/parent.py (original)
+++ AlphaFlow/trunk/activities/parent.py Thu Mar 15 09:55:50 2007
(at)(at) -12,6 +12,7 (at)(at)
import zope.interface
from AccessControl import ClassSecurityInfo
+from ComputedAttribute import ComputedAttribute
from Products.AlphaFlow.workitem import registerWorkItem,
BaseAutomaticWorkItem
from Products.AlphaFlow.activity import \
Exit, registerActivity, BaseAutomaticActivity
(at)(at) -64,12 +65,13 (at)(at)
),
)
- security.declarePrivate('manage_afterAdd')
- def manage_afterAdd(self, item, container):
- """This activity can start any activity that is a possible
- parent of the activity in our 'parentOf' attribute.
- """
- self.exits["parent"] = ParentExit("parent", self)
+ # We have to use ComputedAttribute here because we depend on `self` being
+ # acquisition-wrapped.
+ def exits(self):
+ exits = {}
+ exits["parent"] = ParentExit("parent", self)
+ return exits
+ exits = ComputedAttribute(exits, 1)
class ParentWorkItem(BaseAutomaticWorkItem):
Modified: AlphaFlow/trunk/activities/recursion.py
==============================================================================
--- AlphaFlow/trunk/activities/recursion.py (original)
+++ AlphaFlow/trunk/activities/recursion.py Thu Mar 15 09:55:50 2007
(at)(at) -61,11 +61,12 (at)(at)
'mode':'w', 'select_variable':'listActivityIds'}
)
- security.declarePrivate('manage_afterAdd')
- def manage_afterAdd(self, item, container):
- self.exits.update(
- recursion=Exit("recursion", self.recursion_activity),
- continuation=Exit("continuation", self.continue_activity))
+ (at)property
+ def exits(self):
+ exits = {}
+ exits['recursion'] = Exit("recursion", self.recursion_activity)
+ exits['continuation'] = Exit("continuation", self.continue_activity)
+ return exits
security.declarePrivate("getConfigurationSchema")
def getConfigurationSchema(self, content):
Modified: AlphaFlow/trunk/activities/routing.py
==============================================================================
--- AlphaFlow/trunk/activities/routing.py (original)
+++ AlphaFlow/trunk/activities/routing.py Thu Mar 15 09:55:50 2007
(at)(at) -57,9 +57,11 (at)(at)
'select_variable': 'listActivityIds'},
)
- security.declarePrivate('manage_afterAdd')
- def manage_afterAdd(self, item, container):
- self.exits["routes"] = Exit("routes", self.routes)
+ (at)property
+ def exits(self):
+ exits = {}
+ exits["routes"] = Exit("routes", self.routes)
+ return exits
#########
# private
Modified: AlphaFlow/trunk/activities/simpledecision.py
==============================================================================
--- AlphaFlow/trunk/activities/simpledecision.py (original)
+++ AlphaFlow/trunk/activities/simpledecision.py Thu Mar 15 09:55:50 2007
(at)(at) -67,11 +67,12 (at)(at)
format='checkbox',
)
- security.declarePrivate('manage_afterAdd')
- def manage_afterAdd(self, item, container):
- self.exits.update(
- accept=Exit("accept", self.accept_activity),
- reject=Exit("reject", self.reject_activity))
+ (at)property
+ def exits(self):
+ exits = {}
+ exits['accept'] = Exit("accept", self.accept_activity)
+ exits['reject'] = Exit("reject", self.reject_activity)
+ return exits
security.declareProtected(config.MANAGE_WORKFLOW,
"graphGetPossibleChildren")
Modified: AlphaFlow/trunk/activities/switch.py
==============================================================================
--- AlphaFlow/trunk/activities/switch.py (original)
+++ AlphaFlow/trunk/activities/switch.py Thu Mar 15 09:55:50 2007
(at)(at) -56,10 +56,11 (at)(at)
exportHandler="_attr_export_as_childnodes"),
)
- security.declarePrivate('manage_afterAdd')
- def manage_afterAdd(self, item, container):
- super(SwitchActivity, self).manage_afterAdd(item, container)
- self.exits.update((exit.id, exit) for exit in self.cases)
+ (at)property
+ def exits(self):
+ exits = {}
+ exits.update((exit.id, exit) for exit in self.cases)
+ return exits
class SwitchWorkItem(BaseAutomaticWorkItem):
Modified: AlphaFlow/trunk/activities/task.py
==============================================================================
--- AlphaFlow/trunk/activities/task.py (original)
+++ AlphaFlow/trunk/activities/task.py Thu Mar 15 09:55:50 2007
(at)(at) -51,10 +51,11 (at)(at)
'select_variable': 'listActivityIds'},
)
- security.declarePrivate('manage_afterAdd')
- def manage_afterAdd(self, item, container):
- self.exits["completion"] = Exit("completion",
- self.completion_activity)
+ (at)property
+ def exits(self):
+ exits = {}
+ exits["completion"] = Exit("completion", self.completion_activity)
+ return exits
class TaskWorkItem(BaseAssignableWorkItem):
Modified: AlphaFlow/trunk/activity.py
==============================================================================
--- AlphaFlow/trunk/activity.py (original)
+++ AlphaFlow/trunk/activity.py Thu Mar 15 09:55:50 2007
(at)(at) -92,14 +92,6 (at)(at)
datatype=str),
)
- exits = None # Is set to {} in __init__. This is None to satisfy
- # interface validation requirements and avoid working
- # with a class-attribute dict accidentally.
-
- def __init__(self, *args, **kw):
- super(BaseActivity, self).__init__(*args, **kw)
- self.exits = {}
-
security.declareProtected(config.MANAGE_WORKFLOW, "acquireActivity")
def acquireActivity(self):
"""returns the activity instance from the acquisition chain"""
(at)(at) -183,10 +175,12 (at)(at)
'mode': 'w', 'select_variable': 'listActivityIds'},
)
- security.declarePrivate('manage_afterAdd')
- def manage_afterAdd(self, item, container):
- super(BaseAutomaticActivity, self).manage_afterAdd(item, container)
- self.exits['continuation'] = Exit('continuation',
self.continue_activity)
+
+ (at)property
+ def exits(self):
+ exits = {}
+ exits['continuation'] = Exit('continuation', self.continue_activity)
+ return exits
InitializeClass(BaseAutomaticActivity)
|
SVN: r4576 - in AlphaFlow/trunk: . activities
Christian Theune <ct(at)gocept.com> |
2007-03-15 10:26:19 |
[ FULL ]
|
Author: ctheune
Date: Thu Mar 15 10:26:16 2007
New Revision: 4576
Log:
- switched away from properties as they cause problems with acquisition
Modified:
AlphaFlow/trunk/activities/configuration.py
AlphaFlow/trunk/activities/decision.py
AlphaFlow/trunk/activities/ntask.py
AlphaFlow/trunk/activities/parent.py
AlphaFlow/trunk/activities/recursion.py
AlphaFlow/trunk/activities/routing.py
AlphaFlow/trunk/activities/simpledecision.py
AlphaFlow/trunk/activities/switch.py
AlphaFlow/trunk/activities/task.py
AlphaFlow/trunk/activity.py
Modified: AlphaFlow/trunk/activities/configuration.py
==============================================================================
--- AlphaFlow/trunk/activities/configuration.py (original)
+++ AlphaFlow/trunk/activities/configuration.py Thu Mar 15 10:26:16 2007
(at)(at) -51,8 +51,7 (at)(at)
exportHandler='_attr_export_configure'),
)
- (at)property
- def exits(self):
+ def getExits(self):
exits = {}
exits['completion'] = Exit("completion", self.continue_activity)
return exits
Modified: AlphaFlow/trunk/activities/decision.py
==============================================================================
--- AlphaFlow/trunk/activities/decision.py (original)
+++ AlphaFlow/trunk/activities/decision.py Thu Mar 15 10:26:16 2007
(at)(at) -76,8 +76,7 (at)(at)
format='checkbox',
)
- (at)property
- def exits(self):
+ def getExits(self):
exits = {}
exits['accept'] = Exit("accept", self.accept_activity)
exits['reject'] = Exit("reject", self.reject_activity)
Modified: AlphaFlow/trunk/activities/ntask.py
==============================================================================
--- AlphaFlow/trunk/activities/ntask.py (original)
+++ AlphaFlow/trunk/activities/ntask.py Thu Mar 15 10:26:16 2007
(at)(at) -47,8 +47,7 (at)(at)
)),
)) + BaseAssignableActivity.configurationSchema
- (at)property
- def exits(self):
+ def getExits(self):
exits = {}
# Make data structure that stores the exits after the import
# compatible with the real exit infrastructure.
(at)(at) -71,7 +70,7 (at)(at)
def getActions(self):
"""Determine all possible actions."""
return [self._get_action(exit)
- for exit in self.getActivity().exits.values()]
+ for exit in self.getActivity().getExits().values()]
security.declarePrivate('_get_action')
def _get_action(self, exit):
(at)(at) -95,7 +94,7 (at)(at)
raise ValueError, "Can't complete a task that isn't active."
created = False
- for exit_ in self.getActivity().exits.values():
+ for exit_ in self.getActivity().getExits().values():
if exit_.id == exit:
self.createWorkItems(exit_.activities)
created=True
Modified: AlphaFlow/trunk/activities/parent.py
==============================================================================
--- AlphaFlow/trunk/activities/parent.py (original)
+++ AlphaFlow/trunk/activities/parent.py Thu Mar 15 10:26:16 2007
(at)(at) -65,13 +65,10 (at)(at)
),
)
- # We have to use ComputedAttribute here because we depend on `self` being
- # acquisition-wrapped.
- def exits(self):
+ def getExits(self):
exits = {}
exits["parent"] = ParentExit("parent", self)
return exits
- exits = ComputedAttribute(exits, 1)
class ParentWorkItem(BaseAutomaticWorkItem):
Modified: AlphaFlow/trunk/activities/recursion.py
==============================================================================
--- AlphaFlow/trunk/activities/recursion.py (original)
+++ AlphaFlow/trunk/activities/recursion.py Thu Mar 15 10:26:16 2007
(at)(at) -61,8 +61,7 (at)(at)
'mode':'w', 'select_variable':'listActivityIds'}
)
- (at)property
- def exits(self):
+ def getExits(self):
exits = {}
exits['recursion'] = Exit("recursion", self.recursion_activity)
exits['continuation'] = Exit("continuation", self.continue_activity)
Modified: AlphaFlow/trunk/activities/routing.py
==============================================================================
--- AlphaFlow/trunk/activities/routing.py (original)
+++ AlphaFlow/trunk/activities/routing.py Thu Mar 15 10:26:16 2007
(at)(at) -57,8 +57,7 (at)(at)
'select_variable': 'listActivityIds'},
)
- (at)property
- def exits(self):
+ def getExits(self):
exits = {}
exits["routes"] = Exit("routes", self.routes)
return exits
Modified: AlphaFlow/trunk/activities/simpledecision.py
==============================================================================
--- AlphaFlow/trunk/activities/simpledecision.py (original)
+++ AlphaFlow/trunk/activities/simpledecision.py Thu Mar 15 10:26:16 2007
(at)(at) -67,8 +67,7 (at)(at)
format='checkbox',
)
- (at)property
- def exits(self):
+ def getExits(self):
exits = {}
exits['accept'] = Exit("accept", self.accept_activity)
exits['reject'] = Exit("reject", self.reject_activity)
Modified: AlphaFlow/trunk/activities/switch.py
==============================================================================
--- AlphaFlow/trunk/activities/switch.py (original)
+++ AlphaFlow/trunk/activities/switch.py Thu Mar 15 10:26:16 2007
(at)(at) -56,8 +56,7 (at)(at)
exportHandler="_attr_export_as_childnodes"),
)
- (at)property
- def exits(self):
+ def getExits(self):
exits = {}
exits.update((exit.id, exit) for exit in self.cases)
return exits
Modified: AlphaFlow/trunk/activities/task.py
==============================================================================
--- AlphaFlow/trunk/activities/task.py (original)
+++ AlphaFlow/trunk/activities/task.py Thu Mar 15 10:26:16 2007
(at)(at) -51,8 +51,7 (at)(at)
'select_variable': 'listActivityIds'},
)
- (at)property
- def exits(self):
+ def getExits(self):
exits = {}
exits["completion"] = Exit("completion", self.completion_activity)
return exits
Modified: AlphaFlow/trunk/activity.py
==============================================================================
--- AlphaFlow/trunk/activity.py (original)
+++ AlphaFlow/trunk/activity.py Thu Mar 15 10:26:16 2007
(at)(at) -113,7 +113,7 (at)(at)
"""Return a list of all ids of activities that can be instantiated as
successors by instances of this activity."""
possible_children = set()
- for exit in self.exits.values():
+ for exit in self.getExits().values():
possible_children.update(exit.activities)
return possible_children
(at)(at) -122,7 +122,7 (at)(at)
def graphGetPossibleChildren(self):
"Return a list of possible successor activities as dictionaries."
possible_children = []
- for exit in self.exits.values():
+ for exit in self.getExits().values():
possible_children.extend({'id': activity,
'exit': exit.id,
'label': exit.id,
(at)(at) -175,9 +175,7 (at)(at)
'mode': 'w', 'select_variable': 'listActivityIds'},
)
-
- (at)property
- def exits(self):
+ def getExits(self):
exits = {}
exits['continuation'] = Exit('continuation', self.continue_activity)
return exits
|
SVN: r4577 - in AlphaFlow/trunk: . activities
Thomas Lotze <tl(at)gocept.com> |
2007-03-15 11:58:22 |
[ FULL ]
|
Author: thomas
Date: Thu Mar 15 11:58:17 2007
New Revision: 4577
Log:
added passCheckPoint
Added:
AlphaFlow/trunk/activities/configure.zcml (contents, props changed)
Modified:
AlphaFlow/trunk/activities/alarm.py
AlphaFlow/trunk/activities/configuration.py
AlphaFlow/trunk/activities/decision.py
AlphaFlow/trunk/activities/gates.py
AlphaFlow/trunk/activities/interfaces.py
AlphaFlow/trunk/activities/notify.py
AlphaFlow/trunk/activities/ntask.py
AlphaFlow/trunk/activities/parent.py
AlphaFlow/trunk/activities/recursion.py
AlphaFlow/trunk/activities/simpledecision.py
AlphaFlow/trunk/activities/switch.py
AlphaFlow/trunk/activities/task.py
AlphaFlow/trunk/activity.py
AlphaFlow/trunk/configure.zcml
AlphaFlow/trunk/instance.py
AlphaFlow/trunk/interfaces.py
AlphaFlow/trunk/registry.py
AlphaFlow/trunk/workitem.py
Modified: AlphaFlow/trunk/activities/alarm.py
==============================================================================
--- AlphaFlow/trunk/activities/alarm.py (original)
+++ AlphaFlow/trunk/activities/alarm.py Thu Mar 15 11:58:17 2007
(at)(at) -48,7 +48,7 (at)(at)
activity = self.getActivity()
deadline = utils.evaluateTales(self, activity.due)
if deadline.isPast():
- self.createWorkItems(activity.continue_activity)
+ self.passCheckPoint("continue")
self.changeState("complete", activity.title_or_id())
security.declareProtected(config.WORK_WITH_PROCESS, 'getStatusInfo')
Modified: AlphaFlow/trunk/activities/configuration.py
==============================================================================
--- AlphaFlow/trunk/activities/configuration.py (original)
+++ AlphaFlow/trunk/activities/configuration.py Thu Mar 15 11:58:17 2007
(at)(at) -53,7 +53,7 (at)(at)
def getExits(self):
exits = {}
- exits['completion'] = Exit("completion", self.continue_activity)
+ exits['complete'] = Exit("complete", self.continue_activity)
return exits
#########
(at)(at) -148,8 +148,7 (at)(at)
"""Do the configuration of the other activities."""
if self.state != "active":
raise ValueError, "Can't configure when not active."
- act = self.getActivity()
- self.createWorkItems(act.continue_activity)
+ self.passCheckPoint("complete")
self.changeState("complete", self.getComment())
self.notifyAssigneesChange()
self._update_ui_after_action('Configuration complete.', REQUEST)
Added: AlphaFlow/trunk/activities/configure.zcml
==============================================================================
--- (empty file)
+++ AlphaFlow/trunk/activities/configure.zcml Thu Mar 15 11:58:17 2007
(at)(at) -0,0 +1,8 (at)(at)
+<configure
+ xmlns="http://namespaces.zope.org/zope"
+ i18n_domain="alphaflow">
+
+ <adapter factory=".simpledecision.WorkItemFactory" />
+ <adapter factory=".parent.ParentWorkItemExit" />
+
+</configure>
Modified: AlphaFlow/trunk/activities/decision.py
==============================================================================
--- AlphaFlow/trunk/activities/decision.py (original)
+++ AlphaFlow/trunk/activities/decision.py Thu Mar 15 11:58:17 2007
(at)(at) -135,8 +135,7 (at)(at)
"""Reject"""
if self.state != "active":
raise ValueError, "Can't reject when not active."
- act = self.getActivity()
- self.createWorkItems(act.reject_activity)
+ self.passCheckPoint("reject")
self._register_decision(False)
self.changeState("complete", "rejected")
self.notifyAssigneesChange()
(at)(at) -199,8 +198,7 (at)(at)
'_is_accepted_' + self.getActivity().decision_modus)()
if not acc:
return
- act = self.getActivity()
- self.createWorkItems(act.accept_activity)
+ self.passCheckPoint("accept")
self.changeState("complete", "all necessary assignees accepted")
Modified: AlphaFlow/trunk/activities/gates.py
==============================================================================
--- AlphaFlow/trunk/activities/gates.py (original)
+++ AlphaFlow/trunk/activities/gates.py Thu Mar 15 11:58:17 2007
(at)(at) -154,7 +154,7 (at)(at)
security.declarePrivate('_doTrigger')
def _doTrigger(self, triggering_workitem, route):
- self.createWorkItems(self.getActivity().continue_activity)
+ self.passCheckPoint("continue")
self.recordAction("Gate triggered",
"Route '%s' triggered '%s-gate' by workitem '%s'" %
(route, self.getActivity().mode, triggering_workitem.getId()))
Modified: AlphaFlow/trunk/activities/interfaces.py
==============================================================================
--- AlphaFlow/trunk/activities/interfaces.py (original)
+++ AlphaFlow/trunk/activities/interfaces.py Thu Mar 15 11:58:17 2007
(at)(at) -107,13 +107,16 (at)(at)
decision_notice = zope.interface.Attribute(
"Describes what the user(s) have to decide about.")
-class IDecisionActivity(ISimpleDecisionActivity):
+class IDecisionActivity(IAssignableActivity):
"""Decide to accept or reject.
First 'no' counts as result 'no'.
decision_modus says how many 'yes' are needed for a 'yes' result.
"""
+ decision_notice = zope.interface.Attribute(
+ "Describes what the user(s) have to decide about.")
+
decision_modus = zope.interface.Attribute("One of 'first_yes' or
'all_yes'.")
class IDecisionWorkItem(IAssignableWorkItem):
Modified: AlphaFlow/trunk/activities/notify.py
==============================================================================
--- AlphaFlow/trunk/activities/notify.py (original)
+++ AlphaFlow/trunk/activities/notify.py Thu Mar 15 11:58:17 2007
(at)(at) -123,7 +123,7 (at)(at)
activity = self.getActivity()
instance = self.getInstance()
recipient_modes = activity.getRecipientModes()
- work_items = self.createWorkItems(activity.continue_activity)
+ work_items = self.passCheckPoint("continue")
work_items = [instance[work_item] for work_item in work_items] or
[self]
template = portal[activity.template]
Modified: AlphaFlow/trunk/activities/ntask.py
==============================================================================
--- AlphaFlow/trunk/activities/ntask.py (original)
+++ AlphaFlow/trunk/activities/ntask.py Thu Mar 15 11:58:17 2007
(at)(at) -93,18 +93,10 (at)(at)
if self.state != "active":
raise ValueError, "Can't complete a task that isn't active."
- created = False
- for exit_ in self.getActivity().getExits().values():
- if exit_.id == exit:
- self.createWorkItems(exit_.activities)
- created=True
-
- if created:
- self.changeState("complete", "No comment")
- self.notifyAssigneesChange()
- self._update_ui_after_action("Work item completed.", REQUEST)
- else:
- self.changeState("fallout", "Could not find exit: %s" % exit)
+ self.passCheckPoint(exit)
+ self.changeState("complete", "No comment")
+ self.notifyAssigneesChange()
+ self._update_ui_after_action("Work item completed.", REQUEST)
security.declareProtected(config.WORK_WITH_PROCESS, 'getShortInfo')
def getShortInfo(self):
Modified: AlphaFlow/trunk/activities/parent.py
==============================================================================
--- AlphaFlow/trunk/activities/parent.py (original)
+++ AlphaFlow/trunk/activities/parent.py Thu Mar 15 11:58:17 2007
(at)(at) -9,14 +9,16 (at)(at)
workflow can continue exactly where the error occoured in the first place.
"""
-import zope.interface
+import zope.interface
+import zope.component
from AccessControl import ClassSecurityInfo
from ComputedAttribute import ComputedAttribute
from Products.AlphaFlow.workitem import registerWorkItem,
BaseAutomaticWorkItem
from Products.AlphaFlow.activity import \
Exit, registerActivity, BaseAutomaticActivity
-from Products.AlphaFlow.interfaces import IParentActivity, IParentWorkItem
+from Products.AlphaFlow.interfaces import \
+ IParentActivity, IParentWorkItem, IWorkItemExit
from Products.AlphaFlow import config
from Products.AlphaFlow.workflowattr import WorkflowAttribute
(at)(at) -29,7 +31,7 (at)(at)
self._activity = activity
def __get_activities(self):
- process = self._activity.acquireProcess()
+ process = self._activity.__parent__
parent_name = self._activity.parentOf
self_id = self._activity.getId()
(at)(at) -71,6 +73,41 (at)(at)
return exits
+class ParentWorkItemExit(object):
+
+ zope.component.adapts(IParentWorkItem, ParentExit)
+ zope.interface.implements(IWorkItemExit)
+
+ def __init__(self, workitem, exit):
+ self.workitem = workitem
+ self.exit = exit
+ self.id = exit.id
+ self.title = exit.title
+
+ (at)property
+ def activities(self):
+ my_activity = self.workitem.getActivity()
+ parent_name = my_activity.parentOf
+
+ parent = self.workitem
+ while parent.activity_id != parent_name:
+ parent = parent.getParent()
+ if parent is None:
+ break
+
+ if parent is None:
+ raise AlphaFlowException(
+ 'Could not find %r activity within parents' % parent_name)
+
+ continue_with = parent.getParent()
+ if continue_with is None:
+ raise AlphaFlowException(
+ 'Activity %r does not have a parent' % parent)
+
+ activity_id = continue_with.getActivity().getId()
+ return [activity_id]
+
+
class ParentWorkItem(BaseAutomaticWorkItem):
zope.interface.implements(IParentWorkItem)
(at)(at) -86,28 +123,8 (at)(at)
def onStart(self):
"Trigger that gets called after the workitem has been started."
my_activity = self.getActivity()
- parent_name = my_activity.parentOf
-
- parent = self
- while parent.activity_id != parent_name:
- parent = parent.getParent()
- if parent is None:
- break
-
- if parent is None:
- self.changeState(
- 'fallout',
- 'Could not find %r activity within parents' % parent_name)
- else:
- continue_with = parent.getParent()
- if continue_with is None:
- self.changeState(
- 'fallout',
- 'Activity %r does not have a parent' % parent)
- else:
- activity_id = continue_with.getActivity().getId()
- self.createWorkItems([activity_id])
- self.changeState('complete', my_activity.title_or_id())
+ self.passCheckPoint("parent")
+ self.changeState('complete', my_activity.title_or_id())
# register the stuff
Modified: AlphaFlow/trunk/activities/recursion.py
==============================================================================
--- AlphaFlow/trunk/activities/recursion.py (original)
+++ AlphaFlow/trunk/activities/recursion.py Thu Mar 15 11:58:17 2007
(at)(at) -64,7 +64,7 (at)(at)
def getExits(self):
exits = {}
exits['recursion'] = Exit("recursion", self.recursion_activity)
- exits['continuation'] = Exit("continuation", self.continue_activity)
+ exits['continue'] = Exit("continue", self.continue_activity)
return exits
security.declarePrivate("getConfigurationSchema")
Modified: AlphaFlow/trunk/activities/simpledecision.py
==============================================================================
--- AlphaFlow/trunk/activities/simpledecision.py (original)
+++ AlphaFlow/trunk/activities/simpledecision.py Thu Mar 15 11:58:17 2007
(at)(at) -4,13 +4,15 (at)(at)
"""Simple Decision activity and work item."""
import zope.interface
+import zope.interface
+import zope.component
from AccessControl import ClassSecurityInfo
from Products.Archetypes import public as atapi
from Products.CMFCore.utils import getToolByName
from Products.AlphaFlow.interfaces import \
- ISimpleDecisionActivity, IDecisionWorkItem
+ ISimpleDecisionActivity, IDecisionWorkItem, IWorkItemFactory
from Products.AlphaFlow.workitem import BaseAssignableWorkItem,
registerWorkItem
from Products.AlphaFlow.activity import \
Exit, BaseAssignableActivity, registerActivity
(at)(at) -19,6 +21,26 (at)(at)
from Products.AlphaFlow.workflowattr import WorkflowAttribute
+class WorkItemFactory(object):
+
+ zope.component.adapts(ISimpleDecisionActivity)
+ zope.interface.implements(IWorkItemFactory)
+
+ def __init__(self, activity):
+ self.activity = activity
+
+ def __call__(self, source, content_object=None):
+ """Instantiates a SimpleDecisionWorkItem for every assignee."""
+ assignees = self.activity._list_relevant_users(source)
+ wis = []
+ for assignee in assignees:
+ w_id = utils.generateUniqueId('Workitem')
+ wi = SimpleDecisionWorkItem(
+ w_id, self.activity.getId(), content_object, assignee)
+ wis.append(wi)
+ return wis
+
+
class SimpleDecisionActivity(BaseAssignableActivity):
"""Decide to accept or reject.
"""
(at)(at) -42,11 +64,9 (at)(at)
encoding='ascii', datatype=tuple),
)
-
configurationSchema = BaseAssignableActivity.configurationSchema.copy()
# gets modified by __init__!
-
_properties = BaseAssignableActivity._properties + \
({'id': 'decision_notice', 'type': 'text', 'mode': 'w'},
{'id': 'reject_activity', 'type': 'multiple selection',
(at)(at) -55,7 +75,6 (at)(at)
'mode': 'w', 'select_variable': 'listActivityIds'},
)
-
security.declareProtected(config.EDIT_WORKFLOW, '__init__')
def __init__(self, id):
SimpleDecisionActivity.inheritedAttribute('__init__')(self, id)
(at)(at) -85,17 +104,6 (at)(at)
act["color"] = "red"
return activities
- def generateWorkItems(self, source, content_object):
- """Instanciates a SimpleDecisionWorkItem for every assignee."""
- assignees = self._list_relevant_users(source)
- wis = []
- for assignee in assignees:
- w_id = utils.generateUniqueId('Workitem')
- wi = SimpleDecisionWorkItem(w_id, self.getId(), content_object,
assignee)
- wis.append(wi)
-
- return wis
-
def _list_relevant_users(self, source):
#XXX duplicated code from activity.py, refactor!
if self.assigneesKind == 'possible':
(at)(at) -128,7 +136,6 (at)(at)
(self, id, activity_id, content_object)
self.assignee = assignee
-
###########
# IWorkItem
(at)(at) -146,14 +153,11 (at)(at)
self.reject),
]
return actions
-
def listRelevantUsers(self):
"""return the stored assignee"""
return [self.assignee]
-
-
###################
# IDecisionWorkItem
(at)(at) -162,8 +166,7 (at)(at)
"""Reject"""
if self.state != "active":
raise ValueError, "Can't reject when not active."
- act = self.getActivity()
- self.createWorkItems(act.reject_activity)
+ self.passCheckPoint("reject")
self.changeState("complete", "rejected")
self.notifyAssigneesChange()
self._update_ui_after_action('Rejected.', REQUEST)
(at)(at) -173,8 +176,7 (at)(at)
"""Accept"""
if self.state != "active":
raise ValueError, "Can't accept when not active."
- act = self.getActivity()
- self.createWorkItems(act.accept_activity)
+ self.passCheckPoint("accept")
self.changeState("complete", "assignee accepted")
self.notifyAssigneesChange()
self._update_ui_after_action("Review registered.", REQUEST)
Modified: AlphaFlow/trunk/activities/switch.py
==============================================================================
--- AlphaFlow/trunk/activities/switch.py (original)
+++ AlphaFlow/trunk/activities/switch.py Thu Mar 15 11:58:17 2007
(at)(at) -78,12 +78,11 (at)(at)
"Trigger that gets called after the workitem has been started."
activity = self.getActivity()
first = activity.mode == "first"
- workitems = []
for case in activity.cases:
try:
if utils.evaluateTales(self, case.condition):
- workitems.extend(case.activities)
+ self.passCheckPoint(case.id)
if first:
break
except:
(at)(at) -94,7 +93,6 (at)(at)
sys.exc_info())
return
- self.createWorkItems(workitems)
self.changeState("complete", activity.title_or_id())
Modified: AlphaFlow/trunk/activities/task.py
==============================================================================
--- AlphaFlow/trunk/activities/task.py (original)
+++ AlphaFlow/trunk/activities/task.py Thu Mar 15 11:58:17 2007
(at)(at) -53,7 +53,7 (at)(at)
def getExits(self):
exits = {}
- exits["completion"] = Exit("completion", self.completion_activity)
+ exits["complete"] = Exit("complete", self.completion_activity)
return exits
(at)(at) -88,7 +88,7 (at)(at)
raise ValueError, "Can't complete a task that isn't active."
act = self.getActivity()
- self.createWorkItems(act.completion_activity)
+ self.passCheckPoint("complete")
# TODO: put in comment from user here.
self.changeState("complete", "no comment")
Modified: AlphaFlow/trunk/activity.py
==============================================================================
--- AlphaFlow/trunk/activity.py (original)
+++ AlphaFlow/trunk/activity.py Thu Mar 15 11:58:17 2007
(at)(at) -20,7 +20,6 (at)(at)
WorkflowAttribute, InitializeWorkflowAttributes, findAttrInAttributes
from Products.AlphaFlow.importexport import DOMImporter
from Products.AlphaFlow.registry import Registry
-from Products.AlphaFlow.workitem import workitem_registry
class Exit(Persistent, DOMImporter):
(at)(at) -92,6 +91,10 (at)(at)
datatype=str),
)
+ def manage_afterAdd(self, item, container):
+ super(BaseActivity, self).manage_afterAdd(item, container)
+ self.__parent__ = container
+
security.declareProtected(config.MANAGE_WORKFLOW, "acquireActivity")
def acquireActivity(self):
"""returns the activity instance from the acquisition chain"""
(at)(at) -138,14 +141,6 (at)(at)
res.append(process[activity_id].getId())
return res
- def generateWorkItems(self, source, content_object):
- """Instanciates workitems for this activity.
- """
- w_id = utils.generateUniqueId('Workitem')
- wi_class = workitem_registry.get(self.activity_type)
- wi = wi_class(w_id, self.getId(), content_object)
- return [wi]
-
InitializeClass(BaseActivity)
(at)(at) -177,7 +172,7 (at)(at)
def getExits(self):
exits = {}
- exits['continuation'] = Exit('continuation', self.continue_activity)
+ exits['continue'] = Exit('continue', self.continue_activity)
return exits
Modified: AlphaFlow/trunk/configure.zcml
==============================================================================
--- AlphaFlow/trunk/configure.zcml (original)
+++ AlphaFlow/trunk/configure.zcml Thu Mar 15 11:58:17 2007
(at)(at) -13,4 +13,9 (at)(at)
for="Products.CMFPlone.interfaces.IPloneSiteRoot"
/>
+ <adapter factory=".workitem.work_item_exit" />
+ <adapter factory=".workitem.WorkItemFactory" />
+
+ <include package=".activities" />
+
</configure>
Modified: AlphaFlow/trunk/instance.py
==============================================================================
--- AlphaFlow/trunk/instance.py (original)
+++ AlphaFlow/trunk/instance.py Thu Mar 15 11:58:17 2007
(at)(at) -26,7 +26,7 (at)(at)
# Sibling imports
from Products.AlphaFlow.interfaces import \
- IInstance, IAlphaFlowed, IDaemonActivity
+ IInstance, IAlphaFlowed, IDaemonActivity, IWorkItemFactory
from Products.AlphaFlow import config, utils
from Products.AlphaFlow.exception import UnknownActivityError
(at)(at) -629,7 +629,7 (at)(at)
except KeyError:
raise UnknownActivityError, \
"Activity '%s' does not exist." % activity_id
- new.extend(activity.generateWorkItems(source, content_object))
+ new.extend(IWorkItemFactory(activity)(source, content_object))
for wi in new:
wi_id = wi.getId()
Modified: AlphaFlow/trunk/interfaces.py
==============================================================================
--- AlphaFlow/trunk/interfaces.py (original)
+++ AlphaFlow/trunk/interfaces.py Thu Mar 15 11:58:17 2007
(at)(at) -256,12 +256,6 (at)(at)
def acquireActivity():
"""returns the activity instance from the acquisition chain"""
- def generateWorkItems(source, content_object):
- """Instanciates work items for this activity.
-
- Returns list of work items.
- """
-
#######################
# content related stuff
(at)(at) -602,6 +596,33 (at)(at)
to ensure an up-to-date cache.
"""
+ def passCheckPoint(name):
+ """Perform all operations to be done when passing a check point such
+ as the start or an exit of a work item.
+
+ returns list of IDs of work items created
+ """
+
+
+class IWorkItemExit(zope.interface.Interface):
+ """An exit of a work item.
+ """
+
+ id = zope.interface.Attribute("ID")
+
+ title = zope.interface.Attribute("Title")
+
+ activities = zope.interface.Attribute("List of activity IDs")
+
+
+class IWorkItemFactory(zope.interface.Interface):
+ """A factory that creates work items for an activity.
+ """
+
+ def __call__(source, content_object=None):
+ """Create and return work items.
+ """
+
###############################################
# specialized activity and work item interfaces
Modified: AlphaFlow/trunk/registry.py
==============================================================================
--- AlphaFlow/trunk/registry.py (original)
+++ AlphaFlow/trunk/registry.py Thu Mar 15 11:58:17 2007
(at)(at) -3,6 +3,8 (at)(at)
# $Id$
"""Registry for activities etc."""
+import inspect
+
from types import ClassType
import zope.interface
(at)(at) -29,12 +31,11 (at)(at)
else:
return klass.nodeName
- def register(self, klass):
+ def register(self, class_):
"Register a class object on the registry."
- t_klass = type(klass)
- if not (t_klass == ClassType or t_klass == ExtensionClass):
- raise ValueError, "klass must be a classobj not %s." % t_klass
- self._registry[self._compute_key(klass)] = klass
+ if not inspect.isclass(class_):
+ raise ValueError, "Object must be a class, not %s." % class_
+ self._registry[self._compute_key(class_)] = class_
def get(self, key):
"Get class object by key."
Modified: AlphaFlow/trunk/workitem.py
==============================================================================
--- AlphaFlow/trunk/workitem.py (original)
+++ AlphaFlow/trunk/workitem.py Thu Mar 15 11:58:17 2007
(at)(at) -8,6 +8,7 (at)(at)
from warnings import warn
import zope.interface
+import zope.component
from AccessControl import getSecurityManager, ClassSecurityInfo
from Globals import InitializeClass
from DateTime import DateTime
(at)(at) -23,14 +24,40 (at)(at)
DynamicLocalRoleSupport, LocalRoleFakeBase, modifyRolesForPermission,
\
ContentObjectRetrieverBase
from Products.AlphaFlow.interfaces import \
- IWorkItem, IAlphaFlowed, IAutomaticWorkItem, \
- IAssignableActivity, IAssignableWorkItem, IFieldGroup
+ IWorkItemExit, IWorkItem, IWorkItemFactory, \
+ IAlphaFlowed, IAutomaticWorkItem, \
+ IActivity, IAssignableActivity, IAssignableWorkItem, IFieldGroup
from Products.AlphaFlow.registry import Registry
+from Products.AlphaFlow.activity import Exit
+from Products.AlphaFlow.exception import AlphaFlowException
DEBUG_FALLOUT = os.getenv('ALPHAFLOW_RAISE_ON_FALLOUT')
+(at)zope.component.adapter(IWorkItem, Exit)
+(at)zope.interface.implementer(IWorkItemExit)
+def work_item_exit(workitem, exit):
+ return exit
+
+
+class WorkItemFactory(object):
+
+ zope.component.adapts(IActivity)
+ zope.interface.implements(IWorkItemFactory)
+
+ def __init__(self, activity):
+ self.activity = activity
+
+ def __call__(self, source, content_object=None):
+ """Instantiates work items for this activity.
+ """
+ w_id = utils.generateUniqueId('Workitem')
+ wi_class = workitem_registry.get(self.activity.activity_type)
+ wi = wi_class(w_id, self.activity.getId(), content_object)
+ return [wi]
+
+
class WorkItemLocalRoleFake(LocalRoleFakeBase):
"""fakes a dictionary for local role support"""
(at)(at) -417,7 +444,19 (at)(at)
alf = getToolByName(self, 'workflow_manager')
alf.updateCacheByWorkItem(self)
-
+ security.declarePrivate('passCheckPoint')
+ def passCheckPoint(self, name):
+ exit = self.getExits()[name]
+ return self.createWorkItems(exit.activities)
+
+ security.declarePrivate('getExits')
+ def getExits(self):
+ activity = self.getActivity()
+ get_work_item_exit = lambda exit: zope.component.getMultiAdapter(
+ (self, exit), IWorkItemExit)
+ return dict((id, get_work_item_exit(exit))
+ for id, exit in activity.getExits().items())
+
#########################
# IContentObjectRetriever
(at)(at) -594,7 +633,7 (at)(at)
self.getActivity().title_or_id(),
sys.exc_info())
else:
- self.createWorkItems(self.getActivity().continue_activity)
+ self.passCheckPoint("continue")
self.changeState("complete", self.getActivity().title_or_id())
security.declareProtected(config.WORK_WITH_PROCESS, 'getShortInfo')
|
SVN: r4578 - in AlphaFlow/trunk: . activities doc/proposals
Christian Theune <ct(at)gocept.com> |
2007-03-15 14:31:08 |
[ FULL ]
|
Author: ctheune
Date: Thu Mar 15 14:31:05 2007
New Revision: 4578
Log:
- added lifecyclecheckpoints
- turned exits into checkpoints
- fixed some spelling
- clarified aspects/activities a bit more
Modified:
AlphaFlow/trunk/activities/alarm.py
AlphaFlow/trunk/activities/configuration.py
AlphaFlow/trunk/activities/configure.zcml
AlphaFlow/trunk/activities/decision.py
AlphaFlow/trunk/activities/gates.py
AlphaFlow/trunk/activities/notify.py
AlphaFlow/trunk/activities/ntask.py
AlphaFlow/trunk/activities/parent.py
AlphaFlow/trunk/activities/simpledecision.py
AlphaFlow/trunk/activities/switch.py
AlphaFlow/trunk/activities/task.py
AlphaFlow/trunk/config.py
AlphaFlow/trunk/configure.zcml
AlphaFlow/trunk/doc/proposals/ASPECTS.txt
AlphaFlow/trunk/interfaces.py
AlphaFlow/trunk/workitem.py
Modified: AlphaFlow/trunk/activities/alarm.py
==============================================================================
--- AlphaFlow/trunk/activities/alarm.py (original)
+++ AlphaFlow/trunk/activities/alarm.py Thu Mar 15 14:31:05 2007
(at)(at) -48,7 +48,7 (at)(at)
activity = self.getActivity()
deadline = utils.evaluateTales(self, activity.due)
if deadline.isPast():
- self.passCheckPoint("continue")
+ self.passCheckpoint("continue")
self.changeState("complete", activity.title_or_id())
security.declareProtected(config.WORK_WITH_PROCESS, 'getStatusInfo')
Modified: AlphaFlow/trunk/activities/configuration.py
==============================================================================
--- AlphaFlow/trunk/activities/configuration.py (original)
+++ AlphaFlow/trunk/activities/configuration.py Thu Mar 15 14:31:05 2007
(at)(at) -148,7 +148,7 (at)(at)
"""Do the configuration of the other activities."""
if self.state != "active":
raise ValueError, "Can't configure when not active."
- self.passCheckPoint("complete")
+ self.passCheckpoint("complete")
self.changeState("complete", self.getComment())
self.notifyAssigneesChange()
self._update_ui_after_action('Configuration complete.', REQUEST)
Modified: AlphaFlow/trunk/activities/configure.zcml
==============================================================================
--- AlphaFlow/trunk/activities/configure.zcml (original)
+++ AlphaFlow/trunk/activities/configure.zcml Thu Mar 15 14:31:05 2007
(at)(at) -3,6 +3,9 (at)(at)
i18n_domain="alphaflow">
<adapter factory=".simpledecision.WorkItemFactory" />
- <adapter factory=".parent.ParentWorkItemExit" />
+ <adapter
+ factory=".parent.ParentWorkItemExit"
+ provides=".interfaces.IWorkItemExit"
+ />
</configure>
Modified: AlphaFlow/trunk/activities/decision.py
==============================================================================
--- AlphaFlow/trunk/activities/decision.py (original)
+++ AlphaFlow/trunk/activities/decision.py Thu Mar 15 14:31:05 2007
(at)(at) -135,7 +135,7 (at)(at)
"""Reject"""
if self.state != "active":
raise ValueError, "Can't reject when not active."
- self.passCheckPoint("reject")
+ self.passCheckpoint("reject")
self._register_decision(False)
self.changeState("complete", "rejected")
self.notifyAssigneesChange()
(at)(at) -198,7 +198,7 (at)(at)
'_is_accepted_' + self.getActivity().decision_modus)()
if not acc:
return
- self.passCheckPoint("accept")
+ self.passCheckpoint("accept")
self.changeState("complete", "all necessary assignees accepted")
Modified: AlphaFlow/trunk/activities/gates.py
==============================================================================
--- AlphaFlow/trunk/activities/gates.py (original)
+++ AlphaFlow/trunk/activities/gates.py Thu Mar 15 14:31:05 2007
(at)(at) -154,7 +154,7 (at)(at)
security.declarePrivate('_doTrigger')
def _doTrigger(self, triggering_workitem, route):
- self.passCheckPoint("continue")
+ self.passCheckpoint("continue")
self.recordAction("Gate triggered",
"Route '%s' triggered '%s-gate' by workitem '%s'" %
(route, self.getActivity().mode, triggering_workitem.getId()))
Modified: AlphaFlow/trunk/activities/notify.py
==============================================================================
--- AlphaFlow/trunk/activities/notify.py (original)
+++ AlphaFlow/trunk/activities/notify.py Thu Mar 15 14:31:05 2007
(at)(at) -123,7 +123,7 (at)(at)
activity = self.getActivity()
instance = self.getInstance()
recipient_modes = activity.getRecipientModes()
- work_items = self.passCheckPoint("continue")
+ work_items = self.passCheckpoint("continue")
work_items = [instance[work_item] for work_item in work_items] or
[self]
template = portal[activity.template]
Modified: AlphaFlow/trunk/activities/ntask.py
==============================================================================
--- AlphaFlow/trunk/activities/ntask.py (original)
+++ AlphaFlow/trunk/activities/ntask.py Thu Mar 15 14:31:05 2007
(at)(at) -93,7 +93,7 (at)(at)
if self.state != "active":
raise ValueError, "Can't complete a task that isn't active."
- self.passCheckPoint(exit)
+ self.passCheckpoint(exit)
self.changeState("complete", "No comment")
self.notifyAssigneesChange()
self._update_ui_after_action("Work item completed.", REQUEST)
Modified: AlphaFlow/trunk/activities/parent.py
==============================================================================
--- AlphaFlow/trunk/activities/parent.py (original)
+++ AlphaFlow/trunk/activities/parent.py Thu Mar 15 14:31:05 2007
(at)(at) -14,7 +14,8 (at)(at)
from AccessControl import ClassSecurityInfo
from ComputedAttribute import ComputedAttribute
-from Products.AlphaFlow.workitem import registerWorkItem,
BaseAutomaticWorkItem
+from Products.AlphaFlow.workitem import \
+ registerWorkItem, BaseAutomaticWorkItem, WorkItemExit
from Products.AlphaFlow.activity import \
Exit, registerActivity, BaseAutomaticActivity
from Products.AlphaFlow.interfaces import \
(at)(at) -73,7 +74,7 (at)(at)
return exits
-class ParentWorkItemExit(object):
+class ParentWorkItemExit(WorkItemExit):
zope.component.adapts(IParentWorkItem, ParentExit)
zope.interface.implements(IWorkItemExit)
(at)(at) -83,12 +84,12 (at)(at)
self.exit = exit
self.id = exit.id
self.title = exit.title
-
+
(at)property
def activities(self):
my_activity = self.workitem.getActivity()
parent_name = my_activity.parentOf
-
+
parent = self.workitem
while parent.activity_id != parent_name:
parent = parent.getParent()
(at)(at) -123,7 +124,7 (at)(at)
def onStart(self):
"Trigger that gets called after the workitem has been started."
my_activity = self.getActivity()
- self.passCheckPoint("parent")
+ self.passCheckpoint("parent")
self.changeState('complete', my_activity.title_or_id())
Modified: AlphaFlow/trunk/activities/simpledecision.py
==============================================================================
--- AlphaFlow/trunk/activities/simpledecision.py (original)
+++ AlphaFlow/trunk/activities/simpledecision.py Thu Mar 15 14:31:05 2007
(at)(at) -166,7 +166,7 (at)(at)
"""Reject"""
if self.state != "active":
raise ValueError, "Can't reject when not active."
- self.passCheckPoint("reject")
+ self.passCheckpoint("reject")
self.changeState("complete", "rejected")
self.notifyAssigneesChange()
self._update_ui_after_action('Rejected.', REQUEST)
(at)(at) -176,7 +176,7 (at)(at)
"""Accept"""
if self.state != "active":
raise ValueError, "Can't accept when not active."
- self.passCheckPoint("accept")
+ self.passCheckpoint("accept")
self.changeState("complete", "assignee accepted")
self.notifyAssigneesChange()
self._update_ui_after_action("Review registered.", REQUEST)
Modified: AlphaFlow/trunk/activities/switch.py
==============================================================================
--- AlphaFlow/trunk/activities/switch.py (original)
+++ AlphaFlow/trunk/activities/switch.py Thu Mar 15 14:31:05 2007
(at)(at) -82,7 +82,7 (at)(at)
for case in activity.cases:
try:
if utils.evaluateTales(self, case.condition):
- self.passCheckPoint(case.id)
+ self.passCheckpoint(case.id)
if first:
break
except:
Modified: AlphaFlow/trunk/activities/task.py
==============================================================================
--- AlphaFlow/trunk/activities/task.py (original)
+++ AlphaFlow/trunk/activities/task.py Thu Mar 15 14:31:05 2007
(at)(at) -88,7 +88,7 (at)(at)
raise ValueError, "Can't complete a task that isn't active."
act = self.getActivity()
- self.passCheckPoint("complete")
+ self.passCheckpoint("complete")
# TODO: put in comment from user here.
self.changeState("complete", "no comment")
Modified: AlphaFlow/trunk/config.py
==============================================================================
--- AlphaFlow/trunk/config.py (original)
+++ AlphaFlow/trunk/config.py Thu Mar 15 14:31:05 2007
(at)(at) -88,3 +88,5 (at)(at)
mtAllowedRolesAndUsersProxy = 'AllowedRolesAndUsersProxy'
+CHECKPOINT_START = "__checkpoint_start"
+CHECKPOINT_COMPLETE = "__checkpoint_complete"
Modified: AlphaFlow/trunk/configure.zcml
==============================================================================
--- AlphaFlow/trunk/configure.zcml (original)
+++ AlphaFlow/trunk/configure.zcml Thu Mar 15 14:31:05 2007
(at)(at) -13,7 +13,10 (at)(at)
for="Products.CMFPlone.interfaces.IPloneSiteRoot"
/>
- <adapter factory=".workitem.work_item_exit" />
+ <adapter
+ factory=".workitem.WorkItemExit"
+ provides=".interfaces.IWorkItemExit"
+ />
<adapter factory=".workitem.WorkItemFactory" />
<include package=".activities" />
Modified: AlphaFlow/trunk/doc/proposals/ASPECTS.txt
==============================================================================
--- AlphaFlow/trunk/doc/proposals/ASPECTS.txt (original)
+++ AlphaFlow/trunk/doc/proposals/ASPECTS.txt Thu Mar 15 14:31:05 2007
(at)(at) -79,10 +79,12 (at)(at)
decision
alarm
switch
- expression
ntask
- email
configuration
+ route
+
+ expression
+ email
Aspects
(at)(at) -90,7 +92,8 (at)(at)
permission-change
dcworkflow
recursion
- route
+ expression
+ email
Redefining Aspect Activities
Modified: AlphaFlow/trunk/interfaces.py
==============================================================================
--- AlphaFlow/trunk/interfaces.py (original)
+++ AlphaFlow/trunk/interfaces.py Thu Mar 15 14:31:05 2007
(at)(at) -596,15 +596,28 (at)(at)
to ensure an up-to-date cache.
"""
- def passCheckPoint(name):
+ def passCheckpoint(name):
"""Perform all operations to be done when passing a check point such
as the start or an exit of a work item.
returns list of IDs of work items created
"""
+class ICheckpoint(zope.interface.Interface):
+ """A checkpoint.
-class IWorkItemExit(zope.interface.Interface):
+ Checkpoints are executed when a work item starts, completes or triggers an
+ exit.
+ """
+
+ def __call__(self):
+ """Executes all aspects of the checkpoint.
+
+ Returns nothing.
+ """
+
+
+class IWorkItemExit(ICheckpoint):
"""An exit of a work item.
"""
(at)(at) -614,6 +627,11 (at)(at)
activities = zope.interface.Attribute("List of activity IDs")
+ def __call__(self):
+ """Executes all aspects and creates the work items for this exit.
+
+ Returns all generated work item ids.
+ """
class IWorkItemFactory(zope.interface.Interface):
"""A factory that creates work items for an activity.
Modified: AlphaFlow/trunk/workitem.py
==============================================================================
--- AlphaFlow/trunk/workitem.py (original)
+++ AlphaFlow/trunk/workitem.py Thu Mar 15 14:31:05 2007
(at)(at) -25,7 +25,7 (at)(at)
ContentObjectRetrieverBase
from Products.AlphaFlow.interfaces import \
IWorkItemExit, IWorkItem, IWorkItemFactory, \
- IAlphaFlowed, IAutomaticWorkItem, \
+ IAlphaFlowed, IAutomaticWorkItem, ICheckpoint, \
IActivity, IAssignableActivity, IAssignableWorkItem, IFieldGroup
from Products.AlphaFlow.registry import Registry
from Products.AlphaFlow.activity import Exit
(at)(at) -35,10 +35,35 (at)(at)
DEBUG_FALLOUT = os.getenv('ALPHAFLOW_RAISE_ON_FALLOUT')
-(at)zope.component.adapter(IWorkItem, Exit)
-(at)zope.interface.implementer(IWorkItemExit)
-def work_item_exit(workitem, exit):
- return exit
+class LifecycleCheckpoint(object):
+
+ zope.interface.implements(ICheckpoint)
+
+ def __init__(self, workitem, name):
+ self.workitem = workitem
+ self.name = name
+
+ def __call__(self):
+ """Execute aspects."""
+ pass
+
+
+class WorkItemExit(LifecycleCheckpoint):
+
+ zope.component.adapts(IWorkItem, Exit)
+ zope.interface.implements(IWorkItemExit)
+
+ def __init__(self, workitem, exit):
+ self.workitem = workitem
+ self.exit = exit
+
+ self.id = exit.id
+ self.activities = exit.activities
+ self.title = exit.title
+
+ def __call__(self):
+ super(WorkItemExit, self).__call__()
+ return self.workitem.createWorkItems(self.activities)
class WorkItemFactory(object):
(at)(at) -57,7 +82,7 (at)(at)
wi = wi_class(w_id, self.activity.getId(), content_object)
return [wi]
-
+
class WorkItemLocalRoleFake(LocalRoleFakeBase):
"""fakes a dictionary for local role support"""
(at)(at) -444,10 +469,13 (at)(at)
alf = getToolByName(self, 'workflow_manager')
alf.updateCacheByWorkItem(self)
- security.declarePrivate('passCheckPoint')
- def passCheckPoint(self, name):
- exit = self.getExits()[name]
- return self.createWorkItems(exit.activities)
+ security.declarePrivate('passCheckpoint')
+ def passCheckpoint(self, name):
+ if name in [config.CHECKPOINT_START, config.CHECKPOINT_COMPLETE]:
+ checkpoint = LifecycleCheckpoint(self, name)
+ else:
+ checkpoint = self.getExits()[name]
+ return checkpoint()
security.declarePrivate('getExits')
def getExits(self):
(at)(at) -633,7 +661,7 (at)(at)
self.getActivity().title_or_id(),
sys.exc_info())
else:
- self.passCheckPoint("continue")
+ self.passCheckpoint("continue")
self.changeState("complete", self.getActivity().title_or_id())
security.declareProtected(config.WORK_WITH_PROCESS, 'getShortInfo')
(at)(at) -703,8 +731,6 (at)(at)
raise NotImplementedError, 'There are no DOM nodes for workitems'
-
-
####################
# Work item registry
workitem_registry = WorkItemRegistry()
|
SVN: r4579 - in AlphaFlow/trunk: . activities xmlimport
Christian Theune <ct(at)gocept.com> |
2007-03-15 16:12:51 |
[ FULL ]
|
Author: ctheune
Date: Thu Mar 15 16:12:48 2007
New Revision: 4579
Log:
- totally broken checkpoint while rewriting the importer
Added:
AlphaFlow/trunk/xmlimport/
AlphaFlow/trunk/xmlimport/__init__.py (contents, props changed)
AlphaFlow/trunk/xmlimport/importexport.py
- copied, changed from r4577, AlphaFlow/trunk/importexport.py
AlphaFlow/trunk/xmlimport/interfaces_importexport.py
- copied unchanged from r4577, AlphaFlow/trunk/interfaces_importexport.py
AlphaFlow/trunk/xmlimport/workflowattr.py
- copied, changed from r4577, AlphaFlow/trunk/workflowattr.py
Removed:
AlphaFlow/trunk/importexport.py
AlphaFlow/trunk/interfaces_importexport.py
AlphaFlow/trunk/workflowattr.py
Modified:
AlphaFlow/trunk/activities/notify.py
AlphaFlow/trunk/activities/permission.py
AlphaFlow/trunk/activities/switch.py
AlphaFlow/trunk/activity.py
AlphaFlow/trunk/interfaces.py
AlphaFlow/trunk/process.py
AlphaFlow/trunk/workitem.py
Modified: AlphaFlow/trunk/activities/notify.py
==============================================================================
--- AlphaFlow/trunk/activities/notify.py (original)
+++ AlphaFlow/trunk/activities/notify.py Thu Mar 15 16:12:48 2007
(at)(at) -21,9 +21,7 (at)(at)
from Products.AlphaFlow.exception import ConfigurationError
from Products.AlphaFlow.interfaces import \
IEMailActivity, IEMailWorkItem, IEMailRecipientMode
-from Products.AlphaFlow.workflowattr import \
- WorkflowAttribute, InitializeWorkflowAttributes
-from Products.AlphaFlow.importexport import DOMImporter
+from Products.AlphaFlow.workflowattr import WorkflowAttribute
from Products.AlphaFlow.registry import Registry
(at)(at) -189,7 +187,7 (at)(at)
email)
-class AbstractRecipent(Persistent, DOMImporter):
+class AbstractRecipent(Persistent):
"""Abstract recipient class."""
zope.interface.implements(IEMailRecipientMode)
(at)(at) -293,7 +291,3 (at)(at)
# register the stuff
registerActivity(EMailActivity)
registerWorkItem(EMailWorkItem)
-InitializeWorkflowAttributes(RecipientOwner, registry=notify_registry)
-InitializeWorkflowAttributes(RecipientNextAssignees, registry=notify_registry)
-InitializeWorkflowAttributes(RecipientPreviousAssignees,
registry=notify_registry)
-InitializeWorkflowAttributes(RecipientActualRole, registry=notify_registry)
Modified: AlphaFlow/trunk/activities/permission.py
==============================================================================
--- AlphaFlow/trunk/activities/permission.py (original)
+++ AlphaFlow/trunk/activities/permission.py Thu Mar 15 16:12:48 2007
(at)(at) -14,14 +14,12 (at)(at)
from Products.AlphaFlow.activity import registerActivity,
BaseAutomaticActivity
from Products.AlphaFlow.utils import modifyRolesForPermission,
addPermissionsToRoles, removePermissionsFromRoles
from Products.AlphaFlow.workflowattr import \
- WorkflowAttribute, InitializeWorkflowAttributes, \
- workflow_attributes_registry
+ WorkflowAttribute, workflow_attributes_registry
from Products.AlphaFlow.exception import ConfigurationError
from Products.AlphaFlow import config
-from Products.AlphaFlow.importexport import DOMImporter
-class PermissionSetting(DOMImporter):
+class PermissionSetting(object):
zope.interface.implements(IPermissionSetting)
(at)(at) -59,7 +57,6 (at)(at)
modifyRolesForPermission(content, self.permission, self.roles,
acquire=self.acquire)
-InitializeWorkflowAttributes(PermissionSetting)
class PermissionAddSetting(PermissionSetting):
(at)(at) -77,7 +74,6 (at)(at)
"""Apply the permission setting on the content object."""
addPermissionsToRoles(content, self.roles, [self.permission])
-InitializeWorkflowAttributes(PermissionAddSetting)
class PermissionRemoveSetting(PermissionSetting):
(at)(at) -94,7 +90,6 (at)(at)
"""Apply the permission setting on the content object."""
removePermissionsFromRoles(content, self.roles, [self.permission])
-InitializeWorkflowAttributes(PermissionRemoveSetting)
class PermissionActivity(BaseAutomaticActivity):
Modified: AlphaFlow/trunk/activities/switch.py
==============================================================================
--- AlphaFlow/trunk/activities/switch.py (original)
+++ AlphaFlow/trunk/activities/switch.py Thu Mar 15 16:12:48 2007
(at)(at) -21,8 +21,7 (at)(at)
registerActivity, BaseAutomaticActivity
from Products.AlphaFlow.interfaces import ISwitchActivity, ISwitchWorkItem
from Products.AlphaFlow import config, utils
-from Products.AlphaFlow.workflowattr import \
- WorkflowAttribute, InitializeWorkflowAttributes
+from Products.AlphaFlow.workflowattr import WorkflowAttribute
from Products.AlphaFlow.activity import Exit
(at)(at) -96,7 +95,5 (at)(at)
self.changeState("complete", activity.title_or_id())
-# register the stuff
-InitializeWorkflowAttributes(Case)
registerActivity(SwitchActivity)
registerWorkItem(SwitchWorkItem)
Modified: AlphaFlow/trunk/activity.py
==============================================================================
--- AlphaFlow/trunk/activity.py (original)
+++ AlphaFlow/trunk/activity.py Thu Mar 15 16:12:48 2007
(at)(at) -17,12 +17,11 (at)(at)
from Products.AlphaFlow import config, utils
from Products.AlphaFlow.exception import ConfigurationError
from Products.AlphaFlow.workflowattr import \
- WorkflowAttribute, InitializeWorkflowAttributes, findAttrInAttributes
-from Products.AlphaFlow.importexport import DOMImporter
+ WorkflowAttribute, findAttrInAttributes
from Products.AlphaFlow.registry import Registry
-class Exit(Persistent, DOMImporter):
+class Exit(Persistent):
"""A class that (unfortunately) has two meanings:
- represent exits as configured via XML for switches and ntasks
(at)(at) -49,11 +48,7 (at)(at)
self.activities = activities
-# register the stuff
-InitializeWorkflowAttributes(Exit)
-
-
-class BaseActivity(PropertyManager, SimpleItem, DOMImporter):
+class BaseActivity(PropertyManager, SimpleItem):
"""A base class to implement activities"""
zope.interface.implements(IActivity)
(at)(at) -68,8 +63,7 (at)(at)
attributes = (
WorkflowAttribute('id', 'id', None,
'Id of the activity.',
- importHandler=None,
- exportHandler="_attr_export_id"),
+ importHandler=None),
WorkflowAttribute('title', 'title', '',
'Title of the activity.',
encoding="utf-8", datatype=str),
(at)(at) -89,6 +83,7 (at)(at)
'Should the commentfield be hidden or have '
'required input?',
datatype=str),
+
)
def manage_afterAdd(self, item, container):
(at)(at) -203,23 +198,20 (at)(at)
'Defines the user assignment method, either '
'"possible" or "actual".',
required=True, vocabulary=['actual', 'possible'],
- importHandler="_attr_import_assignees",
- exportHandler="_attr_export_assignees"),
+ importHandler="_attr_import_assignees"),
WorkflowAttribute('roles', 'roles', (),
'Roles to compute which members are assignees',
encoding='ascii', datatype=tuple,
- importHandler=None, # done by _attr_import_assignees
- exportHandler=None),
+ importHandler=None), # done by
_attr_import_assignees
WorkflowAttribute('assigneesExpression', 'expression', None,
'Tales Expression returning a list of member ids, '
'may be None.',
- importHandler=None,
- exportHandler=None),
+ importHandler=None),
WorkflowAttribute('completionUrlExpression', 'completion_url_expr',
None,
'(TALES Expression) URL to redirect a user to after
completing the workitem.'
'If empty or unspecified the URL will be determined
the default algorithms.')
)
-
+
configurationSchema = atapi.Schema((
atapi.LinesField("assignees",
vocabulary="getPossibleAssignees",
(at)(at) -244,7 +236,7 (at)(at)
members = self._get_assignees_by_roles()
nice_members = []
-
+
for x in members:
username = x.getUserName()
try:
(at)(at) -276,7 +268,7 (at)(at)
security.declarePrivate('_get_assignees_default')
def _get_assignees_default(self):
return [getSecurityManager().getUser().getUserName()]
-
+
security.declarePrivate('_get_assignees_by_roles')
def _get_assignees_by_roles(self):
content_object = self.getContentObject()
(at)(at) -289,17 +281,6 (at)(at)
members = utils.listMembersWithRoles(role_context, roles)
return members
- security.declarePrivate('_attr_export_assignees')
- def _attr_export_assignees(self, attr, node):
- "Export assignees tag."
- attr_kind = findAttrInAttributes(self, 'assigneesKind')
- attr_roles = findAttrInAttributes(self, 'roles')
- attr_expr = findAttrInAttributes(self, 'assigneesExpression')
- el = node.ownerDocument.createElement('assignees')
- assignees = node.appendChild(el)
- for curr_attr in (attr_kind, attr_roles, attr_expr):
- self._attr_export_simple(curr_attr, assignees)
-
security.declarePrivate('_attr_import_assignees')
def _attr_import_assignees(self, attr, node):
assignees = node.getElementsByTagName('assignees')
(at)(at) -323,7 +304,7 (at)(at)
_import(attr(self, 'assigneesKind'), assignee)
kind = self.assigneesKind
-
+
if has('roles') and has('expression'):
raise ConfigurationError, \
'<assignees> can only have one of roles or
expression.'
(at)(at) -341,11 +322,10 (at)(at)
InitializeClass(BaseAssignableActivity)
-
+
#############################
# Registry for all activities
activity_registry = Registry()
def registerActivity(activity):
InitializeClass(activity)
- InitializeWorkflowAttributes(activity, registry=activity_registry)
Modified: AlphaFlow/trunk/interfaces.py
==============================================================================
--- AlphaFlow/trunk/interfaces.py (original)
+++ AlphaFlow/trunk/interfaces.py Thu Mar 15 16:12:48 2007
(at)(at) -7,9 +7,6 (at)(at)
import zope.interface
-from Products.AlphaFlow.interfaces_importexport import *
-
-
############
# management
(at)(at) -227,6 +224,9 (at)(at)
"An AT schema that can be used to configure a process instance "
"including this activity.")
+ aspects = zope.interface.Attribute(
+ "A dictionary that maps the name of a checkpoint to a list of
aspects.")
+
def getPossibleChildren():
"""Return a list of all ids of activities that can be instantiated as
successors by instances of this activity."""
(at)(at) -603,6 +603,14 (at)(at)
returns list of IDs of work items created
"""
+ def getAspects(checkpoint):
+ """Return all aspects for a checkpoint.
+
+ The checkpoint is given as a name.
+
+ """
+
+
class ICheckpoint(zope.interface.Interface):
"""A checkpoint.
Modified: AlphaFlow/trunk/process.py
==============================================================================
--- AlphaFlow/trunk/process.py (original)
+++ AlphaFlow/trunk/process.py Thu Mar 15 16:12:48 2007
(at)(at) -12,46 +12,22 (at)(at)
from Products.AlphaFlow.interfaces import IProcess
from Products.AlphaFlow import utils, config
from Products.AlphaFlow.activity import activity_registry
-from Products.AlphaFlow.workflowattr import \
- WorkflowAttribute, InitializeWorkflowAttributes
-from Products.AlphaFlow.importexport import DOMImporter
+from Products.AlphaFlow.workflowattr import WorkflowAttribute
from Products.AlphaFlow.exception import UnknownActivityTypeError
+
manage_addProcessForm=PageTemplateFile('www/addProcess', globals())
def manage_addProcess(self, id, REQUEST=None):
self.manage_addProcess(id, REQUEST)
-class Process(Folder, DOMImporter):
+class Process(Folder):
zope.interface.implements(IProcess)
meta_type = "AlphaFlow Process"
security = ClassSecurityInfo()
- nodeName = "workflow"
- attributes = (
- WorkflowAttribute('id', 'id', None,
- 'Id of the workflow definition.',
- encoding='ascii', datatype=str,
- importHandler=None,
- exportHandler='_attr_export_id'),
- WorkflowAttribute('title', 'title', '',
- 'Title of this process definition.',
- encoding='utf-8', datatype=str),
- WorkflowAttribute('startActivity', 'startActivity', (),
- 'List of activity ids to instantiate at start.',
- encoding='ascii', datatype=tuple),
- WorkflowAttribute('description', 'description', '',
- 'Description of this process definition.'),
- WorkflowAttribute('roles', 'onlyAllowRoles', [],
- 'Only members with this roles my start this
workflow.',
- encoding='ascii', datatype=list),
- WorkflowAttribute('object_name', 'object_name', 'object',
- 'Name the content object is bound to in
expressions.',
- encoding='ascii', datatype=str),
- )
-
validation_errors = []
_properties = Folder._properties + (
(at)(at) -124,6 +100,4 (at)(at)
self._setObject(id, activity)
return getattr(self, id)
-
InitializeClass(Process)
-InitializeWorkflowAttributes(Process)
Modified: AlphaFlow/trunk/workitem.py
==============================================================================
--- AlphaFlow/trunk/workitem.py (original)
+++ AlphaFlow/trunk/workitem.py Thu Mar 15 16:12:48 2007
(at)(at) -27,6 +27,7 (at)(at)
IWorkItemExit, IWorkItem, IWorkItemFactory, \
IAlphaFlowed, IAutomaticWorkItem, ICheckpoint, \
IActivity, IAssignableActivity, IAssignableWorkItem, IFieldGroup
+from Products.AlphaFlow.aspects.interfaces import IWorkItemAspect
from Products.AlphaFlow.registry import Registry
from Products.AlphaFlow.activity import Exit
from Products.AlphaFlow.exception import AlphaFlowException
(at)(at) -45,7 +46,8 (at)(at)
def __call__(self):
"""Execute aspects."""
- pass
+ for aspect in self.workitem.getAspects(self.name):
+ aspect.execute()
class WorkItemExit(LifecycleCheckpoint):
(at)(at) -477,6 +479,11 (at)(at)
checkpoint = self.getExits()[name]
return checkpoint()
+ def getAspects(self, checkpoint):
+ aspects = self.getActivity().aspects[checkpoint]
+ return [zope.component.getMultiAdapter((self, aspect),
IWorkItemAspect)
+ for aspect in aspects]
+
security.declarePrivate('getExits')
def getExits(self):
activity = self.getActivity()
Added: AlphaFlow/trunk/xmlimport/__init__.py
==============================================================================
--- (empty file)
+++ AlphaFlow/trunk/xmlimport/__init__.py Thu Mar 15 16:12:48 2007
(at)(at) -0,0 +1 (at)(at)
+# Make this a python package
Copied: AlphaFlow/trunk/xmlimport/importexport.py (from r4577,
AlphaFlow/trunk/importexport.py)
==============================================================================
--- AlphaFlow/trunk/importexport.py (original)
+++ AlphaFlow/trunk/xmlimport/importexport.py Thu Mar 15 16:12:48 2007
(at)(at) -15,142 +15,67 (at)(at)
from Products.AlphaFlow.workflowattr import workflow_attributes_registry
-class DOMImporter:
- """Mixin class with capabilities to import attributes from DOM."""
+class XMLImport:
+ """Import AlphaFlow processes from XML."""
- zope.interface.implements(IDOMConfigurable)
+ def __init__(self, process_manager):
+ self.process_manager
- security = ClassSecurityInfo()
-
- context = None
-
- def __init__(self, id, *args, **kw):
- self.id = id
-
- security.declareProtected(config.EDIT_WORKFLOW, "configureFromXML")
- def configureFromXML(self, REQUEST):
- """Saves the properties to the activity."""
- xmlstr = REQUEST.get('xml')
- node = minidom.parseString(xmlstr)
- self.configureFromDOMNode(node.documentElement)
-
- security.declareProtected(config.MANAGE_WORKFLOW, 'configureFromDOMNode')
- def configureFromDOMNode(self, node):
- "Configures the object from the given DOM node."
- for attr in self.attributes:
- if attr.importHandler is None:
- continue
- importHandler = getattr(self, attr.importHandler)
- importHandler(attr, node)
-
- security.declareProtected(config.MANAGE_WORKFLOW,
- 'createAndConfigureChildNodes')
- def createAndConfigureChildNodes(self, node, registry):
- "Configure all child nodes of node."
- created = []
- for obj_node in node.childNodes:
- if obj_node.nodeType in (obj_node.TEXT_NODE,
- obj_node.COMMENT_NODE):
- # Ignore textnodes, whitespace ...
- continue
- obj_type = obj_node.nodeName
- if obj_node.nodeType != obj_node.ELEMENT_NODE:
- raise ConfigurationError, "Invalid node type %r (%r)" % (
- obj_node.nodeType, obj_type)
- obj_id = obj_node.getAttribute('id').encode('ascii')
- try:
- klass = registry.getFromDOMNode(obj_node)
- except KeyError:
- # we are ignoring tags we don't know
- continue
- obj = klass(obj_id)
- # some validation methods need context, so give it now temporary
- if hasattr(obj, '__of__'):
- obj_wrapped = obj.__of__(self)
- else:
- obj_wrapped = obj
- obj_wrapped.configureFromDOMNode(obj_node)
- created.append(obj)
- return created
-
-
- ########################
- # public import handlers
-
- security.declarePrivate('_attr_import_simple')
- def _attr_import_simple(self, attr, node):
- "Import for attributes which need no special handling."
- dom_attr = attr.domAttr
- node_name = node.nodeName
- datatype = attr.datatype
- value = ''
- if node.hasAttribute(dom_attr):
- value = node.getAttribute(dom_attr)
- if attr.required and value == '': # req but not set
- raise ConfigurationError, \
- "%s requires attribute %s!" % (node_name, dom_attr)
- if attr.encoding is not None:
- value = value.encode(attr.encoding)
- if datatype in [list, tuple]:
- value = datatype(utils.flexSplit(value))
- if not len(value):
- value = attr.default
- elif datatype == bool:
- if value == '': # not set and not required
- value = attr.default
- else:
- try:
- value = utils.makeBoolFromUnicode(value)
- except ValueError:
- import sys
- raise ConfigurationError, str(sys.exc_info()[1])
- else:
- # do not try to convert strings or empty values
- if not (isinstance(datatype, basestring) or value == ''):
- try:
- value = datatype(value)
- except ValueError:
- raise ConfigurationError, \
- "%s.%s must be of %s" % (node_name, dom_attr,
- datatype)
- if value == '': # no attribute or empty value
- value = attr.default
- if attr.vocabulary is not None and value not in attr.vocabulary:
- raise ConfigurationError, \
- "%s.%s must be one of %s" % (node_name, dom_attr,
- attr.vocabulary)
- setattr(self, attr.classAttr, value)
-
- security.declarePrivate('_attr_import_from_all_childnodes')
- def _attr_import_from_all_childnodes(self, attr, node):
- "Import all child nodes as elements of one list attribute."
- elements = self.createAndConfigureChildNodes(
- node, workflow_attributes_registry)
- element_ids = [x.id for x in elements]
- while element_ids:
- element_id = element_ids.pop()
- if element_id in element_ids:
- raise ConfigurationError, \
- "Multiple element id: %s" % element_id
- setattr(self, attr.classAttr, attr.datatype(elements))
-
-
-InitializeClass(DOMImporter)
-
-
-###################
-# helper methods
-
-def convert_to_xml(value):
- """Convert a value to XML notation."""
- if isinstance(value, basestring):
- return value
- elif isinstance(value, tuple) or isinstance(value, list):
- return ' '.join(value)
- elif isinstance(value, bool):
- return value and 'true' or 'false'
- elif isinstance(value, int):
- return str(value)
- elif value is None:
- return ''
- raise ValueError, "Don't know how to handle '%s'." % value
+ def import_xml(self, xml):
+ """Parse given XML and import the process."""
+ dom = minidom.parseString(xml)
+ process_importer = zope.component.getUtility(
+ IDOMImporter, name=dom.documentElement.nodeName)
+ process = process_importer(dom.documentElement)
+ self.process_manager[process.getId()] = process
+
+
+class ProcessImporter(object):
+
+ attributes = (
+ WorkflowAttribute('id', 'id', None,
+ 'Id of the workflow definition.',
+ encoding='ascii', datatype=str,
+ importHandler=None)
+ WorkflowAttribute('title', 'title', '',
+ 'Title of this process definition.',
+ encoding='utf-8', datatype=str),
+ WorkflowAttribute('startActivity', 'startActivity', (),
+ 'List of activity ids to instantiate at start.',
+ encoding='ascii', datatype=tuple),
+ WorkflowAttribute('description', 'description', '',
+ 'Description of this process definition.'),
+ WorkflowAttribute('roles', 'onlyAllowRoles', [],
+ 'Only members with this roles my start this
workflow.',
+ encoding='ascii', datatype=list),
+ WorkflowAttribute('object_name', 'object_name', 'object',
+ 'Name the content object is bound to in
expressions.',
+ encoding='ascii', datatype=str),
+ )
+
+ def __call__(self, process_node):
+ process = Process()
+
+ # Configure the process' simple attributes
+ configure_attributes(process, process_node, self.attributes)
+
+ # Import all activities
+ for node in get_element_children(process_node):
+ activity_importer = zope.component.getUtility(
+ IDOMImporter, name=node.nodeName)
+ activity = activity_importer(node)
+ process[activity.getId()] = activity
+
+ return process
+
+# Import helper functions
+
+def configure_attributes(node, obj, schema):
+ "Configure attributes on this obj as given by the schema"
+ for attr in schema:
+ attr.apply(node, obj)
+
+def get_element_children(dom_node):
+ for node in dom_node.childNodes:
+ if obj_node.nodeType == obj_node.ELEMENT_NODE:
+ yield node
Copied: AlphaFlow/trunk/xmlimport/workflowattr.py (from r4577,
AlphaFlow/trunk/workflowattr.py)
==============================================================================
--- AlphaFlow/trunk/workflowattr.py (original)
+++ AlphaFlow/trunk/xmlimport/workflowattr.py Thu Mar 15 16:12:48 2007
(at)(at) -9,10 +9,10 (at)(at)
from Products.AlphaFlow.registry import Registry
-class WorkflowAttribute:
+class WorkflowAttribute(object):
"""Attribute on objects in workflow (activity, process, ...)
- data used for import and export
+ data used for import
"""
zope.interface.implements(IWorkflowAttribute)
(at)(at) -25,14 +25,11 (at)(at)
encoding = None
datatype = unicode
vocabulary = None
- importHandler = "_attr_import_simple"
- exportHandler = "_attr_export_simple"
def __init__(self, classAttr, domAttr, default, description,
required=False, encoding=None, datatype=unicode,
- vocabulary=None,
- importHandler="_attr_import_simple",
- exportHandler="_attr_export_simple"):
+ vocabulary=None):
+
if not isinstance(classAttr, str):
raise ValueError, "classAttr must be a string."
self.classAttr = classAttr
(at)(at) -58,40 +55,76 (at)(at)
vocabulary is None):
raise ValueError, "vocabulary must be a list or None."
self.vocabulary = vocabulary
- if not (isinstance(importHandler, str) or importHandler is None):
- raise ValueError, "importHandler must be a string or None."
- self.importHandler = importHandler
- if not (isinstance(exportHandler, str) or exportHandler is None):
- raise ValueError, "exportHandler must be a string or None."
- self.exportHandler = exportHandler
def __repr__(self):
return "WorkflowAttribute(%s, %s, %s)" % (self.classAttr,
self.domAttr,
self.default)
+ def apply(self, node, obj):
+ "Import this attribute from the given node to the object."
+ value = ''
+ if node.hasAttribute(self.domAttr):
+ value = node.getAttribute(self.domAttr)
+ if self.required and value == '': # req but not set
+ raise ConfigurationError, \
+ "%s requires attribute %s!" % (node.nodeName, self.domAttr)
+ if self.encoding is not None:
+ value = value.encode(self.encoding)
+ if self.datatype in [list, tuple]:
+ value = self.datatype(utils.flexSplit(value))
+ if not len(value):
+ value = self.default
+ elif self.datatype == bool:
+ if value == '': # not set and not required
+ value = self.default
+ else:
+ try:
+ value = utils.makeBoolFromUnicode(value)
+ except ValueError:
+ import sys
+ raise ConfigurationError, str(sys.exc_info()[1])
+ else:
+ # do not try to convert strings or empty values
+ if not (isinstance(self.datatype, basestring) or value == ''):
+ try:
+ value = self.datatype(value)
+ except ValueError:
+ raise ConfigurationError, \
+ "%s.%s must be of %s" % (node.nodeName,
self.domAttr,
+ self.datatype)
+ if value == '':
+ # no attribute or empty value
+ value = self.default
+ if self.vocabulary is not None and value not in self.vocabulary:
+ raise ConfigurationError, \
+ "%s.%s must be one of %s" % (node.nodeName, self.domAttr,
+ self.vocabulary)
+
+class WorkflowAttributeList(WorkflowAttribute):
+
+
+ def apply(self, node, obj):
+ "Import all child nodes as elements of one list attribute."
+ elements = []
+ for node in get_element_children(node):
+ element_importer = zope.component.getUtility(
+ IDOMImporter, name=node.nodeName)
+ element = element_importer(node)
+ elements.append(element)
+
+ # XXX optimization?
+ element_ids = [x.id for x in elements]
+ while element_ids:
+ element_id = element_ids.pop()
+ if element_id in element_ids:
+ raise ConfigurationError, \
+ "Multiple element id: %s" % element_id
+ setattr(obj, self.classAttr, self.datatype(elements))
+
+
def findAttrInAttributes(klass, classAttr):
"""Find classAttr in WorkflowAttributes of klass."""
for attr in klass.attributes:
if attr.classAttr == classAttr:
return attr
-
-
-#######################################################################
-# Registry for classes having WorkflowAttributes which are not in other
-# registries.
-workflow_attributes_registry = Registry()
-
-def InitializeWorkflowAttributes(klass,
registry=workflow_attributes_registry):
- """Write the WorkflowAttribute on the class object klass.
-
- registry: registry object (IRegistry) to register within
- None means: do not register class
-
- """
- for attribute in klass.attributes:
- setattr(klass, attribute.classAttr, attribute.default)
- if registry is not None:
- registry.register(klass)
-
-
|
SVN: r4580 - in AlphaFlow/trunk: . activities xmlimport
Christian Theune <ct(at)gocept.com> |
2007-03-15 16:48:31 |
[ FULL ]
|
Author: ctheune
Date: Thu Mar 15 16:48:27 2007
New Revision: 4580
Log:
- another snapshot while rewriting the import
Added:
AlphaFlow/trunk/xmlimport/domimporters.py (contents, props changed)
AlphaFlow/trunk/xmlimport/interfaces.py
- copied, changed from r4579,
AlphaFlow/trunk/xmlimport/interfaces_importexport.py
Removed:
AlphaFlow/trunk/xmlimport/interfaces_importexport.py
Modified:
AlphaFlow/trunk/action.py
AlphaFlow/trunk/activities/alarm.py
AlphaFlow/trunk/activities/configuration.py
AlphaFlow/trunk/activities/dcworkflow.py
AlphaFlow/trunk/activities/decision.py
AlphaFlow/trunk/activities/expression.py
AlphaFlow/trunk/activities/gates.py
AlphaFlow/trunk/activities/interfaces.py
AlphaFlow/trunk/activities/notify.py
AlphaFlow/trunk/activity.py
AlphaFlow/trunk/interfaces.py
AlphaFlow/trunk/process.py
AlphaFlow/trunk/xmlimport/importexport.py
AlphaFlow/trunk/xmlimport/workflowattr.py
Modified: AlphaFlow/trunk/action.py
==============================================================================
--- AlphaFlow/trunk/action.py (original)
+++ AlphaFlow/trunk/action.py Thu Mar 15 16:48:27 2007
(at)(at) -5,7 +5,7 (at)(at)
"""Action class
"""
-import zope.interface
+import zope.interface
from Products.AlphaFlow.interfaces import IAction
Modified: AlphaFlow/trunk/activities/alarm.py
==============================================================================
--- AlphaFlow/trunk/activities/alarm.py (original)
+++ AlphaFlow/trunk/activities/alarm.py Thu Mar 15 16:48:27 2007
(at)(at) -19,15 +19,9 (at)(at)
zope.interface.implements(IAlarmActivity)
meta_type = "AlphaFlow Alarm Activity"
- activity_type = nodeName = "alarm"
+ activity_type = "alarm"
icon = "misc_/AlphaFlow/alarm"
- attributes = BaseAutomaticActivity.attributes + (
- WorkflowAttribute('due', 'due', '',
- 'TALES expression that determines the date when '
- 'this alarm is due.',
- required=True),)
-
class AlarmWorkItem(BaseAutomaticWorkItem):
Modified: AlphaFlow/trunk/activities/configuration.py
==============================================================================
--- AlphaFlow/trunk/activities/configuration.py (original)
+++ AlphaFlow/trunk/activities/configuration.py Thu Mar 15 16:48:27 2007
(at)(at) -18,7 +18,7 (at)(at)
from Products.AlphaFlow.workflowattr import WorkflowAttribute
from Products.AlphaFlow.importexport import convert_to_xml
-
+
class ConfigurationActivity(BaseAssignableActivity):
zope.interface.implements(IConfigurationActivity)
(at)(at) -26,59 +26,15 (at)(at)
security = ClassSecurityInfo()
meta_type = "AlphaFlow Configuration Activity"
- activity_type = nodeName = "configuration"
+ activity_type = "configuration"
icon = "misc_/AlphaFlow/configuration"
- attributes = BaseAssignableActivity.attributes + (
- # viewUrlExpression overwrites existing viewUrlExpression
- WorkflowAttribute('viewUrlExpression', 'view_url_expr',
- 'string:${content/absolute_url}/af_edit_workitem?'
- 'workitem=${workitem/getId}&action=configure',
- '(TALES expression) URL to "view" a workitem, '
- 'e.g. "Edit document" points to the edit-tab'),
- WorkflowAttribute('continue_activity', 'continue_activity', (),
- 'Activity to start after completion.',
- encoding='ascii', datatype=tuple),
- WorkflowAttribute('', 'configures_all', None,
- 'Set to true to configure all activities.',
- importHandler=None, # done by _attr_*_configure
- exportHandler=None),
- WorkflowAttribute('configures', 'configures', (),
- 'Other activities which are configured by this '
- 'activity or None as marker for all activities.',
- encoding='ascii', datatype=tuple,
- importHandler='_attr_import_configure',
- exportHandler='_attr_export_configure'),
- )
-
def getExits(self):
exits = {}
exits['complete'] = Exit("complete", self.continue_activity)
return exits
- #########
- # private
-
- security.declarePrivate('_attr_export_configure')
- def _attr_export_configure(self, attr, node):
- if self.configures is None: # marker for "all"
- node.setAttribute('configures_all', convert_to_xml(True))
- else:
- self._attr_export_simple(attr, node)
-
- security.declarePrivate('_attr_import_configure')
- def _attr_import_configure(self, attr, node):
- if node.hasAttribute('configures_all'):
- setattr(self, attr.classAttr, None) # None is marker for "all"
- elif node.hasAttribute('configures'):
- self._attr_import_simple(attr, node)
- else:
- raise ConfigurationError, \
- "%r: Attribute configures or configures_all needed." % (
- self.nodeName,)
-
-
class ConfigurationWorkItem(BaseAssignableWorkItem):
zope.interface.implements(IConfigurationWorkItem)
Modified: AlphaFlow/trunk/activities/dcworkflow.py
==============================================================================
--- AlphaFlow/trunk/activities/dcworkflow.py (original)
+++ AlphaFlow/trunk/activities/dcworkflow.py Thu Mar 15 16:48:27 2007
(at)(at) -30,15 +30,9 (at)(at)
zope.interface.implements(IDCWorkFlowActivity)
meta_type = "AlphaFlow DCWorkFlow Activity"
- activity_type = nodeName = "dcworkflow"
+ activity_type = "dcworkflow"
icon = "misc_/AlphaFlow/dcworkflow"
- attributes = BaseAutomaticActivity.attributes + (
- WorkflowAttribute('status', 'status', '',
- 'Status which is set as DCWorkFlow status.',
- required=True, encoding='ascii', datatype=str),
- )
-
_properties = BaseAutomaticActivity._properties + \
({'id': 'status', 'type': 'text', 'mode': 'w'},
)
Modified: AlphaFlow/trunk/activities/decision.py
==============================================================================
--- AlphaFlow/trunk/activities/decision.py (original)
+++ AlphaFlow/trunk/activities/decision.py Thu Mar 15 16:48:27 2007
(at)(at) -29,29 +29,13 (at)(at)
security = ClassSecurityInfo()
meta_type = "AlphaFlow Decision Activity"
- activity_type = nodeName = "decision"
+ activity_type = "decision"
icon = "misc_/AlphaFlow/decision"
known_decision_modi = ['first_yes', 'all_yes']
- attributes = BaseAssignableActivity.attributes + (
- WorkflowAttribute('decision_notice', 'decision_notice', '',
- 'Describing the task for the decision.'),
- WorkflowAttribute('decision_modus', 'decision_modus', '',
- 'One of self.known_decision_modi',
- required=True,
- vocabulary=known_decision_modi),
- WorkflowAttribute('reject_activity', 'reject_activity', (),
- 'Activity if result is "no".',
- encoding='ascii', datatype=tuple),
- WorkflowAttribute('accept_activity', 'accept_activity', (),
- 'Activity if result is "yes".',
- encoding='ascii', datatype=tuple),
- )
-
-
+ # configurationschema gets modified by __init__!
configurationSchema = BaseAssignableActivity.configurationSchema.copy()
- # gets modified by __init__!
_properties = BaseAssignableActivity._properties + \
Modified: AlphaFlow/trunk/activities/expression.py
==============================================================================
--- AlphaFlow/trunk/activities/expression.py (original)
+++ AlphaFlow/trunk/activities/expression.py Thu Mar 15 16:48:27 2007
(at)(at) -19,19 +19,11 (at)(at)
zope.interface.implements(IExpressionActivity)
- attributes = BaseAutomaticActivity.attributes + (
- WorkflowAttribute('expression', 'expression', '',
- 'TALES expression which is to be executed.',
- required=True),
- WorkflowAttribute('runAs', 'runAs', 'alphaflow/systemUser',
- 'TALES expression returning the user to run as.',
- required=False),
- )
meta_type = "AlphaFlow Expression Activity"
- activity_type = nodeName = "expression"
+ activity_type = "expression"
icon = "misc_/AlphaFlow/expression"
-
+
class ExpressionWorkItem(BaseAutomaticWorkItem):
zope.interface.implements(IExpressionWorkItem)
(at)(at) -58,7 +50,7 (at)(at)
'user but %r' % (activity.runAs, run_as))
evaluateTalesAs(self, activity.expression, run_as)
-
+
# register the stuff
registerActivity(ExpressionActivity)
registerWorkItem(ExpressionWorkItem)
Modified: AlphaFlow/trunk/activities/gates.py
==============================================================================
--- AlphaFlow/trunk/activities/gates.py (original)
+++ AlphaFlow/trunk/activities/gates.py Thu Mar 15 16:48:27 2007
(at)(at) -25,7 +25,7 (at)(at)
zope.interface.implements(IDaemonActivity, IGateActivity)
meta_type = "AlphaFlow Gate Activity"
- activity_type = nodeName = "gate"
+ activity_type = "gate"
icon = "misc_/AlphaFlow/gate"
# - Multimerge is like "OR" (trigger on each)
(at)(at) -36,20 +36,12 (at)(at)
mode_types = (MULTI_MERGE, DISCRIMINATE, DELAYED_DISCRIMINATE,
SYNCHRONIZING_MERGE,)
- attributes = BaseAutomaticActivity.attributes + (
- WorkflowAttribute('mode', 'mode', '',
- 'Mode the gate works, values see self.mode_types',
- required=True, encoding='ascii', datatype=str,
- vocabulary=mode_types),
- )
-
_properties = BaseAutomaticActivity._properties + \
({'id': 'mode', 'type': 'selection', 'mode': 'w',
'select_variable': 'mode_types'},
)
-
class GateWorkItem(BaseWorkItem):
security = ClassSecurityInfo()
Modified: AlphaFlow/trunk/activities/interfaces.py
==============================================================================
--- AlphaFlow/trunk/activities/interfaces.py (original)
+++ AlphaFlow/trunk/activities/interfaces.py Thu Mar 15 16:48:27 2007
(at)(at) -12,7 +12,7 (at)(at)
##############
# helper stuff
-class IExit(IWorkflowAttributeAware, IDOMConfigurable):
+class IExit(IWorkflowAttributeAware):
"""Exit for INTaskActivity."""
(at)(at) -20,7 +20,7 (at)(at)
"""Case for ISwitchActivity."""
-class IEMailRecipientMode(IWorkflowAttributeAware, IDOMConfigurable):
+class IEMailRecipientMode(IWorkflowAttributeAware):
"""Configure which users are recipients for an email activity."""
def getRecipientsForWorkItem(workitem):
Modified: AlphaFlow/trunk/activities/notify.py
==============================================================================
--- AlphaFlow/trunk/activities/notify.py (original)
+++ AlphaFlow/trunk/activities/notify.py Thu Mar 15 16:48:27 2007
(at)(at) -25,28 +25,6 (at)(at)
from Products.AlphaFlow.registry import Registry
-class EMailRegistry(Registry):
- """Registry for email recipents."""
-
- def _compute_key(self, klass):
- "Compute the search key from a class object."
- return klass.mode_name
-
- def getFromDOMNode(self, node):
- """Get a class object from data given in DOM-Node.
-
- node.getAttribute('mode_name') is used as key.
- """
- if node.nodeName != AbstractRecipent.nodeName:
- raise KeyError, 'Only recipent modes in this registry'
- return self.get(node.getAttribute('type'))
-
-
-#################################
-# Registry for all recipent modes
-notify_registry = EMailRegistry()
-
-
class EMailActivity(BaseAutomaticActivity):
zope.interface.implements(IEMailActivity)
(at)(at) -54,49 +32,19 (at)(at)
security = ClassSecurityInfo()
meta_type = "AlphaFlow EMail Activity"
- activity_type = nodeName = "email"
+ activity_type = "email"
icon = "misc_/AlphaFlow/email"
- attributes = BaseAutomaticActivity.attributes + (
- WorkflowAttribute('template', 'template', '',
- 'ID of a DTML-Method-Object being available from '
- 'portal root.',
- required=True, encoding='ascii', datatype=str),
- WorkflowAttribute('mailSubject', 'mailSubject',
- 'AlphaFlow notification message',
- 'Static subject line for the mails sent.',
- required=True),
- WorkflowAttribute('recipientModes', '', (),
- 'Who will get the email. (possible values see'
- 'default of mode_name in subclasses of '
- 'AbstractRecipent)',
- required=True, datatype=tuple,
- importHandler="_attr_import_email",
- exportHandler="_attr_export_email"),
- )
-
_properties = BaseAutomaticActivity._properties + \
({'id': 'template', 'type': 'string', 'mode': 'w',},
{'id': 'mailSubject', 'type': 'ustring', 'mode': 'w'},
)
-
security.declarePrivate('getRecipientModes')
def getRecipientModes(self):
"Return list of IEMailRecipientMode instances (possible recipents)."
return self.recipientModes
- #########
- # private
- security.declarePrivate('_attr_import_email')
- def _attr_import_email(self, attr, node):
- global notify_registry
- modes = self.createAndConfigureChildNodes(node, notify_registry)
- if len(modes) == 0:
- raise ConfigurationError, "No recipients specified in %r" % self
- self.recipientModes = attr.datatype(modes)
-
-
class EMailWorkItem(BaseAutomaticWorkItem):
(at)(at) -235,10 +183,10 (at)(at)
if wi.state != 'active':
continue
if wi.activity_type == 'route':
- for user in self.getRecipientsForWorkItem(wi):
- ret[user] = 1
- else:
- for user in wi.listRelevantUsers():
+ for user in self.getRecipientsForWorkItem(wi):
+ ret[user] = 1
+ else:
+ for user in wi.listRelevantUsers():
ret[user] = 1
return ret.keys()
Modified: AlphaFlow/trunk/activity.py
==============================================================================
--- AlphaFlow/trunk/activity.py (original)
+++ AlphaFlow/trunk/activity.py Thu Mar 15 16:48:27 2007
(at)(at) -30,20 +30,7 (at)(at)
zope.interface.implements(IExit)
- nodeName = "exit"
- attributes = (
- WorkflowAttribute('id', 'id', None,
- 'Id of the exit.',
- encoding="ascii", datatype=str),
- WorkflowAttribute('title', 'title', None,
- 'Title of the exit.'),
- WorkflowAttribute('activities', 'activities', (),
- 'Continue activities if this exit gets chosen.',
- encoding='ascii', datatype=tuple),
- )
-
def __init__(self, id, activities=()):
- super(Exit, self).__init__(id)
self.id = self.title = id
self.activities = activities
(at)(at) -55,37 +42,11 (at)(at)
security = ClassSecurityInfo()
- activity_type = nodeName = None
+ activity_type = None
configurationSchema = None
icon = "misc_/AlphaFlow/generic"
commentfield = ""
- attributes = (
- WorkflowAttribute('id', 'id', None,
- 'Id of the activity.',
- importHandler=None),
- WorkflowAttribute('title', 'title', '',
- 'Title of the activity.',
- encoding="utf-8", datatype=str),
- WorkflowAttribute('sortPriority', 'sort', 0,
- 'Lower priority activities will be shown first.',
- datatype=int),
- WorkflowAttribute('nonEditableFields', 'nonEditableFields', (),
- 'Fields in schema which are not to be edited '
- 'aka configured by user of workflow.',
- datatype=tuple),
- WorkflowAttribute('startActivity', 'startActivity', (),
- 'Workitems to be spawned just before the '
- 'workitem for this activity is started.',
- datatype=tuple),
- WorkflowAttribute('commentfield',
- 'commentfield', "",
- 'Should the commentfield be hidden or have '
- 'required input?',
- datatype=str),
-
- )
-
def manage_afterAdd(self, item, container):
super(BaseActivity, self).manage_afterAdd(item, container)
self.__parent__ = container
(at)(at) -152,14 +113,6 (at)(at)
manage_options = (PropertyManager.manage_options + \
SimpleItem.manage_options)
- attributes = BaseActivity.attributes + (
- WorkflowAttribute('continue_activity', 'continue_activity', (),
- 'A list of activities that follow this'
- 'automatic activity. (single exit)',
- encoding='ascii', datatype=tuple),
- )
-
-
_properties = PropertyManager._properties + \
({'id': 'continue_activity', 'type': 'multiple selection',
'mode': 'w', 'select_variable': 'listActivityIds'},
(at)(at) -185,33 +138,6 (at)(at)
{ 'id': 'roles', 'type': 'lines', 'mode': 'w' },
)
- attributes = BaseActivity.attributes + (
- WorkflowAttribute('viewUrlExpression', 'view_url_expr',
- 'string:${content/absolute_url}/view',
- '(TALES expression) URL to "view" a workitem, '
- 'e.g. "Edit document" points to the edit-tab'),
- WorkflowAttribute('contentRoles', 'content_roles', None,
- 'Roles which assigned users get on the '
- 'content object.',
- encoding='ascii', datatype=tuple),
- WorkflowAttribute('assigneesKind', 'kind', 'possible',
- 'Defines the user assignment method, either '
- '"possible" or "actual".',
- required=True, vocabulary=['actual', 'possible'],
- importHandler="_attr_import_assignees"),
- WorkflowAttribute('roles', 'roles', (),
- 'Roles to compute which members are assignees',
- encoding='ascii', datatype=tuple,
- importHandler=None), # done by
_attr_import_assignees
- WorkflowAttribute('assigneesExpression', 'expression', None,
- 'Tales Expression returning a list of member ids, '
- 'may be None.',
- importHandler=None),
- WorkflowAttribute('completionUrlExpression', 'completion_url_expr',
None,
- '(TALES Expression) URL to redirect a user to after
completing the workitem.'
- 'If empty or unspecified the URL will be determined
the default algorithms.')
- )
-
configurationSchema = atapi.Schema((
atapi.LinesField("assignees",
vocabulary="getPossibleAssignees",
Modified: AlphaFlow/trunk/interfaces.py
==============================================================================
--- AlphaFlow/trunk/interfaces.py (original)
+++ AlphaFlow/trunk/interfaces.py Thu Mar 15 16:48:27 2007
(at)(at) -194,7 +194,7 (at)(at)
# process stuff
-class IProcess(IWorkflowAttributeAware, IDOMConfigurable):
+class IProcess(IWorkflowAttributeAware):
"""A process definition."""
id = zope.interface.Attribute("Id of this process definition.")
(at)(at) -214,7 +214,7 (at)(at)
"""returns the process definition from the acquisition chain"""
-class IActivity(IWorkflowAttributeAware, IDOMConfigurable):
+class IActivity(IWorkflowAttributeAware):
"""A workflow activity.
These are the building blocks for process definitions.
Modified: AlphaFlow/trunk/process.py
==============================================================================
--- AlphaFlow/trunk/process.py (original)
+++ AlphaFlow/trunk/process.py Thu Mar 15 16:48:27 2007
(at)(at) -12,7 +12,6 (at)(at)
from Products.AlphaFlow.interfaces import IProcess
from Products.AlphaFlow import utils, config
from Products.AlphaFlow.activity import activity_registry
-from Products.AlphaFlow.workflowattr import WorkflowAttribute
from Products.AlphaFlow.exception import UnknownActivityTypeError
Added: AlphaFlow/trunk/xmlimport/domimporters.py
==============================================================================
--- (empty file)
+++ AlphaFlow/trunk/xmlimport/domimporters.py Thu Mar 15 16:48:27 2007
(at)(at) -0,0 +1,181 (at)(at)
+# Copyright (c) 2007 gocept gmbh & co. kg
+# See also LICENSE.txt
+# $Id$
+"""DOM importers for the built-in workflow objects."""
+
+
+class ExitImporter(object):
+
+ attributes = (
+ WorkflowAttribute('id', 'id', None,
+ 'Id of the exit.',
+ encoding="ascii", datatype=str),
+ WorkflowAttribute('title', 'title', None,
+ 'Title of the exit.'),
+ WorkflowAttribute('activities', 'activities', (),
+ 'Continue activities if this exit gets chosen.',
+ encoding='ascii', datatype=tuple),
+ )
+
+class BaseActivityImporter(object):
+
+ attributes = (
+ WorkflowAttribute('id', 'id', None,
+ 'Id of the activity.',
+ importHandler=None),
+ WorkflowAttribute('title', 'title', '',
+ 'Title of the activity.',
+ encoding="utf-8", datatype=str),
+ WorkflowAttribute('sortPriority', 'sort', 0,
+ 'Lower priority activities will be shown first.',
+ datatype=int),
+ WorkflowAttribute('nonEditableFields', 'nonEditableFields', (),
+ 'Fields in schema which are not to be edited '
+ 'aka configured by user of workflow.',
+ datatype=tuple),
+ WorkflowAttribute('startActivity', 'startActivity', (),
+ 'Workitems to be spawned just before the '
+ 'workitem for this activity is started.',
+ datatype=tuple),
+ WorkflowAttribute('commentfield',
+ 'commentfield', "",
+ 'Should the commentfield be hidden or have '
+ 'required input?',
+ datatype=str),
+
+ )
+
+class BaseAutomaticActivityImporter(BaseActivityImporter):
+
+ attributes = BaseActivityImporter.attributes + (
+ WorkflowAttribute('continue_activity', 'continue_activity', (),
+ 'A list of activities that follow this'
+ 'automatic activity. (single exit)',
+ encoding='ascii', datatype=tuple))
+
+class BaseAssignableActivityImporter(BaseActivityImporter):
+
+
+ attributes = BaseActivityImporter.attributes + (
+ WorkflowAttribute('viewUrlExpression', 'view_url_expr',
+ 'string:${content/absolute_url}/view',
+ '(TALES expression) URL to "view" a workitem, '
+ 'e.g. "Edit document" points to the edit-tab'),
+ WorkflowAttribute('contentRoles', 'content_roles', None,
+ 'Roles which assigned users get on the '
+ 'content object.',
+ encoding='ascii', datatype=tuple),
+ WorkflowAttribute('assigneesKind', 'kind', 'possible',
+ 'Defines the user assignment method, either '
+ '"possible" or "actual".',
+ required=True, vocabulary=['actual', 'possible'],
+ importHandler="_attr_import_assignees"),
+ WorkflowAttribute('roles', 'roles', (),
+ 'Roles to compute which members are assignees',
+ encoding='ascii', datatype=tuple,
+ importHandler=None), # done by
_attr_import_assignees
+ WorkflowAttribute('assigneesExpression', 'expression', None,
+ 'Tales Expression returning a list of member ids, '
+ 'may be None.',
+ importHandler=None),
+ WorkflowAttribute('completionUrlExpression', 'completion_url_expr',
None,
+ '(TALES Expression) URL to redirect a user to after
completing the workitem.'
+ 'If empty or unspecified the URL will be determined
the default algorithms.')
+ )
+
+
+class AlarmImporter(BaseAutomaticActivityImporter):
+
+
+ attributes = BaseAutomaticActivityImporter.attributes + (
+ WorkflowAttribute('due', 'due', '',
+ 'TALES expression that determines the date when '
+ 'this alarm is due.',
+ required=True),)
+
+
+class ConfigurationImporter(BaseAssignableActivityImporter):
+
+ attributes = BaseAssignableActivity.attributes + (
+ # viewUrlExpression overwrites existing viewUrlExpression
+ WorkflowAttribute('viewUrlExpression', 'view_url_expr',
+ 'string:${content/absolute_url}/af_edit_workitem?'
+ 'workitem=${workitem/getId}&action=configure',
+ '(TALES expression) URL to "view" a workitem, '
+ 'e.g. "Edit document" points to the edit-tab'),
+ WorkflowAttribute('continue_activity', 'continue_activity', (),
+ 'Activity to start after completion.',
+ encoding='ascii', datatype=tuple),
+ ConfiguresAttribute('configures', 'configures', (),
+ 'Other activities which are configured by this '
+ 'activity or None as marker for all activities.',
+ encoding='ascii', datatype=tuple),
+ )
+
+
+class DCWorkflowImporter(BaseAutomaticActivityImporter):
+
+ attributes = BaseAutomaticActivityImporter.attributes + (
+ WorkflowAttribute('status', 'status', '',
+ 'Status which is set as DCWorkFlow status.',
+ required=True, encoding='ascii', datatype=str),
+ )
+
+
+class DecisionImporter(BaseAssignableActivityImporter):
+
+ attributes = BaseAssignableActivityImporter.attributes + (
+ WorkflowAttribute('decision_notice', 'decision_notice', '',
+ 'Describing the task for the decision.'),
+ WorkflowAttribute('decision_modus', 'decision_modus', '',
+ 'One of self.known_decision_modi',
+ required=True,
+ vocabulary=known_decision_modi),
+ WorkflowAttribute('reject_activity', 'reject_activity', (),
+ 'Activity if result is "no".',
+ encoding='ascii', datatype=tuple),
+ WorkflowAttribute('accept_activity', 'accept_activity', (),
+ 'Activity if result is "yes".',
+ encoding='ascii', datatype=tuple),
+ )
+
+
+class ExpressionImporter(BaseAutomaticActivityImporter):
+
+ attributes = BaseAutomaticActivityImporter.attributes + (
+ WorkflowAttribute('expression', 'expression', '',
+ 'TALES expression which is to be executed.',
+ required=True),
+ WorkflowAttribute('runAs', 'runAs', 'alphaflow/systemUser',
+ 'TALES expression returning the user to run as.',
+ required=False),
+ )
+
+
+class GateImporter(BaseAutomaticActivityImporter):
+
+ attributes = BaseAutomaticActivityImporter.attributes + (
+ WorkflowAttribute('mode', 'mode', '',
+ 'Mode the gate works, values see self.mode_types',
+ required=True, encoding='ascii', datatype=str,
+ vocabulary=mode_types),
+ )
+
+
+class EMailImporter(BaseAutomaticActivityImporter):
+
+ attributes = BaseAutomaticActivityImporter.attributes + (
+ WorkflowAttribute('template', 'template', '',
+ 'ID of a DTML-Method-Object being available from '
+ 'portal root.',
+ required=True, encoding='ascii', datatype=str),
+ WorkflowAttribute('mailSubject', 'mailSubject',
+ 'AlphaFlow notification message',
+ 'Static subject line for the mails sent.',
+ required=True),
+ RecipientsAttribute('recipientModes', '', (),
+ 'Who will get the email. (possible values see'
+ 'default of mode_name in subclasses of '
+ 'AbstractRecipent)',
+ required=True, datatype=tuple),
+ )
Modified: AlphaFlow/trunk/xmlimport/importexport.py
==============================================================================
--- AlphaFlow/trunk/xmlimport/importexport.py (original)
+++ AlphaFlow/trunk/xmlimport/importexport.py Thu Mar 15 16:48:27 2007
(at)(at) -9,7 +9,6 (at)(at)
from Globals import InitializeClass
from AccessControl import ClassSecurityInfo
-from Products.AlphaFlow.interfaces import IDOMConfigurable
from Products.AlphaFlow import config, utils
from Products.AlphaFlow.exception import ConfigurationError
from Products.AlphaFlow.workflowattr import workflow_attributes_registry
Copied: AlphaFlow/trunk/xmlimport/interfaces.py (from r4579,
AlphaFlow/trunk/xmlimport/interfaces_importexport.py)
==============================================================================
--- AlphaFlow/trunk/xmlimport/interfaces_importexport.py (original)
+++ AlphaFlow/trunk/xmlimport/interfaces.py Thu Mar 15 16:48:27 2007
(at)(at) -8,39 +8,16 (at)(at)
import zope.interface
-#####################
-# import/export stuff
+class IDOMImporter(zope.interface.Interface):
+ """DOM importer
-class IDOMConfigurable(zope.interface.Interface):
- """Implemented by objects which are configurable by DOM nodes."""
+ Creates and returns a workflow object (e.g. a process, activity or
similary)
+ from a DOM node that comes from an ALF.
- def __init__(id, *args, **kw):
- """Constructor must have this signature.
-
- id ... id for the object
- """
-
- def configureFromXML(REQUEST):
- """Saves the properties to the object.
-
- REQUEST ... HTTPRequest object which must have property 'xml'
- This property must be an XML-File containing the node of
the
- object as documentElement.
- """
-
-
- def configureFromDOMNode(node):
- """Configures the object from the given DOM node.
-
- Returns nothing.
- May raise ConfigurationError.
- """
-
- def createAndConfigureChildNodes(self, node):
- """Create and configure all child nodes of node.
+ """
- Returns list of created activities.
- """
+ def __call__(dom_node):
+ """Import the dom node."""
class IWorkflowAttributeAware(zope.interface.Interface):
Modified: AlphaFlow/trunk/xmlimport/workflowattr.py
==============================================================================
--- AlphaFlow/trunk/xmlimport/workflowattr.py (original)
+++ AlphaFlow/trunk/xmlimport/workflowattr.py Thu Mar 15 16:48:27 2007
(at)(at) -103,7 +103,6 (at)(at)
class WorkflowAttributeList(WorkflowAttribute):
-
def apply(self, node, obj):
"Import all child nodes as elements of one list attribute."
elements = []
(at)(at) -123,6 +122,27 (at)(at)
setattr(obj, self.classAttr, self.datatype(elements))
+class ConfiguresAttribute(WorkflowAttribute):
+
+ def apply(self, node, obj):
+ if node.hasAttribute('configures_all'):
+ setattr(obj, self.classAttr, None) # None is marker for "all"
+ elif node.hasAttribute('configures'):
+ super(ConfiguresAttribute, self).apply(node, obj)
+ else:
+ raise ConfigurationError(
+ "%r: Attribute configures or configures_all needed." %
+ node.nodeName)
+
+
+class RecipientsAttribute(WorkflowAttributeList):
+
+ def apply(self, node, obj):
+ super(RecipientsAttribute, self).apply(node, obj)
+ if len(getattr(obj, self.classAttr)) == 0:
+ raise ConfigurationError, "No recipients specified in %r" % self
+
+
def findAttrInAttributes(klass, classAttr):
"""Find classAttr in WorkflowAttributes of klass."""
for attr in klass.attributes:
|
SVN: r4581 - in AlphaFlow/trunk: . activities doc/proposals xmlimport
Christian Theune <ct(at)gocept.com> |
2007-03-16 13:37:48 |
[ FULL ]
|
Author: ctheune
Date: Fri Mar 16 13:37:45 2007
New Revision: 4581
Log:
- continued refactoring of import into its own components
- removed version activity
Removed:
AlphaFlow/trunk/activities/version.py
Modified:
AlphaFlow/trunk/__init__.py
AlphaFlow/trunk/activities/notify.py
AlphaFlow/trunk/activities/ntask.py
AlphaFlow/trunk/activities/parent.py
AlphaFlow/trunk/activities/permission.py
AlphaFlow/trunk/activities/recursion.py
AlphaFlow/trunk/activities/roleassign.py
AlphaFlow/trunk/activities/routing.py
AlphaFlow/trunk/activities/simpledecision.py
AlphaFlow/trunk/activities/switch.py
AlphaFlow/trunk/activities/task.py
AlphaFlow/trunk/doc/proposals/ASPECTS.txt
AlphaFlow/trunk/xmlimport/domimporters.py
AlphaFlow/trunk/xmlimport/workflowattr.py
Modified: AlphaFlow/trunk/__init__.py
==============================================================================
--- AlphaFlow/trunk/__init__.py (original)
+++ AlphaFlow/trunk/__init__.py Fri Mar 16 13:37:45 2007
(at)(at) -34,7 +34,7 (at)(at)
def initialize_activities(context):
from activities import \
- task, permission, version, expression, dcworkflow, \
+ task, permission, expression, dcworkflow, \
recursion, notify, alarm, routing, gates, ntask, \
decision, simpledecision, configuration, parent, switch, roleassign
Modified: AlphaFlow/trunk/activities/notify.py
==============================================================================
--- AlphaFlow/trunk/activities/notify.py (original)
+++ AlphaFlow/trunk/activities/notify.py Fri Mar 16 13:37:45 2007
(at)(at) -1,228 +1,3 (at)(at)
-# Copyright (c) 2004-2006 gocept gmbh & co. kg
-# See also LICENSE.txt
-# $Id$
-"""Implement the email activities.
-"""
-
-from email import Header as email_header
-from email import MIMEText
-import sys
-
-import zope.interface
-from AccessControl import ClassSecurityInfo
-from Persistence import Persistent
-
-from Products.CMFCore.utils import getToolByName
-
-from Products.AlphaFlow.utils import \
- unique, listMembersWithRolesAndLocalRoles
-from Products.AlphaFlow.workitem import registerWorkItem,
BaseAutomaticWorkItem
-from Products.AlphaFlow.activity import registerActivity,
BaseAutomaticActivity
-from Products.AlphaFlow.exception import ConfigurationError
-from Products.AlphaFlow.interfaces import \
- IEMailActivity, IEMailWorkItem, IEMailRecipientMode
-from Products.AlphaFlow.workflowattr import WorkflowAttribute
-from Products.AlphaFlow.registry import Registry
-
-
-class EMailActivity(BaseAutomaticActivity):
-
- zope.interface.implements(IEMailActivity)
-
- security = ClassSecurityInfo()
-
- meta_type = "AlphaFlow EMail Activity"
- activity_type = "email"
- icon = "misc_/AlphaFlow/email"
-
- _properties = BaseAutomaticActivity._properties + \
- ({'id': 'template', 'type': 'string', 'mode': 'w',},
- {'id': 'mailSubject', 'type': 'ustring', 'mode': 'w'},
- )
-
- security.declarePrivate('getRecipientModes')
- def getRecipientModes(self):
- "Return list of IEMailRecipientMode instances (possible recipents)."
- return self.recipientModes
-
-
-class EMailWorkItem(BaseAutomaticWorkItem):
-
- zope.interface.implements(IEMailWorkItem)
-
- security = ClassSecurityInfo()
-
- activity_type = "email"
-
- ######################
- # IAutomaticWorkItem
-
- security.declarePrivate('onStart')
- def onStart(self):
- """Send email."""
- portal_properties = getToolByName(self, 'portal_properties')
- membertool = getToolByName(self, 'portal_membership')
- portal_url = getToolByName(self, 'portal_url')
- portal = portal_url.getPortalObject()
-
- siteEncoding =
portal_properties.site_properties.getProperty('default_charset')
- activity = self.getActivity()
- instance = self.getInstance()
- recipient_modes = activity.getRecipientModes()
- work_items = self.passCheckpoint("continue")
- work_items = [instance[work_item] for work_item in work_items] or
[self]
-
- template = portal[activity.template]
- mail_header_data = {'From': self._quoteAddressField(
- portal_properties.email_from_name,
- portal_properties.email_from_address,
- siteEncoding),
- 'To': '',
- 'Errors-to': portal_properties.email_from_address,
- 'Subject':
email_header.Header(activity.mailSubject, siteEncoding),
- 'Content-Type': "text/plain; charset=%s" %
siteEncoding,
- }
- try:
- recipients = []
- for mode in recipient_modes:
- recipients.extend(mode.getRecipientsForWorkItem(self))
- email_recipients = unique(recipients)
-
- for memberid in email_recipients:
- member = membertool.getMemberById(memberid)
- if member is None:
- # users which are defined outside of the portal
- continue
- email = member.getProperty('email')
- if not email:
- # XXX do not send email if member has no email address
set.
- # XXX maybe we should log this.
- continue
-
- mail_variables = {'member': member,
- 'work_items': work_items}
- mail_body = template(self, self.REQUEST, **mail_variables)
- mail_header_data['To'] = self._quoteAddressField(
- member.getProperty('fullname'),
- email,
- siteEncoding)
- mail = MIMEText.MIMEText(mail_body, 'plain', siteEncoding)
- for key, val in mail_header_data.items():
- mail[key] = val
- portal.MailHost._send(portal_properties.email_from_address,
- member.getProperty('email'),
- mail.as_string())
- except:
- self.changeState("fallout",
- "Could not perform automatic activity: %s" %
- activity.title_or_id(),
- sys.exc_info())
- else:
- self.changeState("complete", activity.title_or_id())
-
-
- security.declarePrivate('_quoteAddressField')
- def _quoteAddressField(self, name, email, encoding):
- """Quote address field according to RFC 2822
-
- name ... real name of person
- email ... email address of the person
- encoding ... encoding used to encode name
-
- returns: string"""
- return '%s <%s>' % \
- (email_header.Header('%s' % name, encoding),
- email)
-
-
-class AbstractRecipent(Persistent):
- """Abstract recipient class."""
-
- zope.interface.implements(IEMailRecipientMode)
-
- nodeName = "recipient"
- attributes = ()
-
-
-
-class RecipientOwner(AbstractRecipent):
- """Recipient mode for notifying the owner of a process."""
-
- attributes = (WorkflowAttribute('mode_name', 'type', 'owner',
- 'Identifier for a specific mode.',
- importHandler=None),
- )
-
-
- def getRecipientsForWorkItem(self, wi):
- """Returns list of users which are recipients for a specific
- workitem."""
- content = wi.getContentObject()
- if content:
- return [content.owner_info()['id']]
- else:
- return []
-
-
-
-class RecipientNextAssignees(AbstractRecipent):
- """Recipient mode for notifying the assignee of the next workitems."""
-
- attributes = (WorkflowAttribute('mode_name', 'type', 'next_assignees',
- 'Identifier for a specific mode.',
- importHandler=None),
- )
-
- def getRecipientsForWorkItem(self, wi):
- """Returns list of users which are recipients for a specific
- workitem."""
- wis = wi.getGeneratedWorkItems()
-
- ret = {}
- for wi in wis:
- if wi.state != 'active':
- continue
- if wi.activity_type == 'route':
- for user in self.getRecipientsForWorkItem(wi):
- ret[user] = 1
- else:
- for user in wi.listRelevantUsers():
- ret[user] = 1
-
- return ret.keys()
-
-
-
-class RecipientPreviousAssignees(AbstractRecipent):
- """Recipient mode for notifying the assignee of the parent workitem."""
-
- attributes = (WorkflowAttribute('mode_name', 'type', 'previous_assignees',
- 'Identifier for a specific mode.',
- importHandler=None),
- )
-
- def getRecipientsForWorkItem(self, wi):
- """Returns list of users which are recipients for a specific
- workitem."""
- wi = wi.getParent()
- if wi:
- return wi.listRelevantUsers()
- else:
- return []
-
-
-
-class RecipientActualRole(AbstractRecipent):
- """Recipient mode for notifying users with one of the given roles."""
-
- attributes = (
- WorkflowAttribute('mode_name', 'type', 'actual_role',
- 'Identifier for a specific mode.',
- importHandler=None),
- WorkflowAttribute('roles', 'roles', (),
- 'Members with this roles get an e-mail.',
- required=True, encoding="ascii", datatype=tuple),
- )
def getRecipientsForWorkItem(self, wi):
"""Returns list of users with at least one of the given roles."""
Modified: AlphaFlow/trunk/activities/ntask.py
==============================================================================
--- AlphaFlow/trunk/activities/ntask.py (original)
+++ AlphaFlow/trunk/activities/ntask.py Fri Mar 16 13:37:45 2007
(at)(at) -24,18 +24,9 (at)(at)
security = ClassSecurityInfo()
meta_type = "AlphaFlow NTask Activity"
- activity_type = nodeName = "ntask"
+ activity_type = "ntask"
icon = "misc_/AlphaFlow/ntask"
- attributes = BaseAssignableActivity.attributes + (
- # XXX The import mechanism for this should be revisited.
- WorkflowAttribute('_exits', '', (),
- 'Tuple of IExit objects',
- datatype=tuple,
- importHandler="_attr_import_from_all_childnodes",
- exportHandler="_attr_export_as_childnodes"),
- )
-
configurationSchema = atapi.Schema((
atapi.TextField("task",
widget=atapi.TextAreaWidget(
(at)(at) -109,7 +100,6 (at)(at)
return self.getComment()
-
# register the stuff
registerActivity(NTaskActivity)
registerWorkItem(NTaskWorkItem)
Modified: AlphaFlow/trunk/activities/parent.py
==============================================================================
--- AlphaFlow/trunk/activities/parent.py (original)
+++ AlphaFlow/trunk/activities/parent.py Fri Mar 16 13:37:45 2007
(at)(at) -23,15 +23,17 (at)(at)
from Products.AlphaFlow import config
from Products.AlphaFlow.workflowattr import WorkflowAttribute
-
+
class ParentExit(Exit):
+
id = title = "parent"
def __init__(self, id, activity):
super(ParentExit, self).__init__(id)
self._activity = activity
- def __get_activities(self):
+ (at)property
+ def activities(self):
process = self._activity.__parent__
parent_name = self._activity.parentOf
self_id = self._activity.getId()
(at)(at) -46,12 +48,7 (at)(at)
activities.append(activity_id)
return activities
- def __set_activities(self, value):
- pass
- activities = property(__get_activities, __set_activities)
-
-
class ParentActivity(BaseAutomaticActivity):
zope.interface.implements(IParentActivity)
(at)(at) -59,21 +56,14 (at)(at)
security = ClassSecurityInfo()
meta_type = "AlphaFlow Parent Activity"
- activity_type = nodeName = "parent"
-
- attributes = BaseAutomaticActivity.attributes + (
- WorkflowAttribute('parentOf', 'continue_with_parent_of', (),
- 'Continue with parent of this activity.',
- required=True, encoding='ascii', datatype=str,
- ),
- )
+ activity_type = "parent"
def getExits(self):
exits = {}
exits["parent"] = ParentExit("parent", self)
return exits
-
+
class ParentWorkItemExit(WorkItemExit):
zope.component.adapts(IParentWorkItem, ParentExit)
Modified: AlphaFlow/trunk/activities/permission.py
==============================================================================
--- AlphaFlow/trunk/activities/permission.py (original)
+++ AlphaFlow/trunk/activities/permission.py Fri Mar 16 13:37:45 2007
(at)(at) -23,52 +23,13 (at)(at)
zope.interface.implements(IPermissionSetting)
- nodeName = "permission"
- attributes = (WorkflowAttribute('permission', 'name', '',
- 'The permission affected.',
- encoding="ascii", datatype=str),
- WorkflowAttribute('roles', 'roles', '',
- 'Sequence of affected roles.',
- encoding="ascii", datatype=tuple),
- WorkflowAttribute('acquire', 'acquire', '',
- '(bool) acquire permission or not.',
- required=True, datatype=bool),
- )
-
- def _validate(self, context):
- """Validate the permission configuration.
-
- - Permissions are required to exist
- """
- app = context.getPhysicalRoot()
- permission_valid = False
- permission = self.permission
- for p in app.ac_inherited_permissions(1):
- name = p[0]
- if name == permission:
- permission_valid = True
- break
- if not permission_valid:
- raise ConfigurationError, \
- "The permission %r does not exist." % permission
-
def apply(self, content):
"""Apply the permission setting on the content object."""
modifyRolesForPermission(content, self.permission, self.roles,
acquire=self.acquire)
-
class PermissionAddSetting(PermissionSetting):
-
- nodeName = "add"
- attributes = (WorkflowAttribute('permission', 'name', '',
- 'The permission affected.',
- encoding="ascii", datatype=str),
- WorkflowAttribute('roles', 'roles', '',
- 'Sequence of affected roles.',
- encoding="ascii", datatype=tuple),
- )
def apply(self, content):
"""Apply the permission setting on the content object."""
(at)(at) -76,22 +37,12 (at)(at)
class PermissionRemoveSetting(PermissionSetting):
-
- nodeName = "remove"
- attributes = (WorkflowAttribute('permission', 'name', '',
- 'The permission affected.',
- encoding="ascii", datatype=str),
- WorkflowAttribute('roles', 'roles', '',
- 'Sequence of affected roles.',
- encoding="ascii", datatype=tuple),
- )
def apply(self, content):
"""Apply the permission setting on the content object."""
removePermissionsFromRoles(content, self.roles, [self.permission])
-
class PermissionActivity(BaseAutomaticActivity):
zope.interface.implements(IPermissionActivity)
(at)(at) -99,17 +50,9 (at)(at)
security = ClassSecurityInfo()
meta_type = "AlphaFlow Permission Activity"
- activity_type = nodeName = "permission-change"
+ activity_type = "permission-change"
icon = "misc_/AlphaFlow/permission-change"
- attributes = BaseAutomaticActivity.attributes + (
- WorkflowAttribute('permission_changes', '', (),
- 'Tuple of IPermissionSettings',
- datatype=tuple,
- importHandler="_attr_import_permission",
- exportHandler="_attr_export_permission"),
- )
-
security.declareProtected(config.MANAGE_WORKFLOW, 'setPermissions')
def setPermissions(self, permission_setting):
permissions = []
(at)(at) -132,7 +75,7 (at)(at)
for perm in self.permission_changes:
perm._validate(self)
-
+
class PermissionWorkItem(BaseAutomaticWorkItem):
zope.interface.implements(IPermissionWorkItem)
(at)(at) -154,6 +97,6 (at)(at)
permset.apply(ob)
ob.aq_inner.reindexObjectSecurity()
-
+
registerActivity(PermissionActivity)
registerWorkItem(PermissionWorkItem)
Modified: AlphaFlow/trunk/activities/recursion.py
==============================================================================
--- AlphaFlow/trunk/activities/recursion.py (original)
+++ AlphaFlow/trunk/activities/recursion.py Fri Mar 16 13:37:45 2007
(at)(at) -28,22 +28,9 (at)(at)
security = ClassSecurityInfo()
meta_type = "AlphaFlow Recursion Activity"
- activity_type = nodeName = "recursion"
+ activity_type = "recursion"
icon = "misc_/AlphaFlow/recursion"
- attributes = BaseAutomaticActivity.attributes + (
- WorkflowAttribute('recursion_activity', 'recursion_activity', (),
- 'Activities which will get called recursively.',
- encoding='ascii', datatype=tuple),
- WorkflowAttribute('break_activities', 'break_activities', (),
- 'Activities which stop recursion.',
- encoding='ascii', datatype=tuple),
- WorkflowAttribute('optional_recursion', 'optional_recursion', True,
- 'User can select via UI if recursion should be '
- 'called.',
- datatype=bool),
- )
-
configurationSchema = Schema((
BooleanField("apply",
widget=BooleanWidget(
(at)(at) -96,7 +83,6 (at)(at)
activity_type = "recursion"
-
####################
# IAutomaticWorkItem
(at)(at) -113,7 +99,7 (at)(at)
else:
block = []
return block
-
+
security.declarePrivate("onCreatedItems")
def onCreatedItems(self, items=[]):
"""Trigger that gets called after new work items have been created."""
(at)(at) -174,7 +160,7 (at)(at)
"Estimate the relevant users. Not used for checking."
return ""
-
+
# register the stuff
registerActivity(RecursionActivity)
registerWorkItem(RecursionWorkItem)
Modified: AlphaFlow/trunk/activities/roleassign.py
==============================================================================
--- AlphaFlow/trunk/activities/roleassign.py (original)
+++ AlphaFlow/trunk/activities/roleassign.py Fri Mar 16 13:37:45 2007
(at)(at) -16,7 +16,7 (at)(at)
from Products.AlphaFlow.activities.interfaces import \
IRoleAssignActivity, IRoleAssignWorkItem
-
+
class RoleAssignActivity(BaseAutomaticActivity):
zope.interface.implements(IRoleAssignActivity)
(at)(at) -24,15 +24,9 (at)(at)
security = ClassSecurityInfo()
meta_type = "AlphaFlow Task Activity"
- activity_type = nodeName = "roleassign"
+ activity_type = "roleassign"
icon = "misc_/AlphaFlow/task"
- attributes = BaseAutomaticActivity.attributes + (
- WorkflowAttribute('roles', 'roles', (),
- 'Roles to assign on content object.',
- encoding="ascii", datatype=tuple),
- )
-
configurationSchema = atapi.Schema((
atapi.LinesField(
"users",
(at)(at) -45,10 +39,9 (at)(at)
description="Select one or more users for this task")),
))
-
security.declareProtected(config.WORK_WITH_PROCESS, 'getPossibleUsers')
def getPossibleUsers(self):
-
+
def _sort_members(a, b):
return cmp(a[1], b[1])
(at)(at) -66,13 +59,12 (at)(at)
nice_members.sort(_sort_members)
return nice_members
-
security.declarePrivate('_get_assignees_default')
def _get_assignees_default(self):
return [getSecurityManager().getUser().getUserName()]
-
+
class RoleAssignWorkItem(BaseAutomaticWorkItem):
zope.interface.implements(IRoleAssignWorkItem)
(at)(at) -85,13 +77,13 (at)(at)
activity = self.getActivity()
users = self.getActivityConfiguration('users')
content = self.getContentObject()
-
+
if content is not None:
for role in activity.roles:
self._removeLocalRoleFromAllUsers(role, content)
self._addLocalRole(role, users, content)
content.aq_inner.reindexObjectSecurity()
-
+
def _removeLocalRoleFromAllUsers(self, role, content):
"""remove a given local role from all users on content
"""
(at)(at) -115,9 +107,7 (at)(at)
for user in users:
content.manage_addLocalRoles(user, [role])
-
-
# register the stuff
registerActivity(RoleAssignActivity)
registerWorkItem(RoleAssignWorkItem)
Modified: AlphaFlow/trunk/activities/routing.py
==============================================================================
--- AlphaFlow/trunk/activities/routing.py (original)
+++ AlphaFlow/trunk/activities/routing.py Fri Mar 16 13:37:45 2007
(at)(at) -36,20 +36,9 (at)(at)
security = ClassSecurityInfo()
meta_type = "AlphaFlow Routing Activity"
- activity_type = nodeName = "route"
+ activity_type = "route"
icon = "misc_/AlphaFlow/route"
- attributes = BaseActivity.attributes + (
- WorkflowAttribute('gates', '', (),
- 'Gate activities inside the route.',
- importHandler="_attr_import_route",
- exportHandler="_attr_export_route"),
- WorkflowAttribute('routes', '', (),
- 'All activities inside route which are no gates.',
- importHandler=None, # done by handler above
- exportHandler=None),
- )
-
_properties = BaseActivity._properties + \
({'id': 'gates', 'type': 'multiple selection', 'mode': 'w',
'select_variable': 'listActivityIds'},
(at)(at) -62,25 +51,7 (at)(at)
exits["routes"] = Exit("routes", self.routes)
return exits
- #########
- # private
- security.declarePrivate('_attr_import_route')
- def _attr_import_route(self, attr, node):
- process = self.acquireProcess()
- childs = self.createAndConfigureChildNodes(node, activity_registry)
- gates = []
- routes = []
- for child in childs:
- act_id = child.getId()
- process._set_activity(act_id, child)
- if child.activity_type == "gate":
- gates.append(act_id)
- else:
- routes.append(act_id)
- self.gates = tuple(gates)
- self.routes = tuple(routes)
-
-
+
class RoutingWorkItem(BaseWorkItem):
zope.interface.implements(IRoutingWorkItem)
(at)(at) -109,7 +80,7 (at)(at)
return
if not workitem.activity_type == "gate":
return
-
+
# check if gate is completed
if workitem.state != "complete":
return
(at)(at) -152,7 +123,7 (at)(at)
"""
return ()
-
+
# register the stuff
registerActivity(RoutingActivity)
registerWorkItem(RoutingWorkItem)
Modified: AlphaFlow/trunk/activities/simpledecision.py
==============================================================================
--- AlphaFlow/trunk/activities/simpledecision.py (original)
+++ AlphaFlow/trunk/activities/simpledecision.py Fri Mar 16 13:37:45 2007
(at)(at) -50,22 +50,11 (at)(at)
security = ClassSecurityInfo()
meta_type = "AlphaFlow Simple Decision Activity"
- activity_type = nodeName = "simpledecision"
+ activity_type = "simpledecision"
icon = "misc_/AlphaFlow/decision"
- attributes = BaseAssignableActivity.attributes + (
- WorkflowAttribute('decision_notice', 'decision_notice', '',
- 'Describing the task for the decision.'),
- WorkflowAttribute('reject_activity', 'reject_activity', (),
- 'Activity if result is "no".',
- encoding='ascii', datatype=tuple),
- WorkflowAttribute('accept_activity', 'accept_activity', (),
- 'Activity if result is "yes".',
- encoding='ascii', datatype=tuple),
- )
-
+ # configurationSchema gets modified by __init__!
configurationSchema = BaseAssignableActivity.configurationSchema.copy()
- # gets modified by __init__!
_properties = BaseAssignableActivity._properties + \
({'id': 'decision_notice', 'type': 'text', 'mode': 'w'},
(at)(at) -153,14 +142,14 (at)(at)
self.reject),
]
return actions
-
+
def listRelevantUsers(self):
"""return the stored assignee"""
return [self.assignee]
###################
# IDecisionWorkItem
-
+
security.declareProtected(config.HANDLE_WORKITEM, "reject")
def reject(self, REQUEST=None):
"""Reject"""
Modified: AlphaFlow/trunk/activities/switch.py
==============================================================================
--- AlphaFlow/trunk/activities/switch.py (original)
+++ AlphaFlow/trunk/activities/switch.py Fri Mar 16 13:37:45 2007
(at)(at) -40,20 +40,7 (at)(at)
security = ClassSecurityInfo()
meta_type = "AlphaFlow Switch Activity"
- activity_type = nodeName = "switch"
-
- attributes = BaseAutomaticActivity.attributes + (
- WorkflowAttribute('mode', 'mode', None,
- 'Whether to create WorkItems for only the '
- 'first or all cases yielding True.',
- required=True, datatype=str,
- vocabulary=('first', 'all')),
- WorkflowAttribute('cases', '', (),
- 'Tuple of ICase objects',
- datatype=tuple,
- importHandler="_attr_import_from_all_childnodes",
- exportHandler="_attr_export_as_childnodes"),
- )
+ activity_type = "switch"
def getExits(self):
exits = {}
Modified: AlphaFlow/trunk/activities/task.py
==============================================================================
--- AlphaFlow/trunk/activities/task.py (original)
+++ AlphaFlow/trunk/activities/task.py Fri Mar 16 13:37:45 2007
(at)(at) -27,12 +27,6 (at)(at)
activity_type = nodeName = "task"
icon = "misc_/AlphaFlow/task"
- attributes = BaseAssignableActivity.attributes + (
- WorkflowAttribute('completion_activity', 'completion_activity', (),
- 'Activity to start after completion.',
- encoding="ascii", datatype=tuple),
- )
-
configurationSchema = atapi.Schema((
atapi.TextField("task",
widget=atapi.TextAreaWidget(
(at)(at) -77,7 +71,6 (at)(at)
self.complete),
]
-
###############
# ITaskWorkItem
(at)(at) -106,7 +99,6 (at)(at)
return self.getComment()
-
# register the stuff
registerActivity(TaskActivity)
registerWorkItem(TaskWorkItem)
Modified: AlphaFlow/trunk/doc/proposals/ASPECTS.txt
==============================================================================
--- AlphaFlow/trunk/doc/proposals/ASPECTS.txt (original)
+++ AlphaFlow/trunk/doc/proposals/ASPECTS.txt Fri Mar 16 13:37:45 2007
(at)(at) -94,6 +94,7 (at)(at)
recursion
expression
email
+ role-assign
Redefining Aspect Activities
Modified: AlphaFlow/trunk/xmlimport/domimporters.py
==============================================================================
--- AlphaFlow/trunk/xmlimport/domimporters.py (original)
+++ AlphaFlow/trunk/xmlimport/domimporters.py Fri Mar 16 13:37:45 2007
(at)(at) -4,7 +4,7 (at)(at)
"""DOM importers for the built-in workflow objects."""
-class ExitImporter(object):
+class Exit(object):
attributes = (
WorkflowAttribute('id', 'id', None,
(at)(at) -17,12 +17,9 (at)(at)
encoding='ascii', datatype=tuple),
)
-class BaseActivityImporter(object):
+class BaseActivity(object):
attributes = (
- WorkflowAttribute('id', 'id', None,
- 'Id of the activity.',
- importHandler=None),
WorkflowAttribute('title', 'title', '',
'Title of the activity.',
encoding="utf-8", datatype=str),
(at)(at) -45,18 +42,18 (at)(at)
)
-class BaseAutomaticActivityImporter(BaseActivityImporter):
+class BaseAutomaticActivity(BaseActivity):
- attributes = BaseActivityImporter.attributes + (
+ attributes = BaseActivity.attributes + (
WorkflowAttribute('continue_activity', 'continue_activity', (),
'A list of activities that follow this'
'automatic activity. (single exit)',
encoding='ascii', datatype=tuple))
-class BaseAssignableActivityImporter(BaseActivityImporter):
+class BaseAssignableActivity(BaseActivity):
- attributes = BaseActivityImporter.attributes + (
+ attributes = BaseActivity.attributes + (
WorkflowAttribute('viewUrlExpression', 'view_url_expr',
'string:${content/absolute_url}/view',
'(TALES expression) URL to "view" a workitem, '
(at)(at) -70,31 +67,21 (at)(at)
'"possible" or "actual".',
required=True, vocabulary=['actual', 'possible'],
importHandler="_attr_import_assignees"),
- WorkflowAttribute('roles', 'roles', (),
- 'Roles to compute which members are assignees',
- encoding='ascii', datatype=tuple,
- importHandler=None), # done by
_attr_import_assignees
- WorkflowAttribute('assigneesExpression', 'expression', None,
- 'Tales Expression returning a list of member ids, '
- 'may be None.',
- importHandler=None),
WorkflowAttribute('completionUrlExpression', 'completion_url_expr',
None,
'(TALES Expression) URL to redirect a user to after
completing the workitem.'
'If empty or unspecified the URL will be determined
the default algorithms.')
)
-class AlarmImporter(BaseAutomaticActivityImporter):
-
+class Alarm(BaseAutomaticActivity):
- attributes = BaseAutomaticActivityImporter.attributes + (
+ attributes = BaseAutomaticActivity.attributes + (
WorkflowAttribute('due', 'due', '',
'TALES expression that determines the date when '
'this alarm is due.',
required=True),)
-
-class ConfigurationImporter(BaseAssignableActivityImporter):
+class Configuration(BaseAssignableActivity):
attributes = BaseAssignableActivity.attributes + (
# viewUrlExpression overwrites existing viewUrlExpression
(at)(at) -113,18 +100,18 (at)(at)
)
-class DCWorkflowImporter(BaseAutomaticActivityImporter):
+class DCWorkflow(BaseAutomaticActivity):
- attributes = BaseAutomaticActivityImporter.attributes + (
+ attributes = BaseAutomaticActivity.attributes + (
WorkflowAttribute('status', 'status', '',
'Status which is set as DCWorkFlow status.',
required=True, encoding='ascii', datatype=str),
)
-class DecisionImporter(BaseAssignableActivityImporter):
+class Decision(BaseAssignableActivity):
- attributes = BaseAssignableActivityImporter.attributes + (
+ attributes = BaseAssignableActivity.attributes + (
WorkflowAttribute('decision_notice', 'decision_notice', '',
'Describing the task for the decision.'),
WorkflowAttribute('decision_modus', 'decision_modus', '',
(at)(at) -140,9 +127,9 (at)(at)
)
-class ExpressionImporter(BaseAutomaticActivityImporter):
+class Expression(BaseAutomaticActivity):
- attributes = BaseAutomaticActivityImporter.attributes + (
+ attributes = BaseAutomaticActivity.attributes + (
WorkflowAttribute('expression', 'expression', '',
'TALES expression which is to be executed.',
required=True),
(at)(at) -152,9 +139,9 (at)(at)
)
-class GateImporter(BaseAutomaticActivityImporter):
+class Gate(BaseAutomaticActivity):
- attributes = BaseAutomaticActivityImporter.attributes + (
+ attributes = BaseAutomaticActivity.attributes + (
WorkflowAttribute('mode', 'mode', '',
'Mode the gate works, values see self.mode_types',
required=True, encoding='ascii', datatype=str,
(at)(at) -162,9 +149,9 (at)(at)
)
-class EMailImporter(BaseAutomaticActivityImporter):
+class EMail(BaseAutomaticActivity):
- attributes = BaseAutomaticActivityImporter.attributes + (
+ attributes = BaseAutomaticActivity.attributes + (
WorkflowAttribute('template', 'template', '',
'ID of a DTML-Method-Object being available from '
'portal root.',
(at)(at) -179,3 +166,210 (at)(at)
'AbstractRecipent)',
required=True, datatype=tuple),
)
+
+class Recipient(object):
+
+ # Distinguish the various recipient modes and create
+ # recipient objects
+
+ attributes = (WorkflowAttribute('mode_name', 'type', 'owner',
+ 'Identifier for a specific mode.'),
+ )
+
+
+class RecipientNextAssignees(object):
+
+
+class RecipientPreviousAssignees
+
+class RecipientActualRole
+ attributes = (
+ WorkflowAttribute('roles', 'roles', (),
+ 'Members with this roles get an e-mail.',
+ required=True, encoding="ascii", datatype=tuple),
+ )
+
+class NTask(BaseAssignableActivity):
+
+
+ attributes = BaseAssignableActivity.attributes + (
+ # XXX The import mechanism for this should be revisited.
+ WorkflowAttribute('_exits', '', (),
+ 'Tuple of IExit objects',
+ datatype=tuple,
+ importHandler="_attr_import_from_all_childnodes",
+ exportHandler="_attr_export_as_childnodes"),
+ )
+
+
+class Parent(object):
+
+ attributes = BaseAutomaticActivity.attributes + (
+ WorkflowAttribute('parentOf', 'continue_with_parent_of', (),
+ 'Continue with parent of this activity.',
+ required=True, encoding='ascii', datatype=str,
+ ),
+ )
+
+
+class PermissionSetting(object):
+
+
+ attributes = (WorkflowAttribute('permission', 'name', '',
+ 'The permission affected.',
+ encoding="ascii", datatype=str),
+ WorkflowAttribute('roles', 'roles', '',
+ 'Sequence of affected roles.',
+ encoding="ascii", datatype=tuple),
+ WorkflowAttribute('acquire', 'acquire', '',
+ '(bool) acquire permission or not.',
+ required=True, datatype=bool),
+ )
+
+ def _validate(self, context):
+ """Validate the permission configuration.
+
+ - Permissions are required to exist
+ """
+ app = context.getPhysicalRoot()
+ permission_valid = False
+ permission = self.permission
+ for p in app.ac_inherited_permissions(1):
+ name = p[0]
+ if name == permission:
+ permission_valid = True
+ break
+ if not permission_valid:
+ raise ConfigurationError, \
+ "The permission %r does not exist." % permission
+
+class PermissionAddSetting(PermissionSetting):
+
+ attributes = (WorkflowAttribute('permission', 'name', '',
+ 'The permission affected.',
+ encoding="ascii", datatype=str),
+ WorkflowAttribute('roles', 'roles', '',
+ 'Sequence of affected roles.',
+ encoding="ascii", datatype=tuple),
+ )
+
+class PermissionRemoveSetting(PermissionSetting):
+
+ attributes = (WorkflowAttribute('permission', 'name', '',
+ 'The permission affected.',
+ encoding="ascii", datatype=str),
+ WorkflowAttribute('roles', 'roles', '',
+ 'Sequence of affected roles.',
+ encoding="ascii", datatype=tuple),
+ )
+
+
+class Permission(BaseAutomaticActivity):
+
+
+ attributes = BaseAutomaticActivity.attributes + (
+ WorkflowAttribute('permission_changes', '', (),
+ 'Tuple of IPermissionSettings',
+ datatype=tuple,
+ importHandler="_attr_import_permission",
+ exportHandler="_attr_export_permission"),
+ )
+
+
+class Recursion(BaseAutomaticActivity):
+
+ attributes = BaseAutomaticActivity.attributes + (
+ WorkflowAttribute('recursion_activity', 'recursion_activity', (),
+ 'Activities which will get called recursively.',
+ encoding='ascii', datatype=tuple),
+ WorkflowAttribute('break_activities', 'break_activities', (),
+ 'Activities which stop recursion.',
+ encoding='ascii', datatype=tuple),
+ WorkflowAttribute('optional_recursion', 'optional_recursion', True,
+ 'User can select via UI if recursion should be '
+ 'called.',
+ datatype=bool),
+ )
+
+
+class RoleAssign(BaseAutomaticActivity):
+
+
+ attributes = BaseAutomaticActivity.attributes + (
+ WorkflowAttribute('roles', 'roles', (),
+ 'Roles to assign on content object.',
+ encoding="ascii", datatype=tuple),
+ )
+
+
+class Routing(BaseAutomaticActivity):
+
+ attributes = BaseActivity.attributes + (
+ WorkflowAttribute('gates', '', (),
+ 'Gate activities inside the route.',
+ importHandler="_attr_import_route",
+ exportHandler="_attr_export_route"),
+ WorkflowAttribute('routes', '', (),
+ 'All activities inside route which are no gates.',
+ importHandler=None, # done by handler above
+ exportHandler=None),
+ )
+
+ #########
+ # private
+ security.declarePrivate('_attr_import_route')
+ def _attr_import_route(self, attr, node):
+ process = self.acquireProcess()
+ childs = self.createAndConfigureChildNodes(node, activity_registry)
+ gates = []
+ routes = []
+ for child in childs:
+ act_id = child.getId()
+ process._set_activity(act_id, child)
+ if child.activity_type == "gate":
+ gates.append(act_id)
+ else:
+ routes.append(act_id)
+ self.gates = tuple(gates)
+ self.routes = tuple(routes)
+
+
+class SimpleDecision(BaseAssignableActivity):
+
+ attributes = BaseAssignableActivity.attributes + (
+ WorkflowAttribute('decision_notice', 'decision_notice', '',
+ 'Describing the task for the decision.'),
+ WorkflowAttribute('reject_activity', 'reject_activity', (),
+ 'Activity if result is "no".',
+ encoding='ascii', datatype=tuple),
+ WorkflowAttribute('accept_activity', 'accept_activity', (),
+ 'Activity if result is "yes".',
+ encoding='ascii', datatype=tuple),
+ )
+
+
+class Switch(BaseAutomaticActivity):
+
+ attributes = BaseAutomaticActivity.attributes + (
+ WorkflowAttribute('mode', 'mode', None,
+ 'Whether to create WorkItems for only the '
+ 'first or all cases yielding True.',
+ required=True, datatype=str,
+ vocabulary=('first', 'all')),
+ WorkflowAttribute('cases', '', (),
+ 'Tuple of ICase objects',
+ datatype=tuple,
+ importHandler="_attr_import_from_all_childnodes",
+ exportHandler="_attr_export_as_childnodes"),
+ )
+
+
+class Task(BaseAssignableActivity):
+
+
+ attributes = BaseAssignableActivity.attributes + (
+ WorkflowAttribute('completion_activity', 'completion_activity', (),
+ 'Activity to start after completion.',
+ encoding="ascii", datatype=tuple),
+ )
+
Modified: AlphaFlow/trunk/xmlimport/workflowattr.py
==============================================================================
--- AlphaFlow/trunk/xmlimport/workflowattr.py (original)
+++ AlphaFlow/trunk/xmlimport/workflowattr.py Fri Mar 16 13:37:45 2007
(at)(at) -140,11 +140,4 (at)(at)
def apply(self, node, obj):
super(RecipientsAttribute, self).apply(node, obj)
if len(getattr(obj, self.classAttr)) == 0:
- raise ConfigurationError, "No recipients specified in %r" % self
-
-
-def findAttrInAttributes(klass, classAttr):
- """Find classAttr in WorkflowAttributes of klass."""
- for attr in klass.attributes:
- if attr.classAttr == classAttr:
- return attr
+ raise ConfigurationError("No recipients specified in %r" % self)
|
SVN: r4582 - AlphaFlow/trunk/xmlimport
Christian Theune <ct(at)gocept.com> |
2007-03-16 13:44:06 |
[ FULL ]
|
Author: ctheune
Date: Fri Mar 16 13:44:04 2007
New Revision: 4582
Log:
Added:
AlphaFlow/trunk/xmlimport/core.py
- copied, changed from r4580, AlphaFlow/trunk/xmlimport/importexport.py
Removed:
AlphaFlow/trunk/xmlimport/importexport.py
Copied: AlphaFlow/trunk/xmlimport/core.py (from r4580,
AlphaFlow/trunk/xmlimport/importexport.py)
==============================================================================
--- AlphaFlow/trunk/xmlimport/importexport.py (original)
+++ AlphaFlow/trunk/xmlimport/core.py Fri Mar 16 13:44:04 2007
(at)(at) -1,7 +1,7 (at)(at)
# Copyright (c) 2004-2006 gocept gmbh & co. kg
# See also LICENSE.txt
# $Id$
-"""Mixins for import and export"""
+"""Core components that drive the import/export"""
from xml.dom import minidom
|
SVN: r4586 - in AlphaFlow/trunk: . activities adapters xmlimport
Christian Theune <ct(at)gocept.com> |
2007-03-16 14:16:13 |
[ FULL ]
|
Author: ctheune
Date: Fri Mar 16 14:16:10 2007
New Revision: 4586
Log:
- removed old-style registries
Removed:
AlphaFlow/trunk/registry.py
Modified:
AlphaFlow/trunk/activities/alarm.py
AlphaFlow/trunk/activities/configuration.py
AlphaFlow/trunk/activities/dcworkflow.py
AlphaFlow/trunk/activities/decision.py
AlphaFlow/trunk/activities/expression.py
AlphaFlow/trunk/activities/gates.py
AlphaFlow/trunk/activities/notify.py
AlphaFlow/trunk/activities/ntask.py
AlphaFlow/trunk/activities/parent.py
AlphaFlow/trunk/activities/permission.py
AlphaFlow/trunk/activities/recursion.py
AlphaFlow/trunk/activities/roleassign.py
AlphaFlow/trunk/activities/routing.py
AlphaFlow/trunk/activities/simpledecision.py
AlphaFlow/trunk/activities/switch.py
AlphaFlow/trunk/activities/task.py
AlphaFlow/trunk/activity.py
AlphaFlow/trunk/adapters/alphaflowable.py
AlphaFlow/trunk/instance.py
AlphaFlow/trunk/interfaces.py
AlphaFlow/trunk/process.py
AlphaFlow/trunk/workitem.py
AlphaFlow/trunk/xmlimport/domimporters.py
AlphaFlow/trunk/xmlimport/interfaces.py
Modified: AlphaFlow/trunk/activities/alarm.py
==============================================================================
--- AlphaFlow/trunk/activities/alarm.py (original)
+++ AlphaFlow/trunk/activities/alarm.py Fri Mar 16 14:16:10 2007
(at)(at) -7,8 +7,8 (at)(at)
import zope.interface
from AccessControl import ClassSecurityInfo
-from Products.AlphaFlow.workitem import registerWorkItem,
BaseAutomaticWorkItem
-from Products.AlphaFlow.activity import registerActivity,
BaseAutomaticActivity
+from Products.AlphaFlow.workitem import BaseAutomaticWorkItem
+from Products.AlphaFlow.activity import BaseAutomaticActivity
from Products.AlphaFlow.interfaces import IAlarmActivity, IAlarmWorkItem
from Products.AlphaFlow import config, utils
(at)(at) -52,8 +52,3 (at)(at)
elif self.state == 'complete':
return "deadline exceeded"
return "Error Status"
-
-
-# register the stuff
-registerActivity(AlarmActivity)
-registerWorkItem(AlarmWorkItem)
Modified: AlphaFlow/trunk/activities/configuration.py
==============================================================================
--- AlphaFlow/trunk/activities/configuration.py (original)
+++ AlphaFlow/trunk/activities/configuration.py Fri Mar 16 14:16:10 2007
(at)(at) -8,10 +8,8 (at)(at)
from Products.AlphaFlow.interfaces import \
IConfigurationActivity, IConfigurationWorkItem
-from Products.AlphaFlow.workitem import \
- registerWorkItem, BaseAssignableWorkItem, Group
-from Products.AlphaFlow.activity import \
- Exit, registerActivity, BaseAssignableActivity
+from Products.AlphaFlow.workitem import BaseAssignableWorkItem, Group
+from Products.AlphaFlow.activity import Exit,BaseAssignableActivity
from Products.AlphaFlow import config
from Products.AlphaFlow.exception import ConfigurationError
from Products.AlphaFlow.action import Action
(at)(at) -125,9 +123,3 (at)(at)
groups = [ Group(instance, *item) for item in groups.items() ]
groups.sort()
return groups
-
-
-
-# register the stuff
-registerActivity(ConfigurationActivity)
-registerWorkItem(ConfigurationWorkItem)
Modified: AlphaFlow/trunk/activities/dcworkflow.py
==============================================================================
--- AlphaFlow/trunk/activities/dcworkflow.py (original)
+++ AlphaFlow/trunk/activities/dcworkflow.py Fri Mar 16 14:16:10 2007
(at)(at) -9,8 +9,8 (at)(at)
import zope.interface
from AccessControl import ClassSecurityInfo
-from Products.AlphaFlow.workitem import registerWorkItem,
BaseAutomaticWorkItem
-from Products.AlphaFlow.activity import registerActivity,
BaseAutomaticActivity
+from Products.AlphaFlow.workitem import BaseAutomaticWorkItem
+from Products.AlphaFlow.activity import BaseAutomaticActivity
from Products.AlphaFlow.interfaces import IDCWorkFlowActivity
(at)(at) -63,7 +63,3 (at)(at)
})
wfh.set("alphaflow_fake", tuple(affh))
ob.aq_inner.reindexObject(idxs=['review_state'])
-
-
-registerActivity(DCWorkFlowActivity)
-registerWorkItem(DCWorkFlowWorkItem)
Modified: AlphaFlow/trunk/activities/decision.py
==============================================================================
--- AlphaFlow/trunk/activities/decision.py (original)
+++ AlphaFlow/trunk/activities/decision.py Fri Mar 16 14:16:10 2007
(at)(at) -9,9 +9,8 (at)(at)
from Products.Archetypes import public as atapi
from Products.AlphaFlow.interfaces import IDecisionActivity, IDecisionWorkItem
-from Products.AlphaFlow.workitem import BaseAssignableWorkItem,
registerWorkItem
-from Products.AlphaFlow.activity import \
- Exit, BaseAssignableActivity, registerActivity
+from Products.AlphaFlow.workitem import BaseAssignableWorkItem
+from Products.AlphaFlow.activity import Exit, BaseAssignableActivity
from Products.AlphaFlow import config
from Products.AlphaFlow.action import Action
(at)(at) -179,7 +178,3 (at)(at)
return
self.passCheckpoint("accept")
self.changeState("complete", "all necessary assignees accepted")
-
-
-registerActivity(DecisionActivity)
-registerWorkItem(DecisionWorkItem)
Modified: AlphaFlow/trunk/activities/expression.py
==============================================================================
--- AlphaFlow/trunk/activities/expression.py (original)
+++ AlphaFlow/trunk/activities/expression.py Fri Mar 16 14:16:10 2007
(at)(at) -6,8 +6,8 (at)(at)
import zope.interface
from AccessControl import ClassSecurityInfo
-from Products.AlphaFlow.workitem import registerWorkItem,
BaseAutomaticWorkItem
-from Products.AlphaFlow.activity import registerActivity,
BaseAutomaticActivity
+from Products.AlphaFlow.workitem import BaseAutomaticWorkItem
+from Products.AlphaFlow.activity import BaseAutomaticActivity
from Products.AlphaFlow.interfaces import \
IExpressionActivity, IExpressionWorkItem
(at)(at) -49,7 +49,3 (at)(at)
'user but %r' % (activity.runAs, run_as))
evaluateTalesAs(self, activity.expression, run_as)
-
-
-registerActivity(ExpressionActivity)
-registerWorkItem(ExpressionWorkItem)
Modified: AlphaFlow/trunk/activities/gates.py
==============================================================================
--- AlphaFlow/trunk/activities/gates.py (original)
+++ AlphaFlow/trunk/activities/gates.py Fri Mar 16 14:16:10 2007
(at)(at) -7,8 +7,8 (at)(at)
import zope.interface
from AccessControl import ClassSecurityInfo
-from Products.AlphaFlow.workitem import registerWorkItem, BaseWorkItem
-from Products.AlphaFlow.activity import registerActivity,
BaseAutomaticActivity
+from Products.AlphaFlow.workitem import BaseWorkItem
+from Products.AlphaFlow.activity import BaseAutomaticActivity
from Products.AlphaFlow.interfaces import \
IDaemonActivity, IGateActivity, IGateWorkItem
from Products.AlphaFlow import config
(at)(at) -165,7 +165,3 (at)(at)
"""Return a list of actions the user may perform on this work item.
"""
return ()
-
-
-registerActivity(GateActivity)
-registerWorkItem(GateWorkItem)
Modified: AlphaFlow/trunk/activities/notify.py
==============================================================================
--- AlphaFlow/trunk/activities/notify.py (original)
+++ AlphaFlow/trunk/activities/notify.py Fri Mar 16 14:16:10 2007
(at)(at) -16,34 +16,11 (at)(at)
from Products.AlphaFlow.utils import \
unique, listMembersWithRolesAndLocalRoles
-from Products.AlphaFlow.workitem import registerWorkItem,
BaseAutomaticWorkItem
-from Products.AlphaFlow.activity import registerActivity,
BaseAutomaticActivity
+from Products.AlphaFlow.workitem import BaseAutomaticWorkItem
+from Products.AlphaFlow.activity import BaseAutomaticActivity
from Products.AlphaFlow.exception import ConfigurationError
from Products.AlphaFlow.interfaces import \
IEMailActivity, IEMailWorkItem, IEMailRecipientMode
-from Products.AlphaFlow.registry import Registry
-
-
-class EMailRegistry(Registry):
- """Registry for email recipents."""
-
- def _compute_key(self, klass):
- "Compute the search key from a class object."
- return klass.mode_name
-
- def getFromDOMNode(self, node):
- """Get a class object from data given in DOM-Node.
-
- node.getAttribute('mode_name') is used as key.
- """
- if node.nodeName != AbstractRecipent.nodeName:
- raise KeyError, 'Only recipent modes in this registry'
- return self.get(node.getAttribute('type'))
-
-
-#################################
-# Registry for all recipent modes
-notify_registry = EMailRegistry()
class EMailActivity(BaseAutomaticActivity):
(at)(at) -227,8 +204,3 (at)(at)
listMembersWithRolesAndLocalRoles(contentObject, self.roles)
return relevant
-
-
-# register the stuff
-registerActivity(EMailActivity)
-registerWorkItem(EMailWorkItem)
Modified: AlphaFlow/trunk/activities/ntask.py
==============================================================================
--- AlphaFlow/trunk/activities/ntask.py (original)
+++ AlphaFlow/trunk/activities/ntask.py Fri Mar 16 14:16:10 2007
(at)(at) -9,9 +9,8 (at)(at)
from Products.Archetypes import public as atapi
from Products.AlphaFlow.interfaces import INTaskActivity, INTaskWorkItem
-from Products.AlphaFlow.workitem import registerWorkItem,
BaseAssignableWorkItem
-from Products.AlphaFlow.activity import \
- registerActivity, BaseAssignableActivity
+from Products.AlphaFlow.workitem import BaseAssignableWorkItem
+from Products.AlphaFlow.activity import BaseAssignableActivity
from Products.AlphaFlow import config
from Products.AlphaFlow.action import Action
(at)(at) -97,8 +96,3 (at)(at)
def getStatusInfo(self):
"""Returns a short status information text."""
return self.getComment()
-
-
-# register the stuff
-registerActivity(NTaskActivity)
-registerWorkItem(NTaskWorkItem)
Modified: AlphaFlow/trunk/activities/parent.py
==============================================================================
--- AlphaFlow/trunk/activities/parent.py (original)
+++ AlphaFlow/trunk/activities/parent.py Fri Mar 16 14:16:10 2007
(at)(at) -14,10 +14,8 (at)(at)
from AccessControl import ClassSecurityInfo
from ComputedAttribute import ComputedAttribute
-from Products.AlphaFlow.workitem import \
- registerWorkItem, BaseAutomaticWorkItem, WorkItemExit
-from Products.AlphaFlow.activity import \
- Exit, registerActivity, BaseAutomaticActivity
+from Products.AlphaFlow.workitem import BaseAutomaticWorkItem, WorkItemExit
+from Products.AlphaFlow.activity import Exit, BaseAutomaticActivity
from Products.AlphaFlow.interfaces import \
IParentActivity, IParentWorkItem, IWorkItemExit
from Products.AlphaFlow import config
(at)(at) -115,8 +113,3 (at)(at)
my_activity = self.getActivity()
self.passCheckpoint("parent")
self.changeState('complete', my_activity.title_or_id())
-
-
-# register the stuff
-registerActivity(ParentActivity)
-registerWorkItem(ParentWorkItem)
Modified: AlphaFlow/trunk/activities/permission.py
==============================================================================
--- AlphaFlow/trunk/activities/permission.py (original)
+++ AlphaFlow/trunk/activities/permission.py Fri Mar 16 14:16:10 2007
(at)(at) -10,8 +10,8 (at)(at)
from Products.AlphaFlow.interfaces import \
IPermissionActivity, IPermissionWorkItem, IPermissionSetting
-from Products.AlphaFlow.workitem import registerWorkItem,
BaseAutomaticWorkItem
-from Products.AlphaFlow.activity import registerActivity,
BaseAutomaticActivity
+from Products.AlphaFlow.workitem import BaseAutomaticWorkItem
+from Products.AlphaFlow.activity import BaseAutomaticActivity
from Products.AlphaFlow.utils import modifyRolesForPermission,
addPermissionsToRoles, removePermissionsFromRoles
from Products.AlphaFlow.exception import ConfigurationError
from Products.AlphaFlow import config
(at)(at) -85,7 +85,3 (at)(at)
for permset in permission_changes:
permset.apply(ob)
ob.aq_inner.reindexObjectSecurity()
-
-
-registerActivity(PermissionActivity)
-registerWorkItem(PermissionWorkItem)
Modified: AlphaFlow/trunk/activities/recursion.py
==============================================================================
--- AlphaFlow/trunk/activities/recursion.py (original)
+++ AlphaFlow/trunk/activities/recursion.py Fri Mar 16 14:16:10 2007
(at)(at) -13,9 +13,8 (at)(at)
from Products.Archetypes.public import \
Schema, BooleanField, BooleanWidget
-from Products.AlphaFlow.workitem import registerWorkItem,
BaseAutomaticWorkItem
-from Products.AlphaFlow.activity import \
- Exit, registerActivity, BaseAutomaticActivity
+from Products.AlphaFlow.workitem import BaseAutomaticWorkItem
+from Products.AlphaFlow.activity import Exit, BaseAutomaticActivity
from Products.AlphaFlow import config, utils
from Products.AlphaFlow.interfaces import IDaemonActivity
Modified: AlphaFlow/trunk/activities/roleassign.py
==============================================================================
--- AlphaFlow/trunk/activities/roleassign.py (original)
+++ AlphaFlow/trunk/activities/roleassign.py Fri Mar 16 14:16:10 2007
(at)(at) -9,8 +9,8 (at)(at)
from Products.CMFCore.utils import getToolByName
from Products.Archetypes import public as atapi
-from Products.AlphaFlow.workitem import registerWorkItem,
BaseAutomaticWorkItem
-from Products.AlphaFlow.activity import registerActivity,
BaseAutomaticActivity
+from Products.AlphaFlow.workitem import BaseAutomaticWorkItem
+from Products.AlphaFlow.activity import BaseAutomaticActivity
from Products.AlphaFlow import config
from Products.AlphaFlow.activities.interfaces import \
IRoleAssignActivity, IRoleAssignWorkItem
(at)(at) -105,8 +105,3 (at)(at)
"""add a role to all given users"""
for user in users:
content.manage_addLocalRoles(user, [role])
-
-
-# register the stuff
-registerActivity(RoleAssignActivity)
-registerWorkItem(RoleAssignWorkItem)
Modified: AlphaFlow/trunk/activities/routing.py
==============================================================================
--- AlphaFlow/trunk/activities/routing.py (original)
+++ AlphaFlow/trunk/activities/routing.py Fri Mar 16 14:16:10 2007
(at)(at) -7,9 +7,8 (at)(at)
import zope.interface
from AccessControl import ClassSecurityInfo
-from Products.AlphaFlow.workitem import registerWorkItem, BaseWorkItem
-from Products.AlphaFlow.activity import \
- Exit, registerActivity, BaseActivity, activity_registry
+from Products.AlphaFlow.workitem import BaseWorkItem
+from Products.AlphaFlow.activity import Exit, BaseActivity
from Products.AlphaFlow import config
from Products.AlphaFlow.utils import killWorkItemRecursively
from Products.AlphaFlow.interfaces import \
(at)(at) -121,8 +120,3 (at)(at)
"""Return a list of actions the user may perform on this work item.
"""
return ()
-
-
-# register the stuff
-registerActivity(RoutingActivity)
-registerWorkItem(RoutingWorkItem)
Modified: AlphaFlow/trunk/activities/simpledecision.py
==============================================================================
--- AlphaFlow/trunk/activities/simpledecision.py (original)
+++ AlphaFlow/trunk/activities/simpledecision.py Fri Mar 16 14:16:10 2007
(at)(at) -13,9 +13,8 (at)(at)
from Products.AlphaFlow.interfaces import \
ISimpleDecisionActivity, IDecisionWorkItem, IWorkItemFactory
-from Products.AlphaFlow.workitem import BaseAssignableWorkItem,
registerWorkItem
-from Products.AlphaFlow.activity import \
- Exit, BaseAssignableActivity, registerActivity
+from Products.AlphaFlow.workitem import BaseAssignableWorkItem
+from Products.AlphaFlow.activity import Exit, BaseAssignableActivity
from Products.AlphaFlow import config, utils
from Products.AlphaFlow.action import Action
(at)(at) -177,7 +176,3 (at)(at)
info = "n/a"
else:
info = content.Title()
-
-
-registerActivity(SimpleDecisionActivity)
-registerWorkItem(SimpleDecisionWorkItem)
Modified: AlphaFlow/trunk/activities/switch.py
==============================================================================
--- AlphaFlow/trunk/activities/switch.py (original)
+++ AlphaFlow/trunk/activities/switch.py Fri Mar 16 14:16:10 2007
(at)(at) -15,10 +15,8 (at)(at)
import zope.interface
from AccessControl import ClassSecurityInfo
-from Products.AlphaFlow.workitem import \
- registerWorkItem, BaseAutomaticWorkItem
-from Products.AlphaFlow.activity import \
- registerActivity, BaseAutomaticActivity
+from Products.AlphaFlow.workitem import BaseAutomaticWorkItem
+from Products.AlphaFlow.activity import BaseAutomaticActivity
from Products.AlphaFlow.interfaces import ISwitchActivity, ISwitchWorkItem
from Products.AlphaFlow import config, utils
from Products.AlphaFlow.activity import Exit
Modified: AlphaFlow/trunk/activities/task.py
==============================================================================
--- AlphaFlow/trunk/activities/task.py (original)
+++ AlphaFlow/trunk/activities/task.py Fri Mar 16 14:16:10 2007
(at)(at) -9,9 +9,8 (at)(at)
from Products.Archetypes import public as atapi
from Products.AlphaFlow.interfaces import ITaskActivity, ITaskWorkItem
-from Products.AlphaFlow.workitem import registerWorkItem,
BaseAssignableWorkItem
-from Products.AlphaFlow.activity import \
- Exit, registerActivity, BaseAssignableActivity
+from Products.AlphaFlow.workitem import BaseAssignableWorkItem
+from Products.AlphaFlow.activity import Exit, BaseAssignableActivity
from Products.AlphaFlow import config
from Products.AlphaFlow.action import Action
Modified: AlphaFlow/trunk/activity.py
==============================================================================
--- AlphaFlow/trunk/activity.py (original)
+++ AlphaFlow/trunk/activity.py Fri Mar 16 14:16:10 2007
(at)(at) -16,11 +16,9 (at)(at)
IActivity, IAutomaticActivity, IAssignableActivity, IExit
from Products.AlphaFlow import config, utils
from Products.AlphaFlow.exception import ConfigurationError
-from Products.AlphaFlow.workflowattr import \
- WorkflowAttribute, findAttrInAttributes
-from Products.AlphaFlow.registry import Registry
+from Products.AlphaFlow.workflowattr import findAttrInAttributes
+
-
class Exit(Persistent):
"""A class that (unfortunately) has two meanings:
(at)(at) -100,7 +98,7 (at)(at)
InitializeClass(BaseActivity)
-
+
class BaseAutomaticActivity(BaseActivity):
"""A base class for automatic activities (single exit)"""
(at)(at) -247,11 +245,3 (at)(at)
InitializeClass(BaseAssignableActivity)
-
-
-#############################
-# Registry for all activities
-activity_registry = Registry()
-
-def registerActivity(activity):
- InitializeClass(activity)
Modified: AlphaFlow/trunk/adapters/alphaflowable.py
==============================================================================
--- AlphaFlow/trunk/adapters/alphaflowable.py (original)
+++ AlphaFlow/trunk/adapters/alphaflowable.py Fri Mar 16 14:16:10 2007
(at)(at) -16,7 +16,6 (at)(at)
from Products.AlphaFlow.adapters import adapter
from Products.AlphaFlow.process import Process
from Products.AlphaFlow import config
-from Products.AlphaFlow.activity import activity_registry
validate_wf_defs = have_libxml2 and config.validate_wf_defs
(at)(at) -41,7 +40,7 (at)(at)
id = wf.getAttribute('id').encode('ascii')
p = self.addProcess(id)
p.configureFromDOMNode(wf)
- childs = p.createAndConfigureChildNodes(wf, activity_registry)
+ childs = p.createAndConfigureChildNodes(wf)
for child in childs:
p._set_activity(child.id, child)
if validate_wf_defs:
Modified: AlphaFlow/trunk/instance.py
==============================================================================
--- AlphaFlow/trunk/instance.py (original)
+++ AlphaFlow/trunk/instance.py Fri Mar 16 14:16:10 2007
(at)(at) -662,7 +662,3 (at)(at)
InitializeClass(Instance)
registerType(Instance, config.PROJECTNAME)
-
-
-
-
Modified: AlphaFlow/trunk/interfaces.py
==============================================================================
--- AlphaFlow/trunk/interfaces.py (original)
+++ AlphaFlow/trunk/interfaces.py Fri Mar 16 14:16:10 2007
(at)(at) -194,7 +194,7 (at)(at)
# process stuff
-class IProcess(IWorkflowAttributeAware):
+class IProcess(zope.interface.Interface):
"""A process definition."""
id = zope.interface.Attribute("Id of this process definition.")
(at)(at) -214,7 +214,7 (at)(at)
"""returns the process definition from the acquisition chain"""
-class IActivity(IWorkflowAttributeAware):
+class IActivity(zope.interface.Interface):
"""A workflow activity.
These are the building blocks for process definitions.
Modified: AlphaFlow/trunk/process.py
==============================================================================
--- AlphaFlow/trunk/process.py (original)
+++ AlphaFlow/trunk/process.py Fri Mar 16 14:16:10 2007
(at)(at) -11,7 +11,6 (at)(at)
from Products.AlphaFlow.interfaces import IProcess
from Products.AlphaFlow import utils, config
-from Products.AlphaFlow.activity import activity_registry
from Products.AlphaFlow.exception import UnknownActivityTypeError
Modified: AlphaFlow/trunk/workitem.py
==============================================================================
--- AlphaFlow/trunk/workitem.py (original)
+++ AlphaFlow/trunk/workitem.py Fri Mar 16 14:16:10 2007
(at)(at) -28,7 +28,6 (at)(at)
IAlphaFlowed, IAutomaticWorkItem, ICheckpoint, \
IActivity, IAssignableActivity, IAssignableWorkItem, IFieldGroup
from Products.AlphaFlow.aspects.interfaces import IWorkItemAspect
-from Products.AlphaFlow.registry import Registry
from Products.AlphaFlow.activity import Exit
from Products.AlphaFlow.exception import AlphaFlowException
(at)(at) -689,7 +688,6 (at)(at)
InitializeClass(BaseAutomaticWorkItem)
-
################
# Helper classes
(at)(at) -721,28 +719,3 (at)(at)
def getSortPriority(self):
return self.getActivity().sortPriority
-
-
-class WorkItemRegistry(Registry):
- """Registry for workitems."""
-
- def _compute_key(self, klass):
- "Compute the search key from a class object."
- return klass.activity_type
-
- def getFromDOMNode(self, node):
- """Get a class object from data given in DOM-Node.
-
- node.getAttribute('mode_name') is used as key.
- """
- raise NotImplementedError, 'There are no DOM nodes for workitems'
-
-
-####################
-# Work item registry
-workitem_registry = WorkItemRegistry()
-
-def registerWorkItem(workitem):
- InitializeClass(workitem)
- atapi.registerType(workitem, config.PROJECTNAME)
- workitem_registry.register(workitem)
Modified: AlphaFlow/trunk/xmlimport/domimporters.py
==============================================================================
--- AlphaFlow/trunk/xmlimport/domimporters.py (original)
+++ AlphaFlow/trunk/xmlimport/domimporters.py Fri Mar 16 14:16:10 2007
(at)(at) -17,6 +17,13 (at)(at)
encoding='ascii', datatype=tuple),
)
+
+class Case(Exit):
+
+ attributes = Exit.attributes + (
+ WorkflowAttribute("condition", "condition", None,
+ "TALES expression returning True or False."),)
+
class BaseActivity(object):
attributes = (
(at)(at) -39,9 +46,9 (at)(at)
'Should the commentfield be hidden or have '
'required input?',
datatype=str),
-
)
+
class BaseAutomaticActivity(BaseActivity):
attributes = BaseActivity.attributes + (
(at)(at) -50,8 +57,8 (at)(at)
'automatic activity. (single exit)',
encoding='ascii', datatype=tuple))
-class BaseAssignableActivity(BaseActivity):
+class BaseAssignableActivity(BaseActivity):
attributes = BaseActivity.attributes + (
WorkflowAttribute('viewUrlExpression', 'view_url_expr',
(at)(at) -81,6 +88,7 (at)(at)
'this alarm is due.',
required=True),)
+
class Configuration(BaseAssignableActivity):
attributes = BaseAssignableActivity.attributes + (
(at)(at) -178,19 +186,23 (at)(at)
class RecipientNextAssignees(object):
+ pass
+
+class RecipientPreviousAssignees(object):
+ pass
-class RecipientPreviousAssignees
-class RecipientActualRole
+class RecipientActualRole(object):
+
attributes = (
WorkflowAttribute('roles', 'roles', (),
'Members with this roles get an e-mail.',
required=True, encoding="ascii", datatype=tuple),
)
-class NTask(BaseAssignableActivity):
+class NTask(BaseAssignableActivity):
attributes = BaseAssignableActivity.attributes + (
# XXX The import mechanism for this should be revisited.
(at)(at) -214,7 +226,6 (at)(at)
class PermissionSetting(object):
-
attributes = (WorkflowAttribute('permission', 'name', '',
'The permission affected.',
encoding="ascii", datatype=str),
(at)(at) -243,6 +254,7 (at)(at)
raise ConfigurationError, \
"The permission %r does not exist." % permission
+
class PermissionAddSetting(PermissionSetting):
attributes = (WorkflowAttribute('permission', 'name', '',
(at)(at) -253,6 +265,17 (at)(at)
encoding="ascii", datatype=tuple),
)
+ #########
+ # private
+ security.declarePrivate('_attr_import_permission')
+ def _attr_import_permission(self, attr, node):
+ permission_changes = self.createAndConfigureChildNodes(
+ node, workflow_attributes_registry)
+ self.permission_changes = attr.datatype(permission_changes)
+ for perm in self.permission_changes:
+ perm._validate(self)
+
+
class PermissionRemoveSetting(PermissionSetting):
attributes = (WorkflowAttribute('permission', 'name', '',
(at)(at) -266,7 +289,6 (at)(at)
class Permission(BaseAutomaticActivity):
-
attributes = BaseAutomaticActivity.attributes + (
WorkflowAttribute('permission_changes', '', (),
'Tuple of IPermissionSettings',
(at)(at) -290,10 +312,9 (at)(at)
'called.',
datatype=bool),
)
-
-class RoleAssign(BaseAutomaticActivity):
+class RoleAssign(BaseAutomaticActivity):
attributes = BaseAutomaticActivity.attributes + (
WorkflowAttribute('roles', 'roles', (),
(at)(at) -366,10 +387,8 (at)(at)
class Task(BaseAssignableActivity):
-
attributes = BaseAssignableActivity.attributes + (
WorkflowAttribute('completion_activity', 'completion_activity', (),
'Activity to start after completion.',
encoding="ascii", datatype=tuple),
)
-
Modified: AlphaFlow/trunk/xmlimport/interfaces.py
==============================================================================
--- AlphaFlow/trunk/xmlimport/interfaces.py (original)
+++ AlphaFlow/trunk/xmlimport/interfaces.py Fri Mar 16 14:16:10 2007
(at)(at) -63,44 +63,3 (at)(at)
importHandler="_attr_import_simple",
exportHandler="_attr_export_simple"):
"Constructor."
-
-
-class IRegistry(zope.interface.Interface):
- """Registry for class objects."""
-
- def register(klass):
- """Register a class object on the registry.
-
- The key for searching the class is computed via
self._compute_key(klass)
- If key already exists, its value gets replaced.
-
- klass ... class: object behind key
- Raises ValueError if klass is no class object.
- """
-
- def _compute_key(klass):
- """Compute the search key from a class object.
-
- Each registy implementation can have its own algorithm.
- """
-
- def get(key):
- """Get class object by key.
-
- Raises KeyError if key not found.
- """
-
- def getFromDOMNode(node):
- """Get a class object from data given in DOM-Node.
-
- Which parts of DOM node are taken for getting the key depends on
- implementation.
-
- Raises KeyError if key not found.
- """
-
- def keys():
- """Return the keys in the registry as a list."""
-
- def values():
- """Return the class objects in the registry as a list."""
|
SVN: r4587 - in AlphaFlow/trunk: . activities xmlimport
Christian Theune <ct(at)gocept.com> |
2007-03-16 14:20:50 |
[ FULL ]
|
Author: ctheune
Date: Fri Mar 16 14:20:48 2007
New Revision: 4587
Log:
- moved some import code into the import package
- fixed some superfluous imports
Modified:
AlphaFlow/trunk/__init__.py
AlphaFlow/trunk/activities/configuration.py
AlphaFlow/trunk/activities/notify.py
AlphaFlow/trunk/activities/parent.py
AlphaFlow/trunk/activities/permission.py
AlphaFlow/trunk/activities/switch.py
AlphaFlow/trunk/activity.py
AlphaFlow/trunk/workitem.py
AlphaFlow/trunk/xmlimport/core.py
AlphaFlow/trunk/xmlimport/domimporters.py
Modified: AlphaFlow/trunk/__init__.py
==============================================================================
--- AlphaFlow/trunk/__init__.py (original)
+++ AlphaFlow/trunk/__init__.py Fri Mar 16 14:20:48 2007
(at)(at) -32,13 +32,6 (at)(at)
('Manager', 'Owner'))
-def initialize_activities(context):
- from activities import \
- task, permission, expression, dcworkflow, \
- recursion, notify, alarm, routing, gates, ntask, \
- decision, simpledecision, configuration, parent, switch, roleassign
-
-
def initialize_content(context):
from Products.AlphaFlow import instance
content_types, constructors, ftis = process_types(
(at)(at) -90,7 +83,6 (at)(at)
DirectoryView.registerDirectory(config.SKINS_DIR, config.GLOBALS)
initialize_permissions(context)
initialize_tools(context)
- initialize_activities(context)
initialize_content(context)
initialize_index(context)
Modified: AlphaFlow/trunk/activities/configuration.py
==============================================================================
--- AlphaFlow/trunk/activities/configuration.py (original)
+++ AlphaFlow/trunk/activities/configuration.py Fri Mar 16 14:20:48 2007
(at)(at) -11,9 +11,7 (at)(at)
from Products.AlphaFlow.workitem import BaseAssignableWorkItem, Group
from Products.AlphaFlow.activity import Exit,BaseAssignableActivity
from Products.AlphaFlow import config
-from Products.AlphaFlow.exception import ConfigurationError
from Products.AlphaFlow.action import Action
-from Products.AlphaFlow.importexport import convert_to_xml
class ConfigurationActivity(BaseAssignableActivity):
(at)(at) -100,7 +98,7 (at)(at)
def configure(self, REQUEST=None):
"""Do the configuration of the other activities."""
if self.state != "active":
- raise ValueError, "Can't configure when not active."
+ raise ValueError("Can't configure when not active.")
self.passCheckpoint("complete")
self.changeState("complete", self.getComment())
self.notifyAssigneesChange()
Modified: AlphaFlow/trunk/activities/notify.py
==============================================================================
--- AlphaFlow/trunk/activities/notify.py (original)
+++ AlphaFlow/trunk/activities/notify.py Fri Mar 16 14:20:48 2007
(at)(at) -18,7 +18,6 (at)(at)
unique, listMembersWithRolesAndLocalRoles
from Products.AlphaFlow.workitem import BaseAutomaticWorkItem
from Products.AlphaFlow.activity import BaseAutomaticActivity
-from Products.AlphaFlow.exception import ConfigurationError
from Products.AlphaFlow.interfaces import \
IEMailActivity, IEMailWorkItem, IEMailRecipientMode
Modified: AlphaFlow/trunk/activities/parent.py
==============================================================================
--- AlphaFlow/trunk/activities/parent.py (original)
+++ AlphaFlow/trunk/activities/parent.py Fri Mar 16 14:20:48 2007
(at)(at) -13,12 +13,10 (at)(at)
import zope.component
from AccessControl import ClassSecurityInfo
-from ComputedAttribute import ComputedAttribute
from Products.AlphaFlow.workitem import BaseAutomaticWorkItem, WorkItemExit
from Products.AlphaFlow.activity import Exit, BaseAutomaticActivity
from Products.AlphaFlow.interfaces import \
IParentActivity, IParentWorkItem, IWorkItemExit
-from Products.AlphaFlow import config
class ParentExit(Exit):
Modified: AlphaFlow/trunk/activities/permission.py
==============================================================================
--- AlphaFlow/trunk/activities/permission.py (original)
+++ AlphaFlow/trunk/activities/permission.py Fri Mar 16 14:20:48 2007
(at)(at) -3,8 +3,6 (at)(at)
# $Id$
"""Permission change activity and work item."""
-from warnings import warn
-
import zope.interface
from AccessControl import ClassSecurityInfo
(at)(at) -13,7 +11,6 (at)(at)
from Products.AlphaFlow.workitem import BaseAutomaticWorkItem
from Products.AlphaFlow.activity import BaseAutomaticActivity
from Products.AlphaFlow.utils import modifyRolesForPermission,
addPermissionsToRoles, removePermissionsFromRoles
-from Products.AlphaFlow.exception import ConfigurationError
from Products.AlphaFlow import config
Modified: AlphaFlow/trunk/activities/switch.py
==============================================================================
--- AlphaFlow/trunk/activities/switch.py (original)
+++ AlphaFlow/trunk/activities/switch.py Fri Mar 16 14:20:48 2007
(at)(at) -18,7 +18,7 (at)(at)
from Products.AlphaFlow.workitem import BaseAutomaticWorkItem
from Products.AlphaFlow.activity import BaseAutomaticActivity
from Products.AlphaFlow.interfaces import ISwitchActivity, ISwitchWorkItem
-from Products.AlphaFlow import config, utils
+from Products.AlphaFlow import utils
from Products.AlphaFlow.activity import Exit
Modified: AlphaFlow/trunk/activity.py
==============================================================================
--- AlphaFlow/trunk/activity.py (original)
+++ AlphaFlow/trunk/activity.py Fri Mar 16 14:20:48 2007
(at)(at) -15,8 +15,6 (at)(at)
from Products.AlphaFlow.interfaces import \
IActivity, IAutomaticActivity, IAssignableActivity, IExit
from Products.AlphaFlow import config, utils
-from Products.AlphaFlow.exception import ConfigurationError
-from Products.AlphaFlow.workflowattr import findAttrInAttributes
class Exit(Persistent):
(at)(at) -205,43 +203,5 (at)(at)
members = utils.listMembersWithRoles(role_context, roles)
return members
- security.declarePrivate('_attr_import_assignees')
- def _attr_import_assignees(self, attr, node):
- assignees = node.getElementsByTagName('assignees')
- if len(assignees) == 0:
- # default behaviour
- self.roles = ()
- elif len(assignees) == 1:
- self._parse_assignee(assignees[0])
- else:
- raise ConfigurationError, \
- '<assignees> is only allowed once per activity.'
-
- security.declarePrivate('_parse_assignee')
- def _parse_assignee(self, assignee):
- """helper for _attr_import_assignees
- """
- has = assignee.hasAttribute
- get = assignee.getAttribute
- _import = self._attr_import_simple
- attr = findAttrInAttributes
-
- _import(attr(self, 'assigneesKind'), assignee)
- kind = self.assigneesKind
-
- if has('roles') and has('expression'):
- raise ConfigurationError, \
- '<assignees> can only have one of roles or
expression.'
- if not (has('roles') or has('expression')):
- raise ConfigurationError, \
- '<assignees> must have one of roles or expression.'
- if has('roles'):
- _import(attr(self, 'roles'), assignee)
- if has('expression'):
- if kind == 'possible':
- raise NotImplementedError, \
- "possible/expression is not implemented"
- _import(attr(self, 'assigneesExpression'), assignee)
-
InitializeClass(BaseAssignableActivity)
Modified: AlphaFlow/trunk/workitem.py
==============================================================================
--- AlphaFlow/trunk/workitem.py (original)
+++ AlphaFlow/trunk/workitem.py Fri Mar 16 14:20:48 2007
(at)(at) -5,7 +5,6 (at)(at)
import sys
import os
-from warnings import warn
import zope.interface
import zope.component
Modified: AlphaFlow/trunk/xmlimport/core.py
==============================================================================
--- AlphaFlow/trunk/xmlimport/core.py (original)
+++ AlphaFlow/trunk/xmlimport/core.py Fri Mar 16 14:20:48 2007
(at)(at) -32,10 +32,6 (at)(at)
class ProcessImporter(object):
attributes = (
- WorkflowAttribute('id', 'id', None,
- 'Id of the workflow definition.',
- encoding='ascii', datatype=str,
- importHandler=None)
WorkflowAttribute('title', 'title', '',
'Title of this process definition.',
encoding='utf-8', datatype=str),
Modified: AlphaFlow/trunk/xmlimport/domimporters.py
==============================================================================
--- AlphaFlow/trunk/xmlimport/domimporters.py (original)
+++ AlphaFlow/trunk/xmlimport/domimporters.py Fri Mar 16 14:20:48 2007
(at)(at) -49,6 +49,7 (at)(at)
)
+
class BaseAutomaticActivity(BaseActivity):
attributes = BaseActivity.attributes + (
(at)(at) -79,6 +80,44 (at)(at)
'If empty or unspecified the URL will be determined
the default algorithms.')
)
+ security.declarePrivate('_attr_import_assignees')
+ def _attr_import_assignees(self, attr, node):
+ assignees = node.getElementsByTagName('assignees')
+ if len(assignees) == 0:
+ # default behaviour
+ self.roles = ()
+ elif len(assignees) == 1:
+ self._parse_assignee(assignees[0])
+ else:
+ raise ConfigurationError, \
+ '<assignees> is only allowed once per activity.'
+
+ security.declarePrivate('_parse_assignee')
+ def _parse_assignee(self, assignee):
+ """helper for _attr_import_assignees
+ """
+ has = assignee.hasAttribute
+ get = assignee.getAttribute
+ _import = self._attr_import_simple
+ attr = findAttrInAttributes
+
+ _import(attr(self, 'assigneesKind'), assignee)
+ kind = self.assigneesKind
+
+ if has('roles') and has('expression'):
+ raise ConfigurationError, \
+ '<assignees> can only have one of roles or
expression.'
+ if not (has('roles') or has('expression')):
+ raise ConfigurationError, \
+ '<assignees> must have one of roles or expression.'
+ if has('roles'):
+ _import(attr(self, 'roles'), assignee)
+ if has('expression'):
+ if kind == 'possible':
+ raise NotImplementedError, \
+ "possible/expression is not implemented"
+ _import(attr(self, 'assigneesExpression'), assignee)
+
class Alarm(BaseAutomaticActivity):
|
SVN: r4588 - in AlphaFlow/trunk: activities tests
Christian Theune <ct(at)gocept.com> |
2007-03-16 14:22:54 |
[ FULL ]
|
Author: ctheune
Date: Fri Mar 16 14:22:52 2007
New Revision: 4588
Log:
- fixed imports and remaining references to registry
Modified:
AlphaFlow/trunk/activities/recursion.py
AlphaFlow/trunk/activities/switch.py
AlphaFlow/trunk/activities/task.py
AlphaFlow/trunk/tests/test_definition.py
Modified: AlphaFlow/trunk/activities/recursion.py
==============================================================================
--- AlphaFlow/trunk/activities/recursion.py (original)
+++ AlphaFlow/trunk/activities/recursion.py Fri Mar 16 14:22:52 2007
(at)(at) -157,7 +157,3 (at)(at)
def estimateRelevantUsers(self):
"Estimate the relevant users. Not used for checking."
return ""
-
-
-registerActivity(RecursionActivity)
-registerWorkItem(RecursionWorkItem)
Modified: AlphaFlow/trunk/activities/switch.py
==============================================================================
--- AlphaFlow/trunk/activities/switch.py (original)
+++ AlphaFlow/trunk/activities/switch.py Fri Mar 16 14:22:52 2007
(at)(at) -72,7 +72,3 (at)(at)
return
self.changeState("complete", activity.title_or_id())
-
-
-registerActivity(SwitchActivity)
-registerWorkItem(SwitchWorkItem)
Modified: AlphaFlow/trunk/activities/task.py
==============================================================================
--- AlphaFlow/trunk/activities/task.py (original)
+++ AlphaFlow/trunk/activities/task.py Fri Mar 16 14:22:52 2007
(at)(at) -95,8 +95,3 (at)(at)
def getStatusInfo(self):
"""Returns a short status information text."""
return self.getComment()
-
-
-# register the stuff
-registerActivity(TaskActivity)
-registerWorkItem(TaskWorkItem)
Modified: AlphaFlow/trunk/tests/test_definition.py
==============================================================================
--- AlphaFlow/trunk/tests/test_definition.py (original)
+++ AlphaFlow/trunk/tests/test_definition.py Fri Mar 16 14:22:52 2007
(at)(at) -23,15 +23,14 (at)(at)
from Products.AlphaFlow.interfaces import \
IProcess, IAlphaFlowed, IInstance, IActivity, IExit, IWorkItem, \
- IAutomaticWorkItem, IAction, \
- IWorkflowAttribute, IAssignableActivity, IAutomaticActivity, \
+ IAutomaticWorkItem, IAction, IAssignableActivity, IAutomaticActivity, \
IPermissionSetting
+from Products.AlphaFlow.xmlimport.interfaces import IWorkflowAttribute
from Products.AlphaFlow.workflowedobject import AlphaFlowed
from Products.AlphaFlow.instance import Instance
from Products.AlphaFlow.process import Process
from Products.AlphaFlow.activity import \
- activity_registry, BaseAssignableActivity, \
- BaseActivity, BaseAutomaticActivity, Exit
+ BaseAssignableActivity, BaseActivity, BaseAutomaticActivity, Exit
from Products.AlphaFlow.workitem import \
BaseWorkItem, BaseAutomaticWorkItem, workitem_registry
from Products.AlphaFlow.action import Action
|
SVN: r4589 - in AlphaFlow/trunk: . Extensions activities tests xmlimport
Christian Theune <ct(at)gocept.com> |
2007-03-16 16:32:17 |
[ FULL ]
|
Author: ctheune
Date: Fri Mar 16 16:32:13 2007
New Revision: 4589
Log:
- added interfaces IWorkItemClass and IActivityClass to allow marking
those classes as utilities to replace the former activity_registry and
workitem_registry
Added:
AlphaFlow/trunk/xmlimport/attribute.py
- copied, changed from r4581, AlphaFlow/trunk/xmlimport/workflowattr.py
Removed:
AlphaFlow/trunk/tests/test_registry.py
AlphaFlow/trunk/xmlimport/workflowattr.py
Modified:
AlphaFlow/trunk/Extensions/Install.py
AlphaFlow/trunk/activities/alarm.py
AlphaFlow/trunk/activities/configuration.py
AlphaFlow/trunk/activities/configure.zcml
AlphaFlow/trunk/activities/dcworkflow.py
AlphaFlow/trunk/activities/decision.py
AlphaFlow/trunk/activities/expression.py
AlphaFlow/trunk/activities/gates.py
AlphaFlow/trunk/activities/notify.py
AlphaFlow/trunk/activities/ntask.py
AlphaFlow/trunk/activities/parent.py
AlphaFlow/trunk/activities/permission.py
AlphaFlow/trunk/activities/recursion.py
AlphaFlow/trunk/activities/roleassign.py
AlphaFlow/trunk/activities/routing.py
AlphaFlow/trunk/activities/simpledecision.py
AlphaFlow/trunk/activities/switch.py
AlphaFlow/trunk/activities/task.py
AlphaFlow/trunk/activity.py
AlphaFlow/trunk/interfaces.py
AlphaFlow/trunk/tests/test_definition.py
AlphaFlow/trunk/xmlimport/domimporters.py
Modified: AlphaFlow/trunk/Extensions/Install.py
==============================================================================
--- AlphaFlow/trunk/Extensions/Install.py (original)
+++ AlphaFlow/trunk/Extensions/Install.py Fri Mar 16 16:32:13 2007
(at)(at) -19,12 +19,11 (at)(at)
# $Id$
"""Installer"""
-# Python imports
import os
import logging
from StringIO import StringIO
-# CMF imports
+import zope.component
from Products.CMFCore.utils import getToolByName
from Products.CMFCore import permissions
from Products.Archetypes.Extensions.utils import installTypes
(at)(at) -32,11 +31,10 (at)(at)
from Products.CMFFormController.globalVars import ANY_BUTTON
from Products.CMFFormController.FormAction import FormActionKey
-# Sibling imports
from Products.AlphaFlow import config, migration
-from Products.AlphaFlow.workitem import workitem_registry
from Products.AlphaFlow.utils import modifyRolesForPermission, logger
from Products.AlphaFlow.Extensions import dcworkflow
+from Products.AlphaFlow.interfaces import IWorkItemClass
def upgrade_pre0_7_3(self, out):
(at)(at) -117,7 +115,7 (at)(at)
def install_workitems(self, out):
fc = getToolByName(self, "portal_form_controller")
- for workitem in workitem_registry.values():
+ for name, workitem in zope.component.getUtilitiesFor(IWorkItemClass):
fc.addFormAction('content_edit', 'success', workitem.portal_type,
ANY_BUTTON, 'traverse_to',
'string:af_redirect_to_workitem_action')
(at)(at) -125,7 +123,7 (at)(at)
def uninstall_formcontroller_actions(self, out):
fc = getToolByName(self, "portal_form_controller")
- for workitem in workitem_registry.values():
+ for name, workitem in zope.component.getUtilitiesFor(IWorkItemClass):
# gaah, this API sucks
key = FormActionKey('content_edit', 'success',
workitem.portal_type, ANY_BUTTON)
(at)(at) -176,7 +174,7 (at)(at)
# type/catalog mapping
at = getToolByName(self, "archetype_tool")
at.setCatalogsByType('Instance', ['workflow_catalog'])
- for workitem in workitem_registry.values():
+ for name, workitem in zope.component.getUtilitiesFor(IWorkItemClass):
at.setCatalogsByType(workitem.meta_type, ["workflow_catalog"])
if added:
Modified: AlphaFlow/trunk/activities/alarm.py
==============================================================================
--- AlphaFlow/trunk/activities/alarm.py (original)
+++ AlphaFlow/trunk/activities/alarm.py Fri Mar 16 16:32:13 2007
(at)(at) -9,13 +9,15 (at)(at)
from Products.AlphaFlow.workitem import BaseAutomaticWorkItem
from Products.AlphaFlow.activity import BaseAutomaticActivity
-from Products.AlphaFlow.interfaces import IAlarmActivity, IAlarmWorkItem
+from Products.AlphaFlow.interfaces import \
+ IAlarmActivity, IAlarmWorkItem, IActivityClass, IWorkItemClass
from Products.AlphaFlow import config, utils
class AlarmActivity(BaseAutomaticActivity):
zope.interface.implements(IAlarmActivity)
+ zope.interface.classProvides(IActivityClass)
meta_type = "AlphaFlow Alarm Activity"
activity_type = "alarm"
(at)(at) -25,6 +27,7 (at)(at)
class AlarmWorkItem(BaseAutomaticWorkItem):
zope.interface.implements(IAlarmWorkItem)
+ zope.interface.classProvides(IWorkItemClass)
security = ClassSecurityInfo()
Modified: AlphaFlow/trunk/activities/configuration.py
==============================================================================
--- AlphaFlow/trunk/activities/configuration.py (original)
+++ AlphaFlow/trunk/activities/configuration.py Fri Mar 16 16:32:13 2007
(at)(at) -7,7 +7,8 (at)(at)
from AccessControl import ClassSecurityInfo
from Products.AlphaFlow.interfaces import \
- IConfigurationActivity, IConfigurationWorkItem
+ IConfigurationActivity, IConfigurationWorkItem, \
+ IActivityClass, IWorkItemClass
from Products.AlphaFlow.workitem import BaseAssignableWorkItem, Group
from Products.AlphaFlow.activity import Exit,BaseAssignableActivity
from Products.AlphaFlow import config
(at)(at) -17,6 +18,7 (at)(at)
class ConfigurationActivity(BaseAssignableActivity):
zope.interface.implements(IConfigurationActivity)
+ zope.interface.classProvides(IActivityClass)
security = ClassSecurityInfo()
(at)(at) -33,12 +35,13 (at)(at)
class ConfigurationWorkItem(BaseAssignableWorkItem):
zope.interface.implements(IConfigurationWorkItem)
+ zope.interface.classProvides(IWorkItemClass)
security = ClassSecurityInfo()
activity_type = "configuration"
- # XXX security declatration?
+ # XXX security declaration?
def Schema(self):
instance = self.getInstance()
other = instance.Schema()
Modified: AlphaFlow/trunk/activities/configure.zcml
==============================================================================
--- AlphaFlow/trunk/activities/configure.zcml (original)
+++ AlphaFlow/trunk/activities/configure.zcml Fri Mar 16 16:32:13 2007
(at)(at) -8,4 +8,203 (at)(at)
provides=".interfaces.IWorkItemExit"
/>
+ <!-- All activity classes are registered as named
+ utilities for IActivityClass to make them queryable.
+ -->
+
+ <utility
+ component=".alarm.AlarmActivity"
+ name="alarm"
+ provides="..interfaces.IActivityClass"
+ />
+
+ <utility
+ component=".configuration.ConfigurationActivity"
+ name="configuration"
+ provides="..interfaces.IActivityClass"
+ />
+
+ <utility
+ component=".dcworkflow.DCWorkFlowActivity"
+ name="dcworkflow"
+ provides="..interfaces.IActivityClass"
+ />
+
+ <utility
+ component=".decision.DecisionActivity"
+ name="decision"
+ provides="..interfaces.IActivityClass"
+ />
+
+ <utility
+ component=".expression.ExpressionActivity"
+ name="expression"
+ provides="..interfaces.IActivityClass"
+ />
+
+ <utility
+ component=".gates.GateActivity"
+ name="gate"
+ provides="..interfaces.IActivityClass"
+ />
+
+ <utility
+ component=".notify.EMailActivity"
+ name="email"
+ provides="..interfaces.IActivityClass"
+ />
+
+ <utility
+ component=".ntask.NTaskActivity"
+ name="ntask"
+ provides="..interfaces.IActivityClass"
+ />
+
+ <utility
+ component=".parent.ParentActivity"
+ name="parent"
+ provides="..interfaces.IActivityClass"
+ />
+
+ <utility
+ component=".permission.PermissionActivity"
+ name="permission"
+ provides="..interfaces.IActivityClass"
+ />
+
+ <utility
+ component=".recursion.RecursionActivity"
+ name="recursion"
+ provides="..interfaces.IActivityClass"
+ />
+
+ <utility
+ component=".roleassign.RoleAssignActivity"
+ name="roleassign"
+ provides="..interfaces.IActivityClass"
+ />
+
+ <utility
+ component=".routing.RoutingActivity"
+ name="route"
+ provides="..interfaces.IActivityClass"
+ />
+
+ <utility
+ component=".simpledecision.SimpleDecisionActivity"
+ name="simpledecision"
+ provides="..interfaces.IActivityClass"
+ />
+
+ <utility
+ component=".switch.SwitchActivity"
+ name="switch"
+ provides="..interfaces.IActivityClass"
+ />
+
+ <utility
+ component=".task.TaskActivity"
+ name="task"
+ provides="..interfaces.IActivityClass"
+ />
+
+ !-- All work item classes are registered as named
+ utilities for IWorkItemClass to make them queryable.
+ ->
+ <utility
+ component=".alarm.AlarmWorkItem"
+ name="alarm"
+ provides="..interfaces.IWorkItemClass"
+ />
+
+ <utility
+ component=".configuration.ConfigurationWorkItem"
+ name="configuration"
+ provides="..interfaces.IWorkItemClass"
+ />
+
+ <utility
+ component=".dcworkflow.DCWorkFlowWorkItem"
+ name="dcworkflow"
+ provides="..interfaces.IWorkItemClass"
+ />
+
+ <utility
+ component=".decision.DecisionWorkItem"
+ name="decision"
+ provides="..interfaces.IWorkItemClass"
+ />
+
+ <utility
+ component=".expression.ExpressionWorkItem"
+ name="expression"
+ provides="..interfaces.IWorkItemClass"
+ />
+
+ <utility
+ component=".gates.GateWorkItem"
+ name="gate"
+ provides="..interfaces.IWorkItemClass"
+ />
+
+ <utility
+ component=".notify.EMailWorkItem"
+ name="email"
+ provides="..interfaces.IWorkItemClass"
+ />
+
+ <utility
+ component=".ntask.NTaskWorkItem"
+ name="ntask"
+ provides="..interfaces.IWorkItemClass"
+ />
+
+ <utility
+ component=".parent.ParentWorkItem"
+ name="parent"
+ provides="..interfaces.IWorkItemClass"
+ />
+
+ <utility
+ component=".permission.PermissionWorkItem"
+ name="permission"
+ provides="..interfaces.IWorkItemClass"
+ />
+
+ <utility
+ component=".recursion.RecursionWorkItem"
+ name="recursion"
+ provides="..interfaces.IWorkItemClass"
+ />
+
+ <utility
+ component=".roleassign.RoleAssignWorkItem"
+ name="roleassign"
+ provides="..interfaces.IWorkItemClass"
+ />
+
+ <utility
+ component=".routing.RoutingWorkItem"
+ name="route"
+ provides="..interfaces.IWorkItemClass"
+ />
+
+ <utility
+ component=".simpledecision.SimpleDecisionWorkItem"
+ name="simpledecision"
+ provides="..interfaces.IWorkItemClass"
+ />
+
+ <utility
+ component=".switch.SwitchWorkItem"
+ name="switch"
+ provides="..interfaces.IWorkItemClass"
+ />
+
+ <utility
+ component=".task.TaskWorkItem"
+ name="task"
+ provides="..interfaces.IWorkItemClass"
+ />
+
</configure>
Modified: AlphaFlow/trunk/activities/dcworkflow.py
==============================================================================
--- AlphaFlow/trunk/activities/dcworkflow.py (original)
+++ AlphaFlow/trunk/activities/dcworkflow.py Fri Mar 16 16:32:13 2007
(at)(at) -11,7 +11,8 (at)(at)
from Products.AlphaFlow.workitem import BaseAutomaticWorkItem
from Products.AlphaFlow.activity import BaseAutomaticActivity
-from Products.AlphaFlow.interfaces import IDCWorkFlowActivity
+from Products.AlphaFlow.interfaces import \
+ IDCWorkFlowActivity, IActivityClass, IWorkItemClass
class WorkflowHistoryFake(dict):
(at)(at) -27,18 +28,17 (at)(at)
class DCWorkFlowActivity(BaseAutomaticActivity):
zope.interface.implements(IDCWorkFlowActivity)
+ zope.interface.classProvides(IActivityClass)
meta_type = "AlphaFlow DCWorkFlow Activity"
activity_type = "dcworkflow"
icon = "misc_/AlphaFlow/dcworkflow"
- _properties = BaseAutomaticActivity._properties + \
- ({'id': 'status', 'type': 'text', 'mode': 'w'},
- )
-
class DCWorkFlowWorkItem(BaseAutomaticWorkItem):
+ zope.interface.classProvides(IWorkItemClass)
+
security = ClassSecurityInfo()
activity_type = "dcworkflow"
Modified: AlphaFlow/trunk/activities/decision.py
==============================================================================
--- AlphaFlow/trunk/activities/decision.py (original)
+++ AlphaFlow/trunk/activities/decision.py Fri Mar 16 16:32:13 2007
(at)(at) -8,7 +8,9 (at)(at)
from Products.Archetypes import public as atapi
-from Products.AlphaFlow.interfaces import IDecisionActivity, IDecisionWorkItem
+from Products.AlphaFlow.interfaces import \
+ IDecisionActivity, IDecisionWorkItem, \
+ IActivityClass, IWorkItemClass
from Products.AlphaFlow.workitem import BaseAssignableWorkItem
from Products.AlphaFlow.activity import Exit, BaseAssignableActivity
from Products.AlphaFlow import config
(at)(at) -23,6 +25,7 (at)(at)
"""
zope.interface.implements(IDecisionActivity)
+ zope.interface.classProvides(IActivityClass)
security = ClassSecurityInfo()
(at)(at) -35,16 +38,6 (at)(at)
# configurationschema gets modified by __init__!
configurationSchema = BaseAssignableActivity.configurationSchema.copy()
- _properties = BaseAssignableActivity._properties + \
- ({'id': 'decision_notice', 'type': 'text', 'mode': 'w'},
- {'id': 'reject_activity', 'type': 'multiple selection',
- 'mode': 'w', 'select_variable': 'listActivityIds'},
- {'id': 'accept_activity', 'type': 'multiple selection',
- 'mode': 'w', 'select_variable': 'listActivityIds'},
- {'id': 'decision_modus', 'type': 'selection',
- 'mode': 'w', 'select_variable': 'known_decision_modi',},
- )
-
security.declareProtected(config.EDIT_WORKFLOW, '__init__')
def __init__(self, id):
DecisionActivity.inheritedAttribute('__init__')(self, id)
(at)(at) -78,12 +71,12 (at)(at)
class DecisionWorkItem(BaseAssignableWorkItem):
zope.interface.implements(IDecisionWorkItem)
+ zope.interface.classProvides(IWorkItemClass)
activity_type = "decision"
security = ClassSecurityInfo()
decisions = None
-
###########
# IWorkItem
Modified: AlphaFlow/trunk/activities/expression.py
==============================================================================
--- AlphaFlow/trunk/activities/expression.py (original)
+++ AlphaFlow/trunk/activities/expression.py Fri Mar 16 16:32:13 2007
(at)(at) -9,7 +9,8 (at)(at)
from Products.AlphaFlow.workitem import BaseAutomaticWorkItem
from Products.AlphaFlow.activity import BaseAutomaticActivity
from Products.AlphaFlow.interfaces import \
- IExpressionActivity, IExpressionWorkItem
+ IExpressionActivity, IExpressionWorkItem, \
+ IActivityClass, IWorkItemClass
from Products.AlphaFlow.utils import evaluateTales, evaluateTalesAs
(at)(at) -17,6 +18,7 (at)(at)
class ExpressionActivity(BaseAutomaticActivity):
zope.interface.implements(IExpressionActivity)
+ zope.interface.classProvides(IActivityClass)
meta_type = "AlphaFlow Expression Activity"
activity_type = "expression"
(at)(at) -26,6 +28,7 (at)(at)
class ExpressionWorkItem(BaseAutomaticWorkItem):
zope.interface.implements(IExpressionWorkItem)
+ zope.interface.classProvides(IWorkItemClass)
security = ClassSecurityInfo()
Modified: AlphaFlow/trunk/activities/gates.py
==============================================================================
--- AlphaFlow/trunk/activities/gates.py (original)
+++ AlphaFlow/trunk/activities/gates.py Fri Mar 16 16:32:13 2007
(at)(at) -10,7 +10,8 (at)(at)
from Products.AlphaFlow.workitem import BaseWorkItem
from Products.AlphaFlow.activity import BaseAutomaticActivity
from Products.AlphaFlow.interfaces import \
- IDaemonActivity, IGateActivity, IGateWorkItem
+ IDaemonActivity, IGateActivity, IGateWorkItem, \
+ IActivityClass, IWorkItemClass
from Products.AlphaFlow import config
(at)(at) -23,6 +24,7 (at)(at)
class GateActivity(BaseAutomaticActivity):
zope.interface.implements(IDaemonActivity, IGateActivity)
+ zope.interface.classProvides(IActivityClass)
meta_type = "AlphaFlow Gate Activity"
activity_type = "gate"
(at)(at) -33,13 +35,6 (at)(at)
# - Delayed-Discriminate is like "XOR" but waits with trigger until
# all other routes are completed on their own.
# - Synchronize is like "AND" (trigger once when all completed)
- mode_types = (MULTI_MERGE, DISCRIMINATE, DELAYED_DISCRIMINATE,
- SYNCHRONIZING_MERGE,)
-
- _properties = BaseAutomaticActivity._properties + \
- ({'id': 'mode', 'type': 'selection', 'mode': 'w',
- 'select_variable': 'mode_types'},
- )
class GateWorkItem(BaseWorkItem):
(at)(at) -47,6 +42,7 (at)(at)
security = ClassSecurityInfo()
zope.interface.implements(IGateWorkItem)
+ zope.interface.classProvides(IWorkItemClass)
activity_type = "gate"
Modified: AlphaFlow/trunk/activities/notify.py
==============================================================================
--- AlphaFlow/trunk/activities/notify.py (original)
+++ AlphaFlow/trunk/activities/notify.py Fri Mar 16 16:32:13 2007
(at)(at) -19,12 +19,14 (at)(at)
from Products.AlphaFlow.workitem import BaseAutomaticWorkItem
from Products.AlphaFlow.activity import BaseAutomaticActivity
from Products.AlphaFlow.interfaces import \
- IEMailActivity, IEMailWorkItem, IEMailRecipientMode
+ IEMailActivity, IEMailWorkItem, IEMailRecipientMode, \
+ IActivityClass, IWorkItemClass
class EMailActivity(BaseAutomaticActivity):
zope.interface.implements(IEMailActivity)
+ zope.interface.classProvides(IActivityClass)
security = ClassSecurityInfo()
(at)(at) -32,12 +34,6 (at)(at)
activity_type = "email"
icon = "misc_/AlphaFlow/email"
- _properties = BaseAutomaticActivity._properties + \
- ({'id': 'template', 'type': 'string', 'mode': 'w',},
- {'id': 'mailSubject', 'type': 'ustring', 'mode': 'w'},
- )
-
-
security.declarePrivate('getRecipientModes')
def getRecipientModes(self):
"Return list of IEMailRecipientMode instances (possible recipents)."
(at)(at) -47,6 +43,7 (at)(at)
class EMailWorkItem(BaseAutomaticWorkItem):
zope.interface.implements(IEMailWorkItem)
+ zope.interface.classProvides(IWorkItemClass)
security = ClassSecurityInfo()
Modified: AlphaFlow/trunk/activities/ntask.py
==============================================================================
--- AlphaFlow/trunk/activities/ntask.py (original)
+++ AlphaFlow/trunk/activities/ntask.py Fri Mar 16 16:32:13 2007
(at)(at) -8,7 +8,8 (at)(at)
from Products.Archetypes import public as atapi
-from Products.AlphaFlow.interfaces import INTaskActivity, INTaskWorkItem
+from Products.AlphaFlow.interfaces import \
+ INTaskActivity, INTaskWorkItem, IActivityClass, IWorkItemClass
from Products.AlphaFlow.workitem import BaseAssignableWorkItem
from Products.AlphaFlow.activity import BaseAssignableActivity
from Products.AlphaFlow import config
(at)(at) -18,6 +19,7 (at)(at)
class NTaskActivity(BaseAssignableActivity):
zope.interface.implements(INTaskActivity)
+ zope.interface.classProvides(IActivityClass)
security = ClassSecurityInfo()
(at)(at) -47,6 +49,7 (at)(at)
class NTaskWorkItem(BaseAssignableWorkItem):
zope.interface.implements(INTaskWorkItem)
+ zope.interface.classProvides(IWorkItemClass)
security = ClassSecurityInfo()
Modified: AlphaFlow/trunk/activities/parent.py
==============================================================================
--- AlphaFlow/trunk/activities/parent.py (original)
+++ AlphaFlow/trunk/activities/parent.py Fri Mar 16 16:32:13 2007
(at)(at) -16,7 +16,8 (at)(at)
from Products.AlphaFlow.workitem import BaseAutomaticWorkItem, WorkItemExit
from Products.AlphaFlow.activity import Exit, BaseAutomaticActivity
from Products.AlphaFlow.interfaces import \
- IParentActivity, IParentWorkItem, IWorkItemExit
+ IParentActivity, IParentWorkItem, IWorkItemExit, \
+ IActivityClass, IWorkItemClass
class ParentExit(Exit):
(at)(at) -47,6 +48,7 (at)(at)
class ParentActivity(BaseAutomaticActivity):
zope.interface.implements(IParentActivity)
+ zope.interface.classProvides(IActivityClass)
security = ClassSecurityInfo()
(at)(at) -97,6 +99,7 (at)(at)
class ParentWorkItem(BaseAutomaticWorkItem):
zope.interface.implements(IParentWorkItem)
+ zope.interface.classProvides(IWorkItemClass)
security = ClassSecurityInfo()
Modified: AlphaFlow/trunk/activities/permission.py
==============================================================================
--- AlphaFlow/trunk/activities/permission.py (original)
+++ AlphaFlow/trunk/activities/permission.py Fri Mar 16 16:32:13 2007
(at)(at) -7,10 +7,12 (at)(at)
from AccessControl import ClassSecurityInfo
from Products.AlphaFlow.interfaces import \
- IPermissionActivity, IPermissionWorkItem, IPermissionSetting
+ IPermissionActivity, IPermissionWorkItem, IPermissionSetting, \
+ IActivityClass, IWorkItemClass
from Products.AlphaFlow.workitem import BaseAutomaticWorkItem
from Products.AlphaFlow.activity import BaseAutomaticActivity
-from Products.AlphaFlow.utils import modifyRolesForPermission,
addPermissionsToRoles, removePermissionsFromRoles
+from Products.AlphaFlow.utils import \
+ modifyRolesForPermission, addPermissionsToRoles,
removePermissionsFromRoles
from Products.AlphaFlow import config
(at)(at) -41,6 +43,7 (at)(at)
class PermissionActivity(BaseAutomaticActivity):
zope.interface.implements(IPermissionActivity)
+ zope.interface.classProvides(IActivityClass)
security = ClassSecurityInfo()
(at)(at) -65,6 +68,7 (at)(at)
class PermissionWorkItem(BaseAutomaticWorkItem):
zope.interface.implements(IPermissionWorkItem)
+ zope.interface.classProvides(IWorkItemClass)
security = ClassSecurityInfo()
Modified: AlphaFlow/trunk/activities/recursion.py
==============================================================================
--- AlphaFlow/trunk/activities/recursion.py (original)
+++ AlphaFlow/trunk/activities/recursion.py Fri Mar 16 16:32:13 2007
(at)(at) -16,12 +16,14 (at)(at)
from Products.AlphaFlow.workitem import BaseAutomaticWorkItem
from Products.AlphaFlow.activity import Exit, BaseAutomaticActivity
from Products.AlphaFlow import config, utils
-from Products.AlphaFlow.interfaces import IDaemonActivity
+from Products.AlphaFlow.interfaces import \
+ IDaemonActivity, IActivityClass, IWorkItemClass
class RecursionActivity(BaseAutomaticActivity):
zope.interface.implements(IDaemonActivity)
+ zope.interface.classProvides(IActivityClass)
security = ClassSecurityInfo()
(at)(at) -38,14 +40,6 (at)(at)
)),
))
- _properties = BaseAutomaticActivity._properties + \
- ({'id': 'recursion_activity', 'type': 'multiple selection',
- 'mode': 'w', 'select_variable': 'listActivityIds'},
- {'id': 'optional_recursion', 'type': 'boolean', 'mode':'w'},
- {'id': 'break_activities', 'type':'multiple selection',
- 'mode':'w', 'select_variable':'listActivityIds'}
- )
-
def getExits(self):
exits = {}
exits['recursion'] = Exit("recursion", self.recursion_activity)
(at)(at) -74,9 +68,10 (at)(at)
return schema
-
class RecursionWorkItem(BaseAutomaticWorkItem):
+ zope.interface.classProvides(IWorkItemClass)
+
security = ClassSecurityInfo()
activity_type = "recursion"
Modified: AlphaFlow/trunk/activities/roleassign.py
==============================================================================
--- AlphaFlow/trunk/activities/roleassign.py (original)
+++ AlphaFlow/trunk/activities/roleassign.py Fri Mar 16 16:32:13 2007
(at)(at) -13,12 +13,13 (at)(at)
from Products.AlphaFlow.activity import BaseAutomaticActivity
from Products.AlphaFlow import config
from Products.AlphaFlow.activities.interfaces import \
- IRoleAssignActivity, IRoleAssignWorkItem
+ IRoleAssignActivity, IRoleAssignWorkItem, IActivityClass, IWorkItemClass
class RoleAssignActivity(BaseAutomaticActivity):
zope.interface.implements(IRoleAssignActivity)
+ zope.interface.classProvides(IActivityClass)
security = ClassSecurityInfo()
(at)(at) -67,6 +68,7 (at)(at)
class RoleAssignWorkItem(BaseAutomaticWorkItem):
zope.interface.implements(IRoleAssignWorkItem)
+ zope.interface.classProvides(IWorkItemClass)
security = ClassSecurityInfo()
Modified: AlphaFlow/trunk/activities/routing.py
==============================================================================
--- AlphaFlow/trunk/activities/routing.py (original)
+++ AlphaFlow/trunk/activities/routing.py Fri Mar 16 16:32:13 2007
(at)(at) -12,7 +12,7 (at)(at)
from Products.AlphaFlow import config
from Products.AlphaFlow.utils import killWorkItemRecursively
from Products.AlphaFlow.interfaces import \
- IRoutingActivity, IRoutingWorkItem
+ IRoutingActivity, IRoutingWorkItem, IActivityClass, IWorkItemClass
class RoutingActivity(BaseActivity):
(at)(at) -28,8 +28,9 (at)(at)
offsprings from this routing activity will be controlled by the gates of
this routing activity.
"""
-
+
zope.interface.implements(IRoutingActivity)
+ zope.interface.classProvides(IActivityClass)
security = ClassSecurityInfo()
(at)(at) -53,6 +54,7 (at)(at)
class RoutingWorkItem(BaseWorkItem):
zope.interface.implements(IRoutingWorkItem)
+ zope.interface.classProvides(IWorkItemClass)
security = ClassSecurityInfo()
Modified: AlphaFlow/trunk/activities/simpledecision.py
==============================================================================
--- AlphaFlow/trunk/activities/simpledecision.py (original)
+++ AlphaFlow/trunk/activities/simpledecision.py Fri Mar 16 16:32:13 2007
(at)(at) -12,7 +12,8 (at)(at)
from Products.CMFCore.utils import getToolByName
from Products.AlphaFlow.interfaces import \
- ISimpleDecisionActivity, IDecisionWorkItem, IWorkItemFactory
+ ISimpleDecisionActivity, IDecisionWorkItem, IWorkItemFactory, \
+ IActivityClass, IWorkItemClass
from Products.AlphaFlow.workitem import BaseAssignableWorkItem
from Products.AlphaFlow.activity import Exit, BaseAssignableActivity
from Products.AlphaFlow import config, utils
(at)(at) -44,6 +45,7 (at)(at)
"""
zope.interface.implements(ISimpleDecisionActivity)
+ zope.interface.classProvides(IActivityClass)
security = ClassSecurityInfo()
(at)(at) -114,6 +116,7 (at)(at)
class SimpleDecisionWorkItem(BaseAssignableWorkItem):
zope.interface.implements(IDecisionWorkItem)
+ zope.interface.classProvides(IWorkItemClass)
activity_type = "simpledecision"
security = ClassSecurityInfo()
Modified: AlphaFlow/trunk/activities/switch.py
==============================================================================
--- AlphaFlow/trunk/activities/switch.py (original)
+++ AlphaFlow/trunk/activities/switch.py Fri Mar 16 16:32:13 2007
(at)(at) -17,7 +17,8 (at)(at)
from Products.AlphaFlow.workitem import BaseAutomaticWorkItem
from Products.AlphaFlow.activity import BaseAutomaticActivity
-from Products.AlphaFlow.interfaces import ISwitchActivity, ISwitchWorkItem
+from Products.AlphaFlow.interfaces import \
+ ISwitchActivity, ISwitchWorkItem, IActivityClass, IWorkItemClass
from Products.AlphaFlow import utils
from Products.AlphaFlow.activity import Exit
(at)(at) -28,6 +29,7 (at)(at)
class SwitchActivity(BaseAutomaticActivity):
zope.interface.implements(ISwitchActivity)
+ zope.interface.classProvides(IActivityClass)
security = ClassSecurityInfo()
(at)(at) -43,6 +45,7 (at)(at)
class SwitchWorkItem(BaseAutomaticWorkItem):
zope.interface.implements(ISwitchWorkItem)
+ zope.interface.classProvides(IWorkItemClass)
security = ClassSecurityInfo()
Modified: AlphaFlow/trunk/activities/task.py
==============================================================================
--- AlphaFlow/trunk/activities/task.py (original)
+++ AlphaFlow/trunk/activities/task.py Fri Mar 16 16:32:13 2007
(at)(at) -8,7 +8,8 (at)(at)
from Products.Archetypes import public as atapi
-from Products.AlphaFlow.interfaces import ITaskActivity, ITaskWorkItem
+from Products.AlphaFlow.interfaces import \
+ ITaskActivity, ITaskWorkItem, IActivityClass, IWorkItemClass
from Products.AlphaFlow.workitem import BaseAssignableWorkItem
from Products.AlphaFlow.activity import Exit, BaseAssignableActivity
from Products.AlphaFlow import config
(at)(at) -18,11 +19,12 (at)(at)
class TaskActivity(BaseAssignableActivity):
zope.interface.implements(ITaskActivity)
+ zope.interface.classProvides(IActivityClass)
security = ClassSecurityInfo()
meta_type = "AlphaFlow Task Activity"
- activity_type = nodeName = "task"
+ activity_type = "task"
icon = "misc_/AlphaFlow/task"
configurationSchema = atapi.Schema((
(at)(at) -36,13 +38,6 (at)(at)
)),
)) + BaseAssignableActivity.configurationSchema
- _properties = BaseAssignableActivity._properties + \
- ({'id': 'completion_activity',
- 'type': 'multiple selection',
- 'mode': 'r',
- 'select_variable': 'listActivityIds'},
- )
-
def getExits(self):
exits = {}
exits["complete"] = Exit("complete", self.completion_activity)
(at)(at) -52,6 +47,7 (at)(at)
class TaskWorkItem(BaseAssignableWorkItem):
zope.interface.implements(ITaskWorkItem)
+ zope.interface.classProvides(IWorkItemClass)
security = ClassSecurityInfo()
Modified: AlphaFlow/trunk/activity.py
==============================================================================
--- AlphaFlow/trunk/activity.py (original)
+++ AlphaFlow/trunk/activity.py Fri Mar 16 16:32:13 2007
(at)(at) -13,7 +13,8 (at)(at)
from Products.Archetypes import public as atapi
from Products.AlphaFlow.interfaces import \
- IActivity, IAutomaticActivity, IAssignableActivity, IExit
+ IActivity, IAutomaticActivity, IAssignableActivity, IExit, \
+ IActivityClass
from Products.AlphaFlow import config, utils
Modified: AlphaFlow/trunk/interfaces.py
==============================================================================
--- AlphaFlow/trunk/interfaces.py (original)
+++ AlphaFlow/trunk/interfaces.py Fri Mar 16 16:32:13 2007
(at)(at) -214,6 +214,14 (at)(at)
"""returns the process definition from the acquisition chain"""
+class IActivityClass(zope.interface.Interface):
+ """A marker interface to allow registration of all activity classes."""
+
+
+class IWorkItemClass(zope.interface.Interface):
+ """A marker interface to allow registration of all work item classes."""
+
+
class IActivity(zope.interface.Interface):
"""A workflow activity.
Modified: AlphaFlow/trunk/tests/test_definition.py
==============================================================================
--- AlphaFlow/trunk/tests/test_definition.py (original)
+++ AlphaFlow/trunk/tests/test_definition.py Fri Mar 16 16:32:13 2007
(at)(at) -26,23 +26,20 (at)(at)
IAutomaticWorkItem, IAction, IAssignableActivity, IAutomaticActivity, \
IPermissionSetting
from Products.AlphaFlow.xmlimport.interfaces import IWorkflowAttribute
+from Products.AlphaFlow.xmlimport.attribute import WorkflowAttribute
+from Products.AlphaFlow.xmlimport.domimporters import findAttrInAttributes
from Products.AlphaFlow.workflowedobject import AlphaFlowed
from Products.AlphaFlow.instance import Instance
from Products.AlphaFlow.process import Process
from Products.AlphaFlow.activity import \
BaseAssignableActivity, BaseActivity, BaseAutomaticActivity, Exit
from Products.AlphaFlow.workitem import \
- BaseWorkItem, BaseAutomaticWorkItem, workitem_registry
+ BaseWorkItem, BaseAutomaticWorkItem
from Products.AlphaFlow.action import Action
from Products.AlphaFlow.activities.permission import PermissionSetting
from Products.AlphaFlow.activities.decision import DecisionWorkItem
from Products.AlphaFlow.utils import flexSplit
from Products.AlphaFlow.exception import ConfigurationError
-from Products.AlphaFlow.workflowattr import \
- WorkflowAttribute, findAttrInAttributes, \
- workflow_attributes_registry
-from Products.AlphaFlow.importexport import convert_to_xml
-from Products.AlphaFlow.activities.notify import notify_registry
from Products.AlphaFlow.exception import UnknownActivityError
(at)(at) -84,11 +81,13 (at)(at)
(IExit, Exit),
(IActivity, BaseActivity),
(IAutomaticActivity, BaseAutomaticActivity),
- (IPermissionSetting, PermissionSetting)] + \
- [(IActivity, activity_registry.get(act_id))
- for act_id in activity_registry.keys() ] + \
- [(IWorkItem, workitem_registry.get(wi_id))
- for wi_id in workitem_registry.keys()]
+ (IPermissionSetting, PermissionSetting)]
+
+
+ # XXX [(IActivity, activity_registry.get(act_id))
+ # for act_id in activity_registry.keys() ] + \
+ # [(IWorkItem, workitem_registry.get(wi_id))
+ # for wi_id in workitem_registry.keys()]
def _check_DOM_equality(self, exp_dom, got_dom, wf_name):
"""Check, if two DOMs are equal
(at)(at) -132,8 +131,6 (at)(at)
def _filter_relevant_attrs(self, node):
"Get a sorted list of the relevant (not empty, not default)
attributes."
- registries = [activity_registry, workflow_attributes_registry,
- notify_registry]
act_attrs = None
nodeName = node.nodeName
for registry in registries:
(at)(at) -747,6 +744,19 (at)(at)
self.assertEqual(1, len(fallout_workitems))
self.assertEqual('become_fallout', fallout_workitems[0].activity_id)
+def convert_to_xml(value):
+ """Convert a value to XML notation."""
+ if isinstance(value, basestring):
+ return value
+ elif isinstance(value, tuple) or isinstance(value, list):
+ return ' '.join(value)
+ elif isinstance(value, bool):
+ return value and 'true' or 'false'
+ elif isinstance(value, int):
+ return str(value)
+ elif value is None:
+ return ''
+ raise ValueError, "Don't know how to handle '%s'." % value
def test_suite():
suite = unittest.TestSuite()
Copied: AlphaFlow/trunk/xmlimport/attribute.py (from r4581,
AlphaFlow/trunk/xmlimport/workflowattr.py)
==============================================================================
--- AlphaFlow/trunk/xmlimport/workflowattr.py (original)
+++ AlphaFlow/trunk/xmlimport/attribute.py Fri Mar 16 16:32:13 2007
(at)(at) -5,8 +5,7 (at)(at)
import zope.interface
-from Products.AlphaFlow.interfaces import IWorkflowAttribute
-from Products.AlphaFlow.registry import Registry
+from Products.AlphaFlow.xmlimport.interfaces import IWorkflowAttribute
class WorkflowAttribute(object):
Modified: AlphaFlow/trunk/xmlimport/domimporters.py
==============================================================================
--- AlphaFlow/trunk/xmlimport/domimporters.py (original)
+++ AlphaFlow/trunk/xmlimport/domimporters.py Fri Mar 16 16:32:13 2007
(at)(at) -3,6 +3,8 (at)(at)
# $Id$
"""DOM importers for the built-in workflow objects."""
+from Products.AlphaFlow.xmlimport.attribute import \
+ WorkflowAttribute, ConfiguresAttribute, RecipientsAttribute
class Exit(object):
(at)(at) -56,7 +58,7 (at)(at)
WorkflowAttribute('continue_activity', 'continue_activity', (),
'A list of activities that follow this'
'automatic activity. (single exit)',
- encoding='ascii', datatype=tuple))
+ encoding='ascii', datatype=tuple),)
class BaseAssignableActivity(BaseActivity):
(at)(at) -73,14 +75,12 (at)(at)
WorkflowAttribute('assigneesKind', 'kind', 'possible',
'Defines the user assignment method, either '
'"possible" or "actual".',
- required=True, vocabulary=['actual', 'possible'],
- importHandler="_attr_import_assignees"),
+ required=True, vocabulary=['actual', 'possible']),
WorkflowAttribute('completionUrlExpression', 'completion_url_expr',
None,
'(TALES Expression) URL to redirect a user to after
completing the workitem.'
'If empty or unspecified the URL will be determined
the default algorithms.')
)
- security.declarePrivate('_attr_import_assignees')
def _attr_import_assignees(self, attr, node):
assignees = node.getElementsByTagName('assignees')
if len(assignees) == 0:
(at)(at) -92,7 +92,6 (at)(at)
raise ConfigurationError, \
'<assignees> is only allowed once per activity.'
- security.declarePrivate('_parse_assignee')
def _parse_assignee(self, assignee):
"""helper for _attr_import_assignees
"""
(at)(at) -158,6 +157,8 (at)(at)
class Decision(BaseAssignableActivity):
+ known_decision_modi = ['first_yes', 'all_yes']
+
attributes = BaseAssignableActivity.attributes + (
WorkflowAttribute('decision_notice', 'decision_notice', '',
'Describing the task for the decision.'),
(at)(at) -185,9 +186,14 (at)(at)
required=False),
)
+from Products.AlphaFlow.activities.gates import \
+ MULTI_MERGE, DISCRIMINATE, DELAYED_DISCRIMINATE, SYNCHRONIZING_MERGE
class Gate(BaseAutomaticActivity):
+ mode_types = (MULTI_MERGE, DISCRIMINATE, DELAYED_DISCRIMINATE,
+ SYNCHRONIZING_MERGE,)
+
attributes = BaseAutomaticActivity.attributes + (
WorkflowAttribute('mode', 'mode', '',
'Mode the gate works, values see self.mode_types',
(at)(at) -247,9 +253,7 (at)(at)
# XXX The import mechanism for this should be revisited.
WorkflowAttribute('_exits', '', (),
'Tuple of IExit objects',
- datatype=tuple,
- importHandler="_attr_import_from_all_childnodes",
- exportHandler="_attr_export_as_childnodes"),
+ datatype=tuple,),
)
(at)(at) -304,9 +308,6 (at)(at)
encoding="ascii", datatype=tuple),
)
- #########
- # private
- security.declarePrivate('_attr_import_permission')
def _attr_import_permission(self, attr, node):
permission_changes = self.createAndConfigureChildNodes(
node, workflow_attributes_registry)
(at)(at) -331,11 +332,12 (at)(at)
attributes = BaseAutomaticActivity.attributes + (
WorkflowAttribute('permission_changes', '', (),
'Tuple of IPermissionSettings',
- datatype=tuple,
- importHandler="_attr_import_permission",
- exportHandler="_attr_export_permission"),
+ datatype=tuple,),
)
+ # importHandler="_attr_import_permission",
+ # exportHandler="_attr_export_permission"),
+
class Recursion(BaseAutomaticActivity):
(at)(at) -366,18 +368,8 (at)(at)
attributes = BaseActivity.attributes + (
WorkflowAttribute('gates', '', (),
- 'Gate activities inside the route.',
- importHandler="_attr_import_route",
- exportHandler="_attr_export_route"),
- WorkflowAttribute('routes', '', (),
- 'All activities inside route which are no gates.',
- importHandler=None, # done by handler above
- exportHandler=None),
- )
+ 'Gate activities inside the route.'),)
- #########
- # private
- security.declarePrivate('_attr_import_route')
def _attr_import_route(self, attr, node):
process = self.acquireProcess()
childs = self.createAndConfigureChildNodes(node, activity_registry)
(at)(at) -418,11 +410,10 (at)(at)
vocabulary=('first', 'all')),
WorkflowAttribute('cases', '', (),
'Tuple of ICase objects',
- datatype=tuple,
- importHandler="_attr_import_from_all_childnodes",
- exportHandler="_attr_export_as_childnodes"),
+ datatype=tuple),
)
+ # cases: importHandler="_attr_import_from_all_childnodes",
class Task(BaseAssignableActivity):
(at)(at) -431,3 +422,11 (at)(at)
'Activity to start after completion.',
encoding="ascii", datatype=tuple),
)
+
+
+def findAttrInAttributes(klass, classAttr):
+ """Find classAttr in WorkflowAttributes of klass."""
+ for attr in klass.attributes:
+ if attr.classAttr == classAttr:
+ return attr
+ raise ConfigurationError("No recipients specified in %r" % self)
|
SVN: r4590 - in AlphaFlow/trunk: . adapters xmlimport
Christian Theune <ct(at)gocept.com> |
2007-03-16 17:07:05 |
[ FULL ]
|
Author: ctheune
Date: Fri Mar 16 17:07:03 2007
New Revision: 4590
Log:
- changed process manager to start using new import infrastructure. (doesn't
work yet)
Added:
AlphaFlow/trunk/xmlimport/configure.zcml (contents, props changed)
Modified:
AlphaFlow/trunk/adapters/alphaflowable.py
AlphaFlow/trunk/configure.zcml
AlphaFlow/trunk/interfaces.py
AlphaFlow/trunk/processmanager.py
AlphaFlow/trunk/xmlimport/core.py
Modified: AlphaFlow/trunk/adapters/alphaflowable.py
==============================================================================
--- AlphaFlow/trunk/adapters/alphaflowable.py (original)
+++ AlphaFlow/trunk/adapters/alphaflowable.py Fri Mar 16 17:07:03 2007
(at)(at) -28,26 +28,6 (at)(at)
self.context.processes._setObject(process_id, process)
return getattr(self.context.processes, process_id)
- def importWorkflowFromXML(self, id, xmlfile):
- if not hasattr(xmlfile, "read"):
- raise ValueError, \
- "Only file uploads or open files are allowed for " \
- "importing XML data."
- wf = minidom.parse(xmlfile).documentElement
- assert wf.tagName == "workflow", "This is not a workflow definition"
- # try to get the id from the process definition if available
- if not id:
- id = wf.getAttribute('id').encode('ascii')
- p = self.addProcess(id)
- p.configureFromDOMNode(wf)
- childs = p.createAndConfigureChildNodes(wf)
- for child in childs:
- p._set_activity(child.id, child)
- if validate_wf_defs:
- self.validateALF(p, xmlfile)
- return p
-
-
def validateALF(self, process, xmlfile):
"""Validate the process definition against a RelaxNG schema.
Modified: AlphaFlow/trunk/configure.zcml
==============================================================================
--- AlphaFlow/trunk/configure.zcml (original)
+++ AlphaFlow/trunk/configure.zcml Fri Mar 16 17:07:03 2007
(at)(at) -20,5 +20,6 (at)(at)
<adapter factory=".workitem.WorkItemFactory" />
<include package=".activities" />
+ <include package=".xmlimport" />
</configure>
Modified: AlphaFlow/trunk/interfaces.py
==============================================================================
--- AlphaFlow/trunk/interfaces.py (original)
+++ AlphaFlow/trunk/interfaces.py Fri Mar 16 17:07:03 2007
(at)(at) -789,4 +789,12 (at)(at)
"""
+class IWorkflowImporter(zope.interface.Interface):
+ """An importer that imports a workflow form a file."""
+
+
+ def importWorkflow(id, file):
+ """Imports a workflow with the given id form the file."""
+
+
from Products.AlphaFlow.activities.interfaces import *
Modified: AlphaFlow/trunk/processmanager.py
==============================================================================
--- AlphaFlow/trunk/processmanager.py (original)
+++ AlphaFlow/trunk/processmanager.py Fri Mar 16 17:07:03 2007
(at)(at) -3,14 +3,12 (at)(at)
# $Id$
"""Process manager"""
-
-# Python imports
import sys
import logging
from threading import Lock
-# Zope imports
import zope.interface
+import zope.component
import zExceptions
import transaction
from webdav.NullResource import NullResource
(at)(at) -19,7 +17,6 (at)(at)
from AccessControl import getSecurityManager, ClassSecurityInfo
from Globals import InitializeClass
-# CMF
from Products.CMFCore.ActionProviderBase import ActionProviderBase
from Products.CMFCore.Expression import Expression
from Products.CMFCore.ActionInformation import ActionInformation
(at)(at) -29,17 +26,19 (at)(at)
except ImportError:
utranslate = lambda d,m,c:m
-# Sibling imports
-from Products.AlphaFlow.interfaces import IProcessManager, IAlphaFlowed
+from Products.AlphaFlow.interfaces import \
+ IProcessManager, IAlphaFlowed, IWorkflowImporter
from Products.AlphaFlow.instance import Instance
from Products.AlphaFlow import config, utils
from Products.AlphaFlow.adapters.alphaflowable import getAlphaFlowableAdapter
from Products.AlphaFlow.adapters.renderableadapter import getRenderableAdapter
from Products.AlphaFlow.rolecache import RoleCache
+
_marker = object()
ping_lock = Lock()
+
class ProcessManager(RoleCache, UniqueObject, ActionProviderBase, Folder):
"""A process management object."""
(at)(at) -315,24 +314,24 (at)(at)
if content:
ret.append(wi.getObject())
retur | |