[Zope3-checkins] CVS: Zope3/src/zope/app/workflow/stateful/tests - test_xmlimportexport.py:1.6
Stephan Richter
srichter@cosmos.phy.tufts.edu
Thu, 31 Jul 2003 11:01:44 -0400
Update of /cvs-repository/Zope3/src/zope/app/workflow/stateful/tests
In directory cvs.zope.org:/tmp/cvs-serv10755/src/zope/app/workflow/stateful/tests
Modified Files:
test_xmlimportexport.py
Log Message:
Implemented relevant data for Processes (read workflows). You can specify
a schema which contains the fields that should be available as relevant
data. Once the schema is set, you are able to specify "get" and "set"
permissions for each field. That;s it for the setup.
When you then create a Content Object that uses the process definition for
which you declared the schema, you will see that there is a form in the
'Workflows' tab of this content object that allows you to manipulate the
releavant data.
I also enhanced the XML Import/Export to support relevant data and their
permissions.
The easiest way to check all this functionality out is to uncomment the
include directives in browser/workflow/stateful/configure.zcml and
workflow/stateful/configure.zcml (both at the end of the file).
This completes my code and status review of the workflow package, which I
think is now ready for the beta.
=== Zope3/src/zope/app/workflow/stateful/tests/test_xmlimportexport.py 1.5 => 1.6 ===
--- Zope3/src/zope/app/workflow/stateful/tests/test_xmlimportexport.py:1.5 Tue Jul 29 20:00:28 2003
+++ Zope3/src/zope/app/workflow/stateful/tests/test_xmlimportexport.py Thu Jul 31 11:01:40 2003
@@ -18,26 +18,40 @@
from zope.app.interfaces.annotation import IAnnotatable, IAnnotations
from zope.app.interfaces.annotation import IAttributeAnnotatable
from zope.app.interfaces.dublincore import IZopeDublinCore
+from zope.app.interfaces.security import IPermissionService
from zope.app.interfaces.services.registration import IRegisterable
from zope.app.interfaces.workflow import IProcessDefinitionExportHandler
from zope.app.interfaces.workflow import IProcessDefinitionImportHandler
+from zope.app.security.registries.permissionregistry import permissionRegistry
+from zope.app.services.servicenames import Permissions
from zope.app.services.tests.placefulsetup import PlacefulSetup
from zope.app.workflow.stateful.definition import StatefulProcessDefinition
from zope.app.workflow.stateful.definition import State, Transition
from zope.app.workflow.stateful.xmlimportexport import XMLExportHandler
from zope.app.workflow.stateful.xmlimportexport import XMLImportHandler
from zope.component.adapter import provideAdapter
-from zope.component import getAdapter
-from zope.interface import implements, classImplements
+from zope.component import getAdapter, getService, getServiceManager
+from zope.interface import implements, classImplements, Interface
from zope.interface.verify import verifyClass
+from zope.schema import TextLine
from zope.security.checker import CheckerPublic
import unittest
+class ISchema(Interface):
-xml_text = """<?xml version="1.0"?>
+ title = TextLine(
+ title=u"Title",
+ required=True)
+
+
+xml_text = '''<?xml version="1.0"?>
<workflow type="StatefulWorkflow" title="TestPD">
- <schema name="Some.path.to.an.ISchemaClass">
+ <schema name="zope.app.workflow.stateful.tests.test_xmlimportexport.ISchema">
+ <permissions>
+ <permission for="title" type="get" id="zope.Public" />
+ <permission for="title" type="set" id="zope.View" />
+ </permissions>
</schema>
<states>
@@ -73,7 +87,7 @@
</transitions>
</workflow>
-"""
+'''
class TestProcessDefinition(StatefulProcessDefinition):
@@ -92,6 +106,11 @@
provideAdapter(IAttributeAnnotatable, IAnnotations,
AttributeAnnotations)
provideAdapter(IAnnotatable, IZopeDublinCore, ZDCAnnotatableAdapter)
+ sm = getServiceManager(None)
+ sm.defineService(Permissions, IPermissionService)
+ sm.provideService(Permissions, permissionRegistry)
+ perm_service = getService(None, Permissions)
+ perm_service.definePermission('zope.View', 'View', '')
def testInterface(self):
verifyClass(IProcessDefinitionImportHandler, XMLImportHandler)
@@ -110,9 +129,13 @@
handler.doImport(testpd, StringIO(xml_text))
- self.assertEqual(testpd.getRelevantDataSchema(),
- 'Some.path.to.an.ISchemaClass')
+ self.assertEqual(testpd.relevantDataSchema, ISchema)
self.assertEqual(getAdapter(testpd, IZopeDublinCore).title, 'TestPD')
+
+ perm_service = getService(None, Permissions)
+ self.assertEqual(
+ testpd.schemaPermissions['title'],
+ (CheckerPublic, perm_service.getPermission('zope.View')))
self.assertEqual(len(testpd.states), 3)
self.assertEqual(len(testpd.transitions), 3)