class IWorkflowDirective(Interface): type = TextLine(title=_u('type'), required=True) name = TextLine(title=_u('title'), required=True) initial_state = TextLine(title=_u('initial_state'), required=True) state_attr = TextLine(title=_u('state_attr'), required=True) content_types = Tokens(title=_u('content_types'), required=False, value_type=GlobalObject()) elector = GlobalObject(title=_u('elector'), required=False) permission_checker = GlobalObject(title=_u('permission checker'), required=False) description = TextLine(title=_u('description'), required=False) roles_checker = GlobalObject(title=_u('roles checker'), required=False)
class ITransitionDirective(Interface): """ The interface for a transition directive """ name = TextLine(title=_u('name'), required=True) from_state = TextLine(title=_u('from_state'), required=True) to_state = TextLine(title=_u('to_state'), required=True) permission = TextLine(title=_u('permission'), required=False) title = TextLine(title=_u('title'), required=False) callback = GlobalObject(title=_u('callback'), required=False)
def test_execute_actions(self): from zope.configuration import xmlconfig from zope.component import getSiteManager from repoze.workflow.interfaces import IWorkflowList from repoze.workflow.workflow import Workflow from repoze.workflow.tests.fixtures.dummy import callback import repoze.workflow.tests.fixtures as package from repoze.workflow.tests.fixtures import dummy from repoze.workflow.tests.fixtures.dummy import IContent from repoze.workflow.tests.fixtures.dummy import elector from repoze.workflow.tests.fixtures.dummy import has_permission from repoze.workflow._compat import text_ as _u xmlconfig.file('configure.zcml', package, execute=True) sm = getSiteManager() wf_list = sm.adapters.lookup((IContent, ), IWorkflowList, name='security') self.assertEqual(len(wf_list), 1) workflow_data = wf_list[0] self.assertEqual(workflow_data['elector'], elector) workflow = workflow_data['workflow'] self.assertEqual(workflow.__class__, Workflow) self.assertEqual(workflow.name, 'the workflow') self.assertEqual( workflow.description, 'The workflow which is of the ' 'testing fixtures package') self.assertEqual(workflow.permission_checker, has_permission) self.assertEqual( workflow._state_aliases, {'supersecret': 'private'}, ) self.assertEqual( workflow._state_data, { _u('public'): { 'callback': callback, 'description': _u('Everybody can see it'), 'title': _u('Public'), }, _u('private'): { 'callback': callback, 'description': _u('Nobody can see it'), 'title': _u('Private'), }, }) transitions = workflow._transition_data self.assertEqual(len(transitions), 3) self.assertEqual( transitions['private_to_public'], { 'from_state': _u('private'), 'callback': callback, 'guards': [], 'name': _u('private_to_public'), 'to_state': _u('public'), 'permission': 'moderate', 'title': 'private_to_public', }), self.assertEqual( transitions['unavailable_public_to_private'], { 'from_state': _u('public'), 'callback': callback, 'guards': [dummy.never], 'name': _u('unavailable_public_to_private'), 'to_state': _u('private'), 'permission': _u('moderate'), 'title': _u('unavailable_public_to_private'), }), self.assertEqual( transitions['public_to_private'], { 'from_state': _u('public'), 'callback': callback, 'guards': [], 'name': 'public_to_private', 'to_state': _u('private'), 'permission': 'moderate', 'title': 'public_to_private' })
def test_execute_actions(self): from zope.configuration import xmlconfig from zope.component import getSiteManager from repoze.workflow.interfaces import IWorkflowList from repoze.workflow.workflow import Workflow from repoze.workflow.tests.fixtures.dummy import callback import repoze.workflow.tests.fixtures as package from repoze.workflow.tests.fixtures import dummy from repoze.workflow.tests.fixtures.dummy import IContent from repoze.workflow.tests.fixtures.dummy import elector from repoze.workflow.tests.fixtures.dummy import has_permission from repoze.workflow._compat import text_ as _u xmlconfig.file('configure.zcml', package, execute=True) sm = getSiteManager() wf_list = sm.adapters.lookup((IContent,), IWorkflowList, name='security') self.assertEqual(len(wf_list), 1) workflow_data = wf_list[0] self.assertEqual(workflow_data['elector'], elector) workflow = workflow_data['workflow'] self.assertEqual(workflow.__class__, Workflow) self.assertEqual(workflow.name, 'the workflow') self.assertEqual(workflow.description, 'The workflow which is of the ' 'testing fixtures package') self.assertEqual(workflow.permission_checker, has_permission) self.assertEqual( workflow._state_aliases, {'supersecret':'private'}, ) self.assertEqual( workflow._state_data, {_u('public'): {'callback':callback, 'description': _u('Everybody can see it'), 'title': _u('Public'), }, _u('private'): {'callback':callback, 'description': _u('Nobody can see it'), 'title': _u('Private'), }, }) transitions = workflow._transition_data self.assertEqual(len(transitions), 3) self.assertEqual(transitions['private_to_public'], {'from_state': _u('private'), 'callback': callback, 'guards': [], 'name': _u('private_to_public'), 'to_state': _u('public'), 'permission':'moderate', 'title': 'private_to_public', }), self.assertEqual(transitions['unavailable_public_to_private'], {'from_state': _u('public'), 'callback': callback, 'guards': [dummy.never], 'name': _u('unavailable_public_to_private'), 'to_state': _u('private'), 'permission':_u('moderate'), 'title': _u('unavailable_public_to_private'), }), self.assertEqual(transitions['public_to_private'], {'from_state': _u('public'), 'callback': callback, 'guards': [], 'name': 'public_to_private', 'to_state': _u('private'), 'permission':'moderate', 'title': 'public_to_private'} )
class IStateDirective(Interface): """ The interface for a state directive """ name = TextLine(title=_u('name'), required=True) title = TextLine(title=_u('title'), required=False) callback = GlobalObject(title=_u('enter state callback'), required=False)
class IAliasDirective(Interface): """ The interface for an alias subdirective """ name = TextLine(title=_u('name'), required=True)
class IKeyValueDirective(Interface): """ The interface for a key/value pair subdirective """ name = TextLine(title=_u('key'), required=True) value = TextLine(title=_u('value'), required=True)
class IGuardDirective(Interface): """ A directive for a guard on a transition. """ function = GlobalObject(title=_u('enter guard function'), required=True)
class IRoleDirective(Interface): """ The interface for a key/value pair subdirective """ name = TextLine(title=_u('name'), required=True)