[Zope3-checkins] CVS: Zope3/src/zope/app/workflow/stateful - xmlimportexport.py:1.12

Stephan Richter srichter at cosmos.phy.tufts.edu
Mon Mar 8 07:07:05 EST 2004


Update of /cvs-repository/Zope3/src/zope/app/workflow/stateful
In directory cvs.zope.org:/tmp/cvs-serv13053/src/zope/app/workflow/stateful

Modified Files:
	xmlimportexport.py 
Log Message:


Adjusted code to use the new APIs for permissions and principals. Also, use
the utility service instead of the permission registry to look up permissions.




=== Zope3/src/zope/app/workflow/stateful/xmlimportexport.py 1.11 => 1.12 ===
--- Zope3/src/zope/app/workflow/stateful/xmlimportexport.py:1.11	Sat Mar  6 11:50:37 2004
+++ Zope3/src/zope/app/workflow/stateful/xmlimportexport.py	Mon Mar  8 07:06:25 2004
@@ -18,27 +18,22 @@
 from xml.sax import parse
 from xml.sax.handler import ContentHandler
 
-from zope.component import getService
 from zope.configuration.name import resolve
 from zope.interface import implements
 from zope.proxy import removeAllProxies
 from zope.security.checker import CheckerPublic
 from zope.security.proxy import trustedRemoveSecurityProxy
 
+from zope.app import zapi
 from zope.app.dublincore.interfaces import IZopeDublinCore
-from zope.app.workflow.interfaces.stateful \
-     import IStatefulProcessDefinition
+from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
+from zope.app.security.interfaces import IPermission 
+from zope.app.workflow.interfaces.stateful import IStatefulProcessDefinition
 from zope.app.workflow.interfaces import IProcessDefinitionImportHandler
 from zope.app.workflow.interfaces import IProcessDefinitionExportHandler
-from zope.app.pagetemplate.viewpagetemplatefile \
-     import ViewPageTemplateFile
-from zope.app.services.servicenames import Permissions
 from zope.app.workflow.stateful.definition import State, Transition
 
 
-__metaclass__ = type
-
-
 # basic implementation for a format-checker
 class XMLFormatChecker(ContentHandler):
 
@@ -60,7 +55,6 @@
     def __init__(self, context, encoding='latin-1'):
         self.context = context
         self.encoding = encoding
-        self.perm_service = getService(self.context, Permissions)
 
     def startElement(self, name, attrs):
         handler = getattr(self, 'start' + name.title().replace('-', ''), None)
@@ -100,7 +94,7 @@
         elif perm_id == '':
             perm = None
         else:
-            perm = self.perm_service.getPermission(perm_id)
+            perm = zapi.getUtility(None, IPermission, perm_id)
         if not fieldName in perms.keys():
             perms[fieldName] = (CheckerPublic, CheckerPublic)
         if type == u'get':
@@ -123,7 +117,7 @@
 
     def startTransition(self, attrs):
         encoding = self.encoding
-        name   = attrs['name'].encode(encoding)
+        name = attrs['name'].encode(encoding)
         permission = attrs.get('permission', '').encode(encoding)
         if permission == 'zope.Public':
             permission = CheckerPublic
@@ -140,8 +134,7 @@
         self.context.addTransition(name, trans)
 
 
-class XMLImportHandler:
-
+class XMLImportHandler(object):
     implements(IProcessDefinitionImportHandler)
 
     # XXX Implementation needs more work !!
@@ -158,8 +151,7 @@
         parse(data, XMLStatefulImporter(context))
 
 
-class XMLExportHandler:
-
+class XMLExportHandler(object):
     implements(IProcessDefinitionExportHandler)
 
     template = ViewPageTemplateFile('xmlexport_template.pt')
@@ -184,7 +176,7 @@
             return 'zope.Public'
         if permission is None:
             return ''
-        return removeAllProxies(permission).getId()
+        return removeAllProxies(permission).id
 
     def getSchemaPermissions(self):
         info = []




More information about the Zope3-Checkins mailing list