Commit efa37474 authored by Jérome Perrin's avatar Jérome Perrin

*: update imports to prevent deprecation warnings and prepare Zope5 compatibility

parent b7daa4bf
...@@ -50,7 +50,7 @@ from OFS.Image import Pdata ...@@ -50,7 +50,7 @@ from OFS.Image import Pdata
WORKFLOW_TYPE = 'erp5_workflow' WORKFLOW_TYPE = 'erp5_workflow'
from Products.MimetypesRegistry.common import MimeTypeException from Products.MimetypesRegistry.interfaces import MimeTypeException
from Products.PortalTransforms.Transform import Transform from Products.PortalTransforms.Transform import Transform
Transform_tr_init = Transform._tr_init Transform_tr_init = Transform._tr_init
Transform_manage_beforeDelete = Transform.manage_beforeDelete Transform_manage_beforeDelete = Transform.manage_beforeDelete
......
...@@ -576,7 +576,7 @@ class TestERP5Core(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -576,7 +576,7 @@ class TestERP5Core(ERP5TypeTestCase, ZopeTestCase.Functional):
0 != i.getUid() != i.getProperty('uid')]) 0 != i.getUid() != i.getProperty('uid')])
def test_04_site_manager_and_translation_migration(self): def test_04_site_manager_and_translation_migration(self):
from zope.site.hooks import setSite from zope.component.hooks import setSite
from zope.component import queryUtility from zope.component import queryUtility
# check translation is working normaly # check translation is working normaly
erp5_ui_catalog = self.portal.Localizer.erp5_ui erp5_ui_catalog = self.portal.Localizer.erp5_ui
......
...@@ -33,7 +33,8 @@ import six ...@@ -33,7 +33,8 @@ import six
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.utils import createZODBPythonScript from Products.ERP5Type.tests.utils import createZODBPythonScript
from Persistence import PersistentMapping from Persistence import PersistentMapping
from zope.site.hooks import setSite from zope.component.hooks import setSite
class TestLocalizer(ERP5TypeTestCase): class TestLocalizer(ERP5TypeTestCase):
def afterSetUp(self): def afterSetUp(self):
......
...@@ -58,7 +58,7 @@ from BTrees.OIBTree import OIBTree ...@@ -58,7 +58,7 @@ from BTrees.OIBTree import OIBTree
from BTrees.OOBTree import OOBTree from BTrees.OOBTree import OOBTree
from Zope2 import app from Zope2 import app
from Products.ERP5Type.UnrestrictedMethod import PrivilegedUser from Products.ERP5Type.UnrestrictedMethod import PrivilegedUser
from zope.site.hooks import setSite from zope.component.hooks import setSite
import transaction import transaction
from App.config import getConfiguration from App.config import getConfiguration
from Shared.DC.ZRDB.Results import Results from Shared.DC.ZRDB.Results import Results
......
...@@ -111,7 +111,7 @@ try: ...@@ -111,7 +111,7 @@ try:
except TypeError: except TypeError:
pass pass
cache_database = threading.local() cache_database = threading.local()
from Products.MimetypesRegistry.common import MimeTypeException from Products.MimetypesRegistry.interfaces import MimeTypeException
import imghdr import imghdr
# those attributes from CatalogMethodTemplateItem are kept for # those attributes from CatalogMethodTemplateItem are kept for
......
...@@ -478,7 +478,7 @@ class ERP5Site(ResponseHeaderGenerator, FolderMixIn, PortalObjectBase, CacheCook ...@@ -478,7 +478,7 @@ class ERP5Site(ResponseHeaderGenerator, FolderMixIn, PortalObjectBase, CacheCook
# one. Including setting up ZTK style utilities and adapters. We # one. Including setting up ZTK style utilities and adapters. We
# can even call setSite(self), as long as we roll back that later, # can even call setSite(self), as long as we roll back that later,
# since we are actually in the middle of a setSite() call. # since we are actually in the middle of a setSite() call.
from zope.site.hooks import getSite, setSite from zope.component.hooks import getSite, setSite
old_site = getSite() old_site = getSite()
try: try:
setSite(self) setSite(self)
......
...@@ -39,7 +39,7 @@ from erp5.component.mixin.DocumentProxyMixin import DocumentProxyMixin, Document ...@@ -39,7 +39,7 @@ from erp5.component.mixin.DocumentProxyMixin import DocumentProxyMixin, Document
from MethodObject import Method from MethodObject import Method
try: try:
from Products.MimetypesRegistry.common import MimeTypeException # pylint: disable=unused-import from Products.MimetypesRegistry.interfaces import MimeTypeException # pylint: disable=unused-import
except ImportError: except ImportError:
class MimeTypeException(Exception): class MimeTypeException(Exception):
""" """
......
...@@ -46,7 +46,7 @@ from Products.ERP5Type.Utils import UpperCase ...@@ -46,7 +46,7 @@ from Products.ERP5Type.Utils import UpperCase
from zLOG import LOG from zLOG import LOG
try: try:
from webdav.Lockable import ResourceLockedError from zExceptions import ResourceLockedError
from webdav.WriteLockInterface import WriteLockInterface from webdav.WriteLockInterface import WriteLockInterface
SUPPORTS_WEBDAV_LOCKS = 1 SUPPORTS_WEBDAV_LOCKS = 1
except ImportError: except ImportError:
......
...@@ -53,7 +53,7 @@ import re ...@@ -53,7 +53,7 @@ import re
import six import six
try: try:
from webdav.Lockable import ResourceLockedError from zExceptions import ResourceLockedError
SUPPORTS_WEBDAV_LOCKS = 1 SUPPORTS_WEBDAV_LOCKS = 1
except ImportError: except ImportError:
SUPPORTS_WEBDAV_LOCKS = 0 SUPPORTS_WEBDAV_LOCKS = 0
......
...@@ -50,7 +50,7 @@ import itertools ...@@ -50,7 +50,7 @@ import itertools
import six import six
try: try:
from webdav.Lockable import ResourceLockedError from zExceptions import ResourceLockedError
from webdav.WriteLockInterface import WriteLockInterface from webdav.WriteLockInterface import WriteLockInterface
SUPPORTS_WEBDAV_LOCKS = 1 SUPPORTS_WEBDAV_LOCKS = 1
except ImportError: except ImportError:
......
...@@ -38,8 +38,7 @@ http://dev.zope.org/Wikis/DevSite/Projects/DeclarativeSecurity/ZopeSecurityForDe ...@@ -38,8 +38,7 @@ http://dev.zope.org/Wikis/DevSite/Projects/DeclarativeSecurity/ZopeSecurityForDe
from Products.CMFCore import permissions from Products.CMFCore import permissions
from AccessControl import Permissions as ac_permissions from AccessControl import Permissions as ac_permissions
from AccessControl.Permission import addPermission
setDefaultRoles = permissions.setDefaultRoles
# Default Zope Permissions # Default Zope Permissions
View = permissions.View View = permissions.View
...@@ -89,14 +88,14 @@ DeletePortalContent = permissions.ModifyPortalContent ...@@ -89,14 +88,14 @@ DeletePortalContent = permissions.ModifyPortalContent
# ERP5 addition: default content translation permissions # ERP5 addition: default content translation permissions
# this comes from Base18 # this comes from Base18
TranslateContent = 'Translate Content' TranslateContent = 'Translate Content'
setDefaultRoles(TranslateContent, ('Manager', 'Owner', 'Member')) addPermission(TranslateContent, ('Manager', 'Owner', 'Member'))
# ERP5 additions: we define some content creations # ERP5 additions: we define some content creations
# securities here. Each ERP5 Document will # securities here. Each ERP5 Document will
# point to one of these securities through the # point to one of these securities through the
# add_permission attribute # add_permission attribute
# #
# we define here the "setDefaultRoles" although # we define here the "addPermission" although
# it does not apply to most roles since roles are defines # it does not apply to most roles since roles are defines
# on a ERP5 per ERP5 user basis. Most ERP5 users will # on a ERP5 per ERP5 user basis. Most ERP5 users will
# subclass ERP5 basic types and define their own roles # subclass ERP5 basic types and define their own roles
...@@ -140,7 +139,7 @@ setDefaultRoles(TranslateContent, ('Manager', 'Owner', 'Member')) ...@@ -140,7 +139,7 @@ setDefaultRoles(TranslateContent, ('Manager', 'Owner', 'Member'))
# - using technical types / interfaces (ie. Entity, Coordinate, Predicate, etc.) # - using technical types / interfaces (ie. Entity, Coordinate, Predicate, etc.)
#AddERP5Content = 'Add ERP5 content' #AddERP5Content = 'Add ERP5 content'
#setDefaultRoles(AddERP5Content, ('Manager', )) #addPermission(AddERP5Content, ('Manager', ))
AddERP5Content = AddPortalContent # Since we put come CPS content in ERP5 documents, there is no rationale in having 2 permissions AddERP5Content = AddPortalContent # Since we put come CPS content in ERP5 documents, there is no rationale in having 2 permissions
# Source Code Management - this is the highest possible permission # Source Code Management - this is the highest possible permission
......
...@@ -62,7 +62,7 @@ from Products.CMFCore.DirectoryView import registerDirectory ...@@ -62,7 +62,7 @@ from Products.CMFCore.DirectoryView import registerDirectory
from Products.CMFCore.utils import getToolByName from Products.CMFCore.utils import getToolByName
from Products.PageTemplates.Expressions import getEngine from Products.PageTemplates.Expressions import getEngine
from Products.PageTemplates.Expressions import SecureModuleImporter from Products.PageTemplates.Expressions import SecureModuleImporter
from Products.ZCatalog.Lazy import LazyMap from ZTUtils.Lazy import LazyMap
try: try:
import chardet import chardet
......
...@@ -21,7 +21,7 @@ from BTrees.OOBTree import OOBTree ...@@ -21,7 +21,7 @@ from BTrees.OOBTree import OOBTree
from BTrees.OIBTree import OIBTree, union from BTrees.OIBTree import OIBTree, union
from BTrees.Length import Length from BTrees.Length import Length
from OFS.ObjectManager import BadRequestException, BeforeDeleteException from OFS.ObjectManager import BadRequestException, BeforeDeleteException
from Products.ZCatalog.Lazy import LazyMap from ZTUtils.Lazy import LazyMap
from zLOG import LOG, WARNING, ERROR, INFO from zLOG import LOG, WARNING, ERROR, INFO
class ERP5BTreeFolder2Base(BTreeFolder2Base): class ERP5BTreeFolder2Base(BTreeFolder2Base):
......
...@@ -29,7 +29,7 @@ from Products.DCWorkflow.DCWorkflow import ObjectDeleted, ObjectMoved ...@@ -29,7 +29,7 @@ from Products.DCWorkflow.DCWorkflow import ObjectDeleted, ObjectMoved
from Products.DCWorkflow import DCWorkflow from Products.DCWorkflow import DCWorkflow
from Products.DCWorkflow.Transitions import TRIGGER_WORKFLOW_METHOD, TransitionDefinition from Products.DCWorkflow.Transitions import TRIGGER_WORKFLOW_METHOD, TransitionDefinition
from Products.DCWorkflow.Transitions import TRIGGER_USER_ACTION from Products.DCWorkflow.Transitions import TRIGGER_USER_ACTION
from Products.DCWorkflow.permissions import ManagePortal from Products.CMFCore.permissions import ManagePortal
from AccessControl import getSecurityManager, ModuleSecurityInfo from AccessControl import getSecurityManager, ModuleSecurityInfo
from AccessControl.SecurityInfo import ClassSecurityInfo from AccessControl.SecurityInfo import ClassSecurityInfo
from Products.ERP5Type.Globals import InitializeClass from Products.ERP5Type.Globals import InitializeClass
......
...@@ -17,7 +17,6 @@ import six ...@@ -17,7 +17,6 @@ import six
from six import string_types as basestring from six import string_types as basestring
from OFS.PropertyManager import PropertyManager, type_converters from OFS.PropertyManager import PropertyManager, type_converters
from OFS.PropertyManager import escape
from Products.ERP5Type.Globals import DTMLFile from Products.ERP5Type.Globals import DTMLFile
from Products.ERP5Type.Utils import createExpressionContext from Products.ERP5Type.Utils import createExpressionContext
from Products.CMFCore.Expression import Expression from Products.CMFCore.Expression import Expression
...@@ -28,6 +27,12 @@ from DateTime import DateTime ...@@ -28,6 +27,12 @@ from DateTime import DateTime
ERP5PropertyManager = PropertyManager # BBB ERP5PropertyManager = PropertyManager # BBB
if six.PY3:
from html import escape
else:
from cgi import escape
PropertyManager_manage_propertiesForm=DTMLFile('properties', PropertyManager_manage_propertiesForm=DTMLFile('properties',
_dtmldir, _dtmldir,
property_extensible_schema__=1) property_extensible_schema__=1)
......
...@@ -15,6 +15,8 @@ from Shared.DC.ZRDB import sqltest ...@@ -15,6 +15,8 @@ from Shared.DC.ZRDB import sqltest
from DateTime import DateTime from DateTime import DateTime
from Products.ERP5Type import IS_ZOPE2 from Products.ERP5Type import IS_ZOPE2
import six
list_type_list = list, tuple, set, frozenset, dict list_type_list = list, tuple, set, frozenset, dict
if IS_ZOPE2: # BBB Zope2 if IS_ZOPE2: # BBB Zope2
......
...@@ -33,7 +33,7 @@ import imp ...@@ -33,7 +33,7 @@ import imp
import re import re
import warnings import warnings
from zope.site.hooks import setSite from zope.component.hooks import setSite
from zope.globalrequest import getRequest from zope.globalrequest import getRequest
from Acquisition import aq_base from Acquisition import aq_base
from Testing import ZopeTestCase from Testing import ZopeTestCase
......
...@@ -37,7 +37,7 @@ from zope.globalrequest import getRequest ...@@ -37,7 +37,7 @@ from zope.globalrequest import getRequest
from zope.globalrequest import setRequest from zope.globalrequest import setRequest
import six import six
from zope.site.hooks import setSite from zope.component.hooks import setSite
from Testing import ZopeTestCase from Testing import ZopeTestCase
from Testing.makerequest import makerequest from Testing.makerequest import makerequest
......
...@@ -13,7 +13,7 @@ from Products.CMFCore.ActionProviderBase import ActionProviderBase ...@@ -13,7 +13,7 @@ from Products.CMFCore.ActionProviderBase import ActionProviderBase
from Products.CMFCore.permissions import ManagePortal, View from Products.CMFCore.permissions import ManagePortal, View
from Products.CMFCore.utils import registerToolInterface, UniqueObject from Products.CMFCore.utils import registerToolInterface, UniqueObject
from Products.CMFCore.utils import getToolByName from Products.CMFCore.utils import getToolByName
from Products.MimetypesRegistry.common import MimeTypeException from Products.MimetypesRegistry.interfaces import MimeTypeException
from Products.PageTemplates.PageTemplateFile import PageTemplateFile from Products.PageTemplates.PageTemplateFile import PageTemplateFile
from Products.PortalTransforms.data import datastream from Products.PortalTransforms.data import datastream
......
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