Numerous import fixes, keeping compatibility between Zope 2.8 and 2.12

git-svn-id: https://svn.erp5.org/repos/public/erp5/sandbox/portal_types@29486 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 94cc759e
...@@ -49,8 +49,10 @@ from Products.ERP5.Document.Document import ConversionError ...@@ -49,8 +49,10 @@ from Products.ERP5.Document.Document import ConversionError
from OFS.Image import Image as OFSImage from OFS.Image import Image as OFSImage
from OFS.Image import getImageInfo from OFS.Image import getImageInfo
from OFS.content_types import guess_content_type try:
from OFS.content_types import guess_content_type
except ImportError:
from zope.contenttype import guess_content_type
from zLOG import LOG, WARNING from zLOG import LOG, WARNING
from Products.CMFCore.utils import getToolByName from Products.CMFCore.utils import getToolByName
......
...@@ -30,7 +30,10 @@ from OFS.Image import File ...@@ -30,7 +30,10 @@ from OFS.Image import File
from Products.PageTemplates.PageTemplateFile import PageTemplateFile from Products.PageTemplates.PageTemplateFile import PageTemplateFile
from Products.ERP5Type import PropertySheet, Permissions from Products.ERP5Type import PropertySheet, Permissions
from Products.PageTemplates.Expressions import getEngine from Products.PageTemplates.Expressions import getEngine
from Products.PageTemplates.TALES import SafeMapping try:
from Products.PageTemplates.TALES import SafeMapping
except ImportError:
from Products.PageTemplates.Expressions import SafeMapping
from urllib import quote from urllib import quote
from Products.ERP5Type.Globals import InitializeClass, PersistentMapping, DTMLFile from Products.ERP5Type.Globals import InitializeClass, PersistentMapping, DTMLFile
......
...@@ -74,7 +74,8 @@ class TestPDFForm(unittest.TestCase): ...@@ -74,7 +74,8 @@ class TestPDFForm(unittest.TestCase):
self.assertEquals('here/getId', self.pdf_form.getCellTALES('text_1')) self.assertEquals('here/getId', self.pdf_form.getCellTALES('text_1'))
def test_setInvalidTALES(self): def test_setInvalidTALES(self):
from Products.PageTemplates.TALES import CompilerError from Products.PageTemplates.Expressions import getEngine
CompilerError = getEngine().getCompilerError()
self.pdf_form.setCellTALES('text_1', 'python:(inv.alid "= ') self.pdf_form.setCellTALES('text_1', 'python:(inv.alid "= ')
# maybe should raise when setting the TALES, not when getting ? # maybe should raise when setting the TALES, not when getting ?
self.assertRaises(CompilerError, self.pdf_form.evaluateCell, 'text_1') self.assertRaises(CompilerError, self.pdf_form.evaluateCell, 'text_1')
......
...@@ -36,7 +36,10 @@ from AccessControl import ClassSecurityInfo ...@@ -36,7 +36,10 @@ from AccessControl import ClassSecurityInfo
from AccessControl import Unauthorized from AccessControl import Unauthorized
from OFS.Image import Pdata from OFS.Image import Pdata
from OFS.Image import File as OFSFile from OFS.Image import File as OFSFile
from OFS.content_types import guess_content_type try:
from OFS.content_types import guess_content_type
except ImportError:
from zope.contenttype import guess_content_type
from Products.CMFCore.utils import getToolByName, _setCacheHeaders,\ from Products.CMFCore.utils import getToolByName, _setCacheHeaders,\
_ViewEmulator _ViewEmulator
from Products.ERP5Type import Permissions, PropertySheet, Constraint from Products.ERP5Type import Permissions, PropertySheet, Constraint
......
...@@ -34,7 +34,7 @@ from Products.ERP5Type.Base import Base ...@@ -34,7 +34,7 @@ from Products.ERP5Type.Base import Base
from Products.CMFCore.utils import UniqueObject from Products.CMFCore.utils import UniqueObject
from Products.ERP5Type.Globals import InitializeClass, DTMLFile, PersistentMapping, Persistent from Products.ERP5Type.Globals import InitializeClass, DTMLFile, PersistentMapping, Persistent
from AccessControl import ClassSecurityInfo, getSecurityManager from AccessControl import ClassSecurityInfo, getSecurityManager
from Products.CMFCore import CMFCorePermissions from Products.CMFCore import permissions as CMFCorePermissions
from Products.ERP5SyncML import _dtmldir from Products.ERP5SyncML import _dtmldir
from Products.ERP5SyncML import Conduit from Products.ERP5SyncML import Conduit
from Publication import Publication, Subscriber from Publication import Publication, Subscriber
......
...@@ -30,12 +30,12 @@ import sys ...@@ -30,12 +30,12 @@ import sys
from Products.CMFCore.Expression import Expression from Products.CMFCore.Expression import Expression
from ZODB.POSException import ConflictError from ZODB.POSException import ConflictError
try:
# Zope 2.8 import Products.PageTemplates.Expressions
from Products.PageTemplates.TALES import CompilerError # this gets the CompilerError class wherever it is defined (which is different
except ImportError: # depending on the Zope version
# Zope 2.12 CompilerError = Products.PageTemplates.Expressions.getEngine().getCompilerError()
from zope.tales.tales import CompilerError
from zLOG import LOG, PROBLEM from zLOG import LOG, PROBLEM
from Constraint import Constraint from Constraint import Constraint
......
...@@ -36,15 +36,7 @@ A complete explanation of the Zope security architecture is available here: ...@@ -36,15 +36,7 @@ A complete explanation of the Zope security architecture is available here:
http://dev.zope.org/Wikis/DevSite/Projects/DeclarativeSecurity/ZopeSecurityForDevelopers http://dev.zope.org/Wikis/DevSite/Projects/DeclarativeSecurity/ZopeSecurityForDevelopers
""" """
try: from Products.CMFCore import permissions
from Products.CMFCore import permissions
except ImportError:
from Products.CMFCore import CMFCorePermissions as permissions
# XXX "Change local roles" didn't exist at the time of CMF 1.4
permissions.ChangeLocalRoles = 'Change local roles'
permissions.setDefaultRoles(permissions.ChangeLocalRoles,
('Owner', 'Manager'))
from AccessControl import Permissions as ac_permissions from AccessControl import Permissions as ac_permissions
setDefaultRoles = permissions.setDefaultRoles setDefaultRoles = permissions.setDefaultRoles
......
...@@ -1176,7 +1176,8 @@ class TestConstraint(PropertySheetTestCase): ...@@ -1176,7 +1176,8 @@ class TestConstraint(PropertySheetTestCase):
klass_name='TALESConstraint', klass_name='TALESConstraint',
id='tales_constraint', id='tales_constraint',
expression='python: None (" ') expression='python: None (" ')
from Products.PageTemplates.TALES import CompilerError from Products.PageTemplates.Expressions import getEngine
CompilerError = getEngine().getCompilerError()
self.assertRaises(CompilerError, constraint.checkConsistency, obj) self.assertRaises(CompilerError, constraint.checkConsistency, obj)
constraint = self._createGenericConstraint( constraint = self._createGenericConstraint(
......
...@@ -10,9 +10,9 @@ from email.MIMEBase import MIMEBase ...@@ -10,9 +10,9 @@ from email.MIMEBase import MIMEBase
from email.MIMEMultipart import MIMEMultipart from email.MIMEMultipart import MIMEMultipart
from App.class_init import default__class_init__ as InitializeClass from App.class_init import default__class_init__ as InitializeClass
try: try:
from zope.app.content_types import guess_content_type from OFS.content_types import guess_content_type
except ImportError: except ImportError:
from OFS.content_types import guess_content_type # Zope 2.7 from zope.contenttype import guess_content_type
from OFS.Image import File from OFS.Image import File
from ZPublisher.HTTPRequest import FileUpload from ZPublisher.HTTPRequest import FileUpload
......
...@@ -550,7 +550,7 @@ class ZopeEntry(OFS.SimpleItem.Item): ...@@ -550,7 +550,7 @@ class ZopeEntry(OFS.SimpleItem.Item):
action ='manage_propertiesForm') action ='manage_propertiesForm')
import Globals import App.class_init
for klass in (GenericEntry, TransactionalEntry, ZopeEntry): for klass in (GenericEntry, TransactionalEntry, ZopeEntry):
Globals.default__class_init__(klass) App.class_init.default__class_init__(klass)
...@@ -102,5 +102,5 @@ class LDAPConnectionAccessors: ...@@ -102,5 +102,5 @@ class LDAPConnectionAccessors:
if not transactional: if not transactional:
self._isCommitting = 1 self._isCommitting = 1
import Globals import App.class_init
Globals.default__class_init__(LDAPConnectionAccessors) App.class_init.default__class_init__(LDAPConnectionAccessors)
...@@ -558,6 +558,6 @@ pretty_results=DocumentTemplate.HTML("""\ ...@@ -558,6 +558,6 @@ pretty_results=DocumentTemplate.HTML("""\
</table>""") </table>""")
import Globals import App.class_init
Globals.default__class_init__(LDAPMethod) App.class_init.default__class_init__(LDAPMethod)
Globals.default__class_init__(LDIFMethod) App.class_init.default__class_init__(LDIFMethod)
\ No newline at end of file \ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment