Commit 2fa7eb24 authored by Nicolas Dumazet's avatar Nicolas Dumazet

AccessorHolderType meta class, and clear fromPropertyHolder factory


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@42809 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent f8cba738
......@@ -37,7 +37,7 @@ from Products.ERP5Type.Base import PropertyHolder
from Products.CMFCore.utils import getToolByName
from Products.CMFCore.Expression import Expression
from Products.ERP5Type.dynamic.accessor_holder import _createAccessorHolderFromPropertyHolder
from Products.ERP5Type.dynamic.accessor_holder import AccessorHolderType
from zLOG import LOG, ERROR, INFO
......@@ -191,7 +191,7 @@ class PropertySheetTool(BaseTool):
property_holder._categories = getattr(property_sheet, '_categories', [])
property_holder._constraints = getattr(property_sheet, '_constraints', [])
return _createCommonPropertySheetAccessorHolder(
return AccessorHolderType.fromPropertyHolder(
self.getPortalObject(),
property_holder,
'erp5.filesystem_accessor_holder')
......@@ -215,7 +215,7 @@ class PropertySheetTool(BaseTool):
property_holder._categories, \
property_holder._constraints = definition_tuple
return _createAccessorHolderFromPropertyHolder(
return AccessorHolderType.fromPropertyHolder(
self.getPortalObject(),
property_holder,
'erp5.accessor_holder')
......
......@@ -29,8 +29,7 @@
This module should include most code related to the generation of
Accessor Holders, that is, generation of methods for ERP5
* Ideally, PropertyHolder class should be defined here, as well
as a base class for all erp5.accessor_holder Accessor Holders.
* Ideally, PropertyHolder class should be defined here
* Utils, Property Sheet Tool can be probably be cleaned up as well by
moving specialized code here.
"""
......@@ -43,13 +42,15 @@ from Products.ERP5Type.Globals import InitializeClass
from zLOG import LOG, ERROR, INFO
def _createAccessorHolderFromPropertyHolder(property_holder,
portal,
accessor_holder_module_name):
class AccessorHolderType(type):
@classmethod
def fromPropertyHolder(meta_type,
property_holder,
portal=None,
accessor_holder_module_name=None):
"""
Create a new accessor holder class from the given Property Holder
within the given accessor holder module (when the migration will
be finished, there should only be one accessor holder module)
within the given accessor holder module
"""
property_sheet_id = property_holder.__name__
setDefaultClassProperties(property_holder)
......@@ -67,7 +68,7 @@ def _createAccessorHolderFromPropertyHolder(property_holder,
raise
# Create the new accessor holder class and set its module properly
accessor_holder_class = type(property_sheet_id, (object,), dict(
accessor_holder_class = meta_type(property_sheet_id, (object,), dict(
__module__ = accessor_holder_module_name,
constraints = property_holder.constraints,
# The following attributes have been defined only because they
......@@ -136,7 +137,7 @@ def _generateBaseAccessorHolder(portal,
econtext,
base_category_list)
accessor_holder = _createAccessorHolderFromPropertyHolder(
accessor_holder = AccessorHolderType.fromPropertyHolder(
property_holder,
portal,
'erp5.accessor_holder',
......@@ -172,7 +173,7 @@ def _generatePreferenceToolAccessorHolder(portal, accessor_holder_list,
if read_permission:
property_holder.declareProtected(read_permission, attribute_name)
accessor_holder = _createAccessorHolderFromPropertyHolder(
accessor_holder = AccessorHolderType.fromPropertyHolder(
property_holder,
portal,
'erp5.accessor_holder',
......
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