[Zope3-checkins] CVS: Zope3/src/zope/app/workflow/stateful - contentworkflow.py:1.5 xmlimportexport.py:1.5
Steve Alexander
steve@cat-box.net
Fri, 6 Jun 2003 15:29:38 -0400
Update of /cvs-repository/Zope3/src/zope/app/workflow/stateful
In directory cvs.zope.org:/tmp/cvs-serv7875/src/zope/app/workflow/stateful
Modified Files:
contentworkflow.py xmlimportexport.py
Log Message:
Changed old-style __implements__ to new-style implements()
Also, fixed up some incorrect formatting.
=== Zope3/src/zope/app/workflow/stateful/contentworkflow.py 1.4 => 1.5 ===
--- Zope3/src/zope/app/workflow/stateful/contentworkflow.py:1.4 Tue Jun 3 18:46:23 2003
+++ Zope3/src/zope/app/workflow/stateful/contentworkflow.py Fri Jun 6 15:29:07 2003
@@ -30,12 +30,12 @@
from zope.app.interfaces.workflow import IProcessInstanceContainer
from zope.app.interfaces.workflow import IProcessInstanceContainerAdaptable
from zope.app.interfaces.workflow.stateful import IContentWorkflowsUtility
-
+from zope.interface import implements
class ContentWorkflowsUtility(Persistent):
- __implements__ = IContentWorkflowsUtility, ISubscriber
+ implements(IContentWorkflowsUtility, ISubscriber)
def __init__(self):
super(ContentWorkflowsUtility, self).__init__()
@@ -48,18 +48,18 @@
obj = event.object
# XXX Do i need to removeAllProxies somewhere in here ???
-
+
# check if it implements IProcessInstanceContainerAdaptable
if not IProcessInstanceContainerAdaptable.isImplementedBy(obj):
return
-
+
pi_container = queryAdapter(obj, IProcessInstanceContainer)
# probably need to adapt to IZopeContainer to use pi_container with
# context.
if pi_container is None:
# Object can't have associated PIs.
return
-
+
if IObjectCreatedEvent.isImplementedBy(event):
wfs = getService(self, Workflows)
@@ -67,7 +67,7 @@
# for the newly created compoent. For every pd_name
# returned we will create a processinstance.
for pd_name in self._names:
-
+
if pd_name in pi_container.keys():
continue
try:
@@ -77,7 +77,7 @@
# No registered PD with that name..
continue
pi_container.setObject(pd_name, pi)
-
+
notify = ContextMethod(notify)
# IContentWorkflowsUtility
=== Zope3/src/zope/app/workflow/stateful/xmlimportexport.py 1.4 => 1.5 ===
--- Zope3/src/zope/app/workflow/stateful/xmlimportexport.py:1.4 Tue Jun 3 18:46:23 2003
+++ Zope3/src/zope/app/workflow/stateful/xmlimportexport.py Fri Jun 6 15:29:07 2003
@@ -33,7 +33,7 @@
from xml.sax.handler import ContentHandler
from zope.app.workflow.stateful.definition import State, Transition
-
+from zope.interface import implements
# basic implementation for a format-checker
@@ -49,18 +49,15 @@
def endElement(self, name):
pass
-
def isValid(self):
return self.__valid
-
-
class XMLStatefulImporter(ContentHandler):
def __init__(self, context, encoding='latin-1'):
self.context = context
self.encoding = encoding
-
+
def startElement(self, name, attrs):
handler = getattr(self, 'start' + name.title().replace('-', ''), None)
if not handler:
@@ -76,7 +73,7 @@
def noop(*args):
pass
- startStates = noop
+ startStates = noop
startTransitions = noop
def startWorkflow(self, attrs):
@@ -106,21 +103,22 @@
permission = attrs.get('permission', '').encode(encoding)
if permission == 'zope.Public':
permission = CheckerPublic
- trans = Transition(source = attrs['sourceState'].encode(encoding),
- destination = attrs['destinationState'].encode(encoding),
- condition = attrs.get('condition', '').encode(encoding),
- script = attrs.get('script', '').encode(encoding),
- permission = permission,
- triggerMode = attrs['triggerMode'].encode(encoding))
+ trans = Transition(
+ source = attrs['sourceState'].encode(encoding),
+ destination = attrs['destinationState'].encode(encoding),
+ condition = attrs.get('condition', '').encode(encoding),
+ script = attrs.get('script', '').encode(encoding),
+ permission = permission,
+ triggerMode = attrs['triggerMode'].encode(encoding)
+ )
dc = getAdapter(trans, IZopeDublinCore)
dc.title = attrs.get('title', u'')
self.context.addTransition(name, trans)
-
class XMLImportHandler:
- __implements__ = IProcessDefinitionImportHandler
+ implements(IProcessDefinitionImportHandler)
# XXX Implementation needs more work !!
# check if xml-data can be imported and represents a StatefulPD
@@ -129,17 +127,16 @@
parse(data, checker)
return bool(IStatefulProcessDefinition.isImplementedBy(context)) \
and checker.isValid()
-
def doImport(self, context, data):
# XXX Manually clean ProcessDefinition ??
context.clear()
parse(data, XMLStatefulImporter(context))
-
+
class XMLExportHandler:
- __implements__ = IProcessDefinitionExportHandler
+ implements(IProcessDefinitionExportHandler)
template = ViewPageTemplateFile('xmlexport_template.pt')