Commit 0e26e416 authored by Jean-Paul Smets's avatar Jean-Paul Smets

Better management of constructors


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@1335 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 96dbd2c2
...@@ -83,6 +83,21 @@ def convertToUpperCase(key): ...@@ -83,6 +83,21 @@ def convertToUpperCase(key):
UpperCase = convertToUpperCase UpperCase = convertToUpperCase
def convertToMixedCase(key):
"""
This function turns an attribute name into
a method name according to the ERP5 naming conventions
"""
result = ''
parts = string.split(str(key),'_')
i = 0
for part in parts:
letter_list = list(part)
if i: letter_list[0] = string.upper(letter_list[0])
result = result + string.join(letter_list,'')
i += 1
return result
# Some set operations # Some set operations
def cartesianProduct(list_of_list): def cartesianProduct(list_of_list):
if len(list_of_list) == 0: if len(list_of_list) == 0:
...@@ -450,18 +465,32 @@ def importLocalDocument(class_id, document_path = None): ...@@ -450,18 +465,32 @@ def importLocalDocument(class_id, document_path = None):
Products.meta_types = tuple(new_meta_types) Products.meta_types = tuple(new_meta_types)
# Update Constructors # Update Constructors
m = Products.ERP5Type._m m = Products.ERP5Type._m
constructors = ( manage_addContentForm if hasattr(document_class, 'factory_type_information'):
, manage_addContent constructors = ( manage_addContentForm
, document_constructor ) , manage_addContent
, document_constructor
, ('factory_type_information', document_class.factory_type_information) )
else:
constructors = ( manage_addContentForm
, manage_addContent
, document_constructor )
initial = constructors[0] initial = constructors[0]
m[initial.__name__]=manage_addContentForm m[initial.__name__]=manage_addContentForm
m[initial.__name__+'__roles__']=pr m[initial.__name__+'__roles__']=pr
for method in constructors[1:]: for method in constructors[1:]:
name=os.path.split(method.__name__)[-1] if type(method) is type((1,2)): name, method = method
m[name]=method else:
name=os.path.split(method.__name__)[-1]
if name != 'factory_type_information':
# Add constructor to product dispatcher
m[name]=method
else:
# Append fti to product dispatcher
if not m.has_key(name): m[name] = []
m[name].append(method)
m[name+'__roles__']=pr m[name+'__roles__']=pr
# ( manage_addContentForm # ( manage_addContentForm
# , manage_addContent # , manage_addContent
# , self # , self
...@@ -652,7 +681,7 @@ def initializeDefaultProperties(klasses): ...@@ -652,7 +681,7 @@ def initializeDefaultProperties(klasses):
if getattr(klass, 'isRADContent', 0): if getattr(klass, 'isRADContent', 0):
setDefaultClassProperties(klass) setDefaultClassProperties(klass)
setDefaultProperties(klass) setDefaultProperties(klass)
def setDefaultProperties(klass): def setDefaultProperties(klass):
""" """
This methods sets default accessors for this object as well This methods sets default accessors for this object as well
......
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