Commit 3320c65e authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

code cleanup.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@31013 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 0d255eee
...@@ -42,8 +42,6 @@ except ImportError: ...@@ -42,8 +42,6 @@ except ImportError:
from md5 import new as md5_new from md5 import new as md5_new
from sha import new as sha_new from sha import new as sha_new
from zope.interface import implementedBy
from Products.ERP5Type.Globals import package_home from Products.ERP5Type.Globals import package_home
from Products.ERP5Type.Globals import DevelopmentMode from Products.ERP5Type.Globals import DevelopmentMode
from Acquisition import aq_base from Acquisition import aq_base
...@@ -75,8 +73,6 @@ from Products.ERP5Type.Cache import getReadOnlyTransactionCache ...@@ -75,8 +73,6 @@ from Products.ERP5Type.Cache import getReadOnlyTransactionCache
from Products.ERP5Type.TransactionalVariable import getTransactionalVariable from Products.ERP5Type.TransactionalVariable import getTransactionalVariable
from zLOG import LOG, BLATHER, PROBLEM, WARNING from zLOG import LOG, BLATHER, PROBLEM, WARNING
from AccessControl.SecurityManagement import newSecurityManager, getSecurityManager
##################################################### #####################################################
# Avoid importing from (possibly unpatched) Globals # Avoid importing from (possibly unpatched) Globals
##################################################### #####################################################
...@@ -192,8 +188,8 @@ def _showwarning(message, category, filename, lineno, file=None, line=None): ...@@ -192,8 +188,8 @@ def _showwarning(message, category, filename, lineno, file=None, line=None):
LOG("%s:%u %s: %s" % (filename, lineno, category.__name__, message), LOG("%s:%u %s: %s" % (filename, lineno, category.__name__, message),
WARNING, '') WARNING, '')
else: else:
# BACK: In Python 2.6 we need to pass along the "line" parameter to # BACK: In Python 2.6 we need to pass along the "line" parameter to
# formatwarning(). For now we don't to keep backward compat with Python 2.4 # formatwarning(). For now we don't to keep backward compat with Python 2.4
file.write(warnings.formatwarning(message, category, filename, lineno)) file.write(warnings.formatwarning(message, category, filename, lineno))
warnings.showwarning = _showwarning warnings.showwarning = _showwarning
...@@ -304,9 +300,6 @@ def uidToValue(list): ...@@ -304,9 +300,6 @@ def uidToValue(list):
def referenceToPath(list): def referenceToPath(list):
pass pass
def pathToUid(list):
pass
# Path # Path
def getPath(object_or_path, **kw): def getPath(object_or_path, **kw):
"""Returns the absolute path of an object """Returns the absolute path of an object
...@@ -437,12 +430,7 @@ def updateGlobals(this_module, global_hook, ...@@ -437,12 +430,7 @@ def updateGlobals(this_module, global_hook,
import imp import imp
# Zope 2.6.x does not have App.Config from App.config import getConfiguration
try:
from App.config import getConfiguration
except ImportError:
getConfiguration = None
pass
from Products.ERP5Type.Globals import InitializeClass from Products.ERP5Type.Globals import InitializeClass
from Accessor.Base import func_code from Accessor.Base import func_code
...@@ -465,7 +453,7 @@ class DocumentConstructor(Method): ...@@ -465,7 +453,7 @@ class DocumentConstructor(Method):
if activate_kw is not None: if activate_kw is not None:
o.__of__(folder).setDefaultActivateParameters(**activate_kw) o.__of__(folder).setDefaultActivateParameters(**activate_kw)
if reindex_kw is not None: if reindex_kw is not None:
o.__of__(folder).setDefaultReindexParameters(**reindex_kw) o.__of__(folder).setDefaultReindexParameters(**reindex_kw)
if is_indexable is not None: if is_indexable is not None:
o.isIndexable = is_indexable o.isIndexable = is_indexable
folder._setObject(id, o) folder._setObject(id, o)
...@@ -551,7 +539,7 @@ def writeLocalPropertySheet(class_id, text, create=1, instance_home=None): ...@@ -551,7 +539,7 @@ def writeLocalPropertySheet(class_id, text, create=1, instance_home=None):
path = os.path.join(instance_home, "PropertySheet") path = os.path.join(instance_home, "PropertySheet")
if not os.path.exists(path): if not os.path.exists(path):
os.mkdir(path) os.mkdir(path)
LOG('ERP5Type', WARNING, 'Created missing but required directory: %s' %path) LOG('ERP5Type', WARNING, 'Created missing but required directory: %s' %path)
path = os.path.join(path, "%s.py" % class_id) path = os.path.join(path, "%s.py" % class_id)
if create: if create:
if os.path.exists(path): if os.path.exists(path):
...@@ -871,7 +859,6 @@ def importLocalDocument(class_id, document_path = None): ...@@ -871,7 +859,6 @@ def importLocalDocument(class_id, document_path = None):
""" """
import Products.ERP5Type.Document import Products.ERP5Type.Document
import Permissions import Permissions
import Products
if document_path is None: if document_path is None:
instance_home = getConfiguration().instancehome instance_home = getConfiguration().instancehome
...@@ -879,7 +866,7 @@ def importLocalDocument(class_id, document_path = None): ...@@ -879,7 +866,7 @@ def importLocalDocument(class_id, document_path = None):
else: else:
path = document_path path = document_path
path = os.path.join(path, "%s.py" % class_id) path = os.path.join(path, "%s.py" % class_id)
# Import Document Class and Initialize it # Import Document Class and Initialize it
f = open(path) f = open(path)
try: try:
...@@ -901,7 +888,6 @@ def importLocalDocument(class_id, document_path = None): ...@@ -901,7 +888,6 @@ def importLocalDocument(class_id, document_path = None):
# Temp documents are created as standard classes with a different constructor # Temp documents are created as standard classes with a different constructor
# which patches some methods are the instance level to prevent reindexing # which patches some methods are the instance level to prevent reindexing
from Products.ERP5Type import product_path as erp5_product_path
temp_document_constructor = TempDocumentConstructor(document_class) temp_document_constructor = TempDocumentConstructor(document_class)
temp_document_constructor_name = "newTemp%s" % class_id temp_document_constructor_name = "newTemp%s" % class_id
temp_document_constructor.__name__ = temp_document_constructor_name temp_document_constructor.__name__ = temp_document_constructor_name
...@@ -988,7 +974,7 @@ def initializeLocalRegistry(directory_name, import_local_method, ...@@ -988,7 +974,7 @@ def initializeLocalRegistry(directory_name, import_local_method,
# XXX Arg are not consistent # XXX Arg are not consistent
import_local_method(module_name, **{path_arg_name: document_path}) import_local_method(module_name, **{path_arg_name: document_path})
LOG('ERP5Type', BLATHER, LOG('ERP5Type', BLATHER,
'Added local %s to ERP5Type repository: %s (%s)' 'Added local %s to ERP5Type repository: %s (%s)'
% (directory_name, module_name, document_path)) % (directory_name, module_name, document_path))
except Exception, e: except Exception, e:
if DevelopmentMode: if DevelopmentMode:
...@@ -1851,7 +1837,7 @@ def createDefaultAccessors(property_holder, id, prop = None, ...@@ -1851,7 +1837,7 @@ def createDefaultAccessors(property_holder, id, prop = None,
accessor_name = 'get' + UpperCase(composed_id) + 'List' accessor_name = 'get' + UpperCase(composed_id) + 'List'
list_accessor_args = (prop['type'], aq_id + '_list', prop.get('portal_type'), prop.get('storage_id')) list_accessor_args = (prop['type'], aq_id + '_list', prop.get('portal_type'), prop.get('storage_id'))
if not hasattr(property_holder, accessor_name) or override: if not hasattr(property_holder, accessor_name) or override:
property_holder.registerAccessor(accessor_name, composed_id + '_list', property_holder.registerAccessor(accessor_name, composed_id + '_list',
ContentProperty.Getter, list_accessor_args) ContentProperty.Getter, list_accessor_args)
property_holder.declareProtected( read_permission, accessor_name ) property_holder.declareProtected( read_permission, accessor_name )
# No default getter YET XXXXXXXXXXXXXX # No default getter YET XXXXXXXXXXXXXX
...@@ -1862,7 +1848,7 @@ def createDefaultAccessors(property_holder, id, prop = None, ...@@ -1862,7 +1848,7 @@ def createDefaultAccessors(property_holder, id, prop = None,
property_holder.declareProtected( write_permission, accessor_name ) property_holder.declareProtected( write_permission, accessor_name )
accessor_name = '_set' + UpperCase(composed_id) + 'List' accessor_name = '_set' + UpperCase(composed_id) + 'List'
if not hasattr(property_holder, accessor_name) or override: if not hasattr(property_holder, accessor_name) or override:
property_holder.registerAccessor(accessor_name, composed_id + '_list', property_holder.registerAccessor(accessor_name, composed_id + '_list',
ContentProperty.Setter, list_accessor_args) ContentProperty.Setter, list_accessor_args)
property_holder.declareProtected( write_permission, accessor_name ) property_holder.declareProtected( write_permission, accessor_name )
accessor_name = 'set' + UpperCase(composed_id) accessor_name = 'set' + UpperCase(composed_id)
......
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