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
from OFS.Image import Image as OFSImage
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 Products.CMFCore.utils import getToolByName
......
......@@ -30,7 +30,10 @@ from OFS.Image import File
from Products.PageTemplates.PageTemplateFile import PageTemplateFile
from Products.ERP5Type import PropertySheet, Permissions
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 Products.ERP5Type.Globals import InitializeClass, PersistentMapping, DTMLFile
......
......@@ -74,7 +74,8 @@ class TestPDFForm(unittest.TestCase):
self.assertEquals('here/getId', self.pdf_form.getCellTALES('text_1'))
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 "= ')
# maybe should raise when setting the TALES, not when getting ?
self.assertRaises(CompilerError, self.pdf_form.evaluateCell, 'text_1')
......
......@@ -36,7 +36,10 @@ from AccessControl import ClassSecurityInfo
from AccessControl import Unauthorized
from OFS.Image import Pdata
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,\
_ViewEmulator
from Products.ERP5Type import Permissions, PropertySheet, Constraint
......
......@@ -34,7 +34,7 @@ from Products.ERP5Type.Base import Base
from Products.CMFCore.utils import UniqueObject
from Products.ERP5Type.Globals import InitializeClass, DTMLFile, PersistentMapping, Persistent
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 Conduit
from Publication import Publication, Subscriber
......
......@@ -30,12 +30,12 @@ import sys
from Products.CMFCore.Expression import Expression
from ZODB.POSException import ConflictError
try:
# Zope 2.8
from Products.PageTemplates.TALES import CompilerError
except ImportError:
# Zope 2.12
from zope.tales.tales import CompilerError
import Products.PageTemplates.Expressions
# this gets the CompilerError class wherever it is defined (which is different
# depending on the Zope version
CompilerError = Products.PageTemplates.Expressions.getEngine().getCompilerError()
from zLOG import LOG, PROBLEM
from Constraint import Constraint
......
......@@ -36,15 +36,7 @@ A complete explanation of the Zope security architecture is available here:
http://dev.zope.org/Wikis/DevSite/Projects/DeclarativeSecurity/ZopeSecurityForDevelopers
"""
try:
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 Products.CMFCore import permissions
from AccessControl import Permissions as ac_permissions
setDefaultRoles = permissions.setDefaultRoles
......
......@@ -1176,7 +1176,8 @@ class TestConstraint(PropertySheetTestCase):
klass_name='TALESConstraint',
id='tales_constraint',
expression='python: None (" ')
from Products.PageTemplates.TALES import CompilerError
from Products.PageTemplates.Expressions import getEngine
CompilerError = getEngine().getCompilerError()
self.assertRaises(CompilerError, constraint.checkConsistency, obj)
constraint = self._createGenericConstraint(
......
......@@ -10,9 +10,9 @@ from email.MIMEBase import MIMEBase
from email.MIMEMultipart import MIMEMultipart
from App.class_init import default__class_init__ as InitializeClass
try:
from zope.app.content_types import guess_content_type
from OFS.content_types import guess_content_type
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 ZPublisher.HTTPRequest import FileUpload
......
......@@ -550,7 +550,7 @@ class ZopeEntry(OFS.SimpleItem.Item):
action ='manage_propertiesForm')
import Globals
import App.class_init
for klass in (GenericEntry, TransactionalEntry, ZopeEntry):
Globals.default__class_init__(klass)
App.class_init.default__class_init__(klass)
......@@ -102,5 +102,5 @@ class LDAPConnectionAccessors:
if not transactional:
self._isCommitting = 1
import Globals
Globals.default__class_init__(LDAPConnectionAccessors)
import App.class_init
App.class_init.default__class_init__(LDAPConnectionAccessors)
......@@ -558,6 +558,6 @@ pretty_results=DocumentTemplate.HTML("""\
</table>""")
import Globals
Globals.default__class_init__(LDAPMethod)
Globals.default__class_init__(LDIFMethod)
\ No newline at end of file
import App.class_init
App.class_init.default__class_init__(LDAPMethod)
App.class_init.default__class_init__(LDIFMethod)
\ 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