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