From a2f9eb22acc5c7349956ff990d135a7b321f59d7 Mon Sep 17 00:00:00 2001 From: Jean-Paul Smets <jp@nexedi.com> Date: Sun, 8 Jun 2008 19:21:48 +0000 Subject: [PATCH] Ongoing development added to code base with switches in order not to break existing systems. git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@21412 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5/Document/PDFTypeInformation.py | 59 ++++---- product/ERP5Type/ERP5Type.py | 148 ++++++++++++++------ product/ERP5Type/Tool/TypesTool.py | 2 +- product/ERP5Type/__init__.py | 16 ++- product/ERP5Type/patches/PropertyManager.py | 7 +- 5 files changed, 161 insertions(+), 71 deletions(-) diff --git a/product/ERP5/Document/PDFTypeInformation.py b/product/ERP5/Document/PDFTypeInformation.py index c3bcef091e..5785bb1149 100644 --- a/product/ERP5/Document/PDFTypeInformation.py +++ b/product/ERP5/Document/PDFTypeInformation.py @@ -28,22 +28,14 @@ from AccessControl import ClassSecurityInfo from Products.CMFCore.utils import getToolByName from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface -from Products.ERP5Type.XMLObject import XMLObject -from Products.ERP5Type.ERP5Type import ERP5TypeInformation +from Products.ERP5Type import USE_BASE_TYPE -class PDFTypeInformation(XMLObject, ERP5TypeInformation): +if not USE_BASE_TYPE: + from Products.ERP5Type.XMLObject import XMLObject + + class PDFTypeInformation(XMLObject): """ - EXPERIMENTAL - DO NOT USE THIS CLASS BESIDES R&D - - A Type Information class which (will) implement - all PDF Editor related methods in a more generic - way. - - WARNING: the XMLObject inheritance is only there - to prevent breaking existing systems. It - must be removed from inheritance chain for this - class to be used. However, we are not planning to - commit it. + Dummy class """ # CMF Type Definition meta_type = 'ERP5 PDF Type Information' @@ -51,15 +43,32 @@ class PDFTypeInformation(XMLObject, ERP5TypeInformation): isPortalContent = 1 isRADContent = 1 - # Declarative security - security = ClassSecurityInfo() - security.declareObjectProtected(Permissions.AccessContentsInformation) +else: + from Products.ERP5Type.ERP5Type import ERP5TypeInformation - # Default Properties - property_sheets = ( PropertySheet.Base - , PropertySheet.XMLObject - , PropertySheet.CategoryCore - , PropertySheet.SimpleItem - , PropertySheet.Folder - , PropertySheet.BaseType - ) + class PDFTypeInformation(ERP5TypeInformation): + """ + EXPERIMENTAL - DO NOT USE THIS CLASS BESIDES R&D + + A Type Information class which (will) implement + all PDF Editor related methods in a more generic + way. + """ + # CMF Type Definition + meta_type = 'ERP5 PDF Type Information' + portal_type = 'PDF Type' + isPortalContent = 1 + isRADContent = 1 + + # Declarative security + security = ClassSecurityInfo() + security.declareObjectProtected(Permissions.AccessContentsInformation) + + # Default Properties + property_sheets = ( PropertySheet.Base + , PropertySheet.XMLObject + , PropertySheet.CategoryCore + , PropertySheet.SimpleItem + , PropertySheet.Folder + , PropertySheet.BaseType + ) diff --git a/product/ERP5Type/ERP5Type.py b/product/ERP5Type/ERP5Type.py index 9311f7516e..1b4fed07fb 100644 --- a/product/ERP5Type/ERP5Type.py +++ b/product/ERP5Type/ERP5Type.py @@ -39,6 +39,7 @@ from Products.CMFCore.utils import _checkPermission from Products.ERP5Type import PropertySheet from Products.ERP5Type import _dtmldir from Products.ERP5Type import Permissions +from Products.ERP5Type import USE_BASE_TYPE from Products.ERP5Type.UnrestrictedMethod import UnrestrictedMethod # Security uses ERP5Security by default @@ -65,9 +66,9 @@ from Products.CMFCore.exceptions import zExceptions_Unauthorized ERP5TYPE_SECURITY_GROUP_ID_GENERATION_SCRIPT = 'ERP5Type_asSecurityGroupId' -class ERP5TypeInformation( FactoryTypeInformation, - RoleProviderBase, - TranslationProviderBase ): +class ERP5TypeInformationMixIn( FactoryTypeInformation, + RoleProviderBase, + TranslationProviderBase ): """ ERP5 Types are based on FactoryTypeInformation @@ -81,8 +82,8 @@ class ERP5TypeInformation( FactoryTypeInformation, """ __implements__ = ITypeInformation - meta_type = 'ERP5 Type Information' + security = ClassSecurityInfo() manage_options = ( SimpleItemWithProperties.manage_options[:1] @@ -92,7 +93,8 @@ class ERP5TypeInformation( FactoryTypeInformation, + SimpleItemWithProperties.manage_options[1:] ) - _properties = (TypeInformation._basic_properties + ( + if not USE_BASE_TYPE: + _properties = (TypeInformation._basic_properties + ( {'id':'factory', 'type': 'string', 'mode':'w', 'label':'Product factory method'}, {'id':'permission', 'type': 'string', 'mode':'w', @@ -315,19 +317,6 @@ class ERP5TypeInformation( FactoryTypeInformation, return ob - security.declareProtected(Permissions.AccessContentsInformation, - 'getPropertySheetList') - def getPropertySheetList( self ): - """ - Return list of content types. - XXX I (seb) think the name is bad - (jp) yes, the name is bad, it should be getAvailablePropertySheetList - """ - result = Products.ERP5Type.PropertySheet.__dict__.keys() - result = filter(lambda k: not k.startswith('__'), result) - result.sort() - return result - security.declareProtected(Permissions.ManagePortal, 'setPropertySheetList') def setPropertySheetList( self, property_sheet_list): @@ -344,26 +333,6 @@ class ERP5TypeInformation( FactoryTypeInformation, """ return self.hidden_content_type_list - security.declareProtected(Permissions.AccessContentsInformation, - 'getBaseCategoryList') - def getBaseCategoryList( self ): - result = self.portal_categories.getBaseCategoryList() - result.sort() - return result - - security.declareProtected(Permissions.AccessContentsInformation, - 'getConstraintList') - def getConstraintList( self ): - result = Products.ERP5Type.Constraint.__dict__.keys() - result = filter(lambda k: k != 'Constraint' and not k.startswith('__'), - result) - result.sort() - return result - - security.declareProtected(Permissions.AccessContentsInformation, - 'getGroupList') - def getGroupList( self ): - return self.defined_group_list security.declareProtected(Permissions.AccessContentsInformation, 'getInstanceBaseCategoryList') @@ -780,7 +749,107 @@ class ERP5TypeInformation( FactoryTypeInformation, search_source_list.extend([ri.id, ri.title, ri.description, ri.getCondition(), ri.base_category_script ]) return ' '.join(search_source_list) + +if USE_BASE_TYPE: + from Products.ERP5Type.XMLObject import XMLObject + + class ERP5TypeInformation(XMLObject, + ERP5TypeInformationMixIn): + """ + EXPERIMENTAL - DO NOT USE THIS CLASS BESIDES R&D + """ + portal_type = 'Base Type' + isPortalContent = 1 + isRADContent = 1 + + security = ClassSecurityInfo() + + # Declarative properties + property_sheets = ( PropertySheet.Base + , PropertySheet.XMLObject + , PropertySheet.SimpleItem + , PropertySheet.Folder + , PropertySheet.BaseType + ) + + def getTypeInfo(self, *args): + if not len(args): + return XMLObject.getTypeInfo(self) + else: + return self.getParentValue().getTypeInfo(self, args[0]) + + security.declareProtected(Permissions.AccessContentsInformation, + 'getPortalPropertySheetList') + def getPortalPropertySheetList( self ): + """ + Return list of content types. + XXX I (seb) think the name is bad + (jp) yes, the name is bad, it should be getAvailablePropertySheetList + """ + result = Products.ERP5Type.PropertySheet.__dict__.keys() + result = filter(lambda k: not k.startswith('__'), result) + result.sort() + return result + + security.declareProtected(Permissions.AccessContentsInformation, + 'getPortalBaseCategoryList') + def getPortalBaseCategoryList( self ): + result = self.portal_categories.getBaseCategoryList() + result.sort() + return result + + security.declareProtected(Permissions.AccessContentsInformation, + 'getPortalConstraintList') + def getPortalConstraintList( self ): + result = Products.ERP5Type.Constraint.__dict__.keys() + result = filter(lambda k: k != 'Constraint' and not k.startswith('__'), + result) + result.sort() + return result + + security.declareProtected(Permissions.AccessContentsInformation, + 'getPortalTypeGroupList') + def getPortalTypeGroupList( self ): + return self.defined_group_list + +else: + class ERP5TypeInformation(ERP5TypeInformationMixIn): + + security = ClassSecurityInfo() + security.declareProtected(Permissions.AccessContentsInformation, + 'getPropertySheetList') + def getPropertySheetList( self ): + """ + Return list of content types. + XXX I (seb) think the name is bad + (jp) yes, the name is bad, it should be getAvailablePropertySheetList + """ + result = Products.ERP5Type.PropertySheet.__dict__.keys() + result = filter(lambda k: not k.startswith('__'), result) + result.sort() + return result + + security.declareProtected(Permissions.AccessContentsInformation, + 'getBaseCategoryList') + def getBaseCategoryList( self ): + result = self.portal_categories.getBaseCategoryList() + result.sort() + return result + + security.declareProtected(Permissions.AccessContentsInformation, + 'getConstraintList') + def getConstraintList( self ): + result = Products.ERP5Type.Constraint.__dict__.keys() + result = filter(lambda k: k != 'Constraint' and not k.startswith('__'), + result) + result.sort() + return result + + security.declareProtected(Permissions.AccessContentsInformation, + 'getGroupList') + def getGroupList( self ): + return self.defined_group_list InitializeClass( ERP5TypeInformation ) @@ -799,6 +868,3 @@ Products.CMFCore.TypesTool.typeClasses.append( 'action':'manage_addERP5TIForm', 'permission':'Manage portal'}, ) Products.CMFCore.TypesTool.TypesTool.manage_addERP5TIForm = manage_addERP5TIForm - - -# vim: filetype=python syntax=python shiftwidth=2 diff --git a/product/ERP5Type/Tool/TypesTool.py b/product/ERP5Type/Tool/TypesTool.py index c4cc5dad91..cb1eb9dc45 100644 --- a/product/ERP5Type/Tool/TypesTool.py +++ b/product/ERP5Type/Tool/TypesTool.py @@ -24,7 +24,7 @@ from Acquisition import aq_base class TypesTool(BaseTool, CMFCoreTypesTool): """ - EXPERIMENTAL - DO NOT USE THIS PROPERTYSHEET BESIDES R&D + EXPERIMENTAL - DO NOT USE THIS CLASS BESIDES R&D """ id = 'portal_types' diff --git a/product/ERP5Type/__init__.py b/product/ERP5Type/__init__.py index 6763a22bf8..031bafe090 100644 --- a/product/ERP5Type/__init__.py +++ b/product/ERP5Type/__init__.py @@ -29,6 +29,9 @@ ERP5Type is provides a RAD environment for Zope / CMF All ERP5 classes derive from ERP5Type """ +# Switch(es) for ongoing development which require single code base +USE_BASE_TYPE = False +USE_INTERACTOR = False # Update ERP5 Globals import sys, Permissions, os @@ -57,17 +60,23 @@ def allowClassTool(): def initialize( context ): # Import Product Components from Tool import ClassTool, CacheTool, MemcachedTool, SessionTool + if USE_BASE_TYPE: + from Tool import TypesTool import Document import Base, XMLObject from ERP5Type import ERP5TypeInformation # Define documents, classes, constructors and tools object_classes = () content_constructors = () - content_classes = ( Base.Base, XMLObject.XMLObject, ) + content_classes = ( Base.Base, XMLObject.XMLObject) portal_tools = ( ClassTool.ClassTool, CacheTool.CacheTool, MemcachedTool.MemcachedTool, - SessionTool.SessionTool ) + SessionTool.SessionTool, + ) + if USE_BASE_TYPE: + content_classes = content_classes + (ERP5TypeInformation,) + portal_tools = portal_tools + (TypesTool.TypesTool, ) # Do initialization step initializeProduct(context, this_module, globals(), document_module = Document, @@ -88,6 +97,9 @@ def initialize( context ): # We should register local classes at some point from Products.ERP5Type.Utils import initializeLocalDocumentRegistry initializeLocalDocumentRegistry() + # Experimental Interactor + if USE_INTERACTOR: + import Interactor from AccessControl.SecurityInfo import allow_module from AccessControl.SecurityInfo import ModuleSecurityInfo diff --git a/product/ERP5Type/patches/PropertyManager.py b/product/ERP5Type/patches/PropertyManager.py index 517237449d..ed6c884204 100644 --- a/product/ERP5Type/patches/PropertyManager.py +++ b/product/ERP5Type/patches/PropertyManager.py @@ -16,8 +16,10 @@ from OFS.PropertyManager import PropertyManager, type_converters from OFS.PropertyManager import escape from Globals import DTMLFile +from Products.ERP5Type import USE_BASE_TYPE from Products.ERP5Type.Utils import createExpressionContext -from Products.ERP5Type.ERP5Type import ERP5TypeInformation +if not USE_BASE_TYPE: + from Products.ERP5Type.ERP5Type import ERP5TypeInformation from Products.CMFCore.Expression import Expression from Products.ERP5Type import _dtmldir from Acquisition import aq_base @@ -192,7 +194,8 @@ PropertyManager._propertyMap = PropertyManager_propertyMap PropertyManager.propdict = PropertyManager_propdict PropertyManager.hasProperty = PropertyManager_hasProperty PropertyManager.getProperty = PropertyManager_getProperty -ERP5TypeInformation.manage_propertiesForm = PropertyManager_manage_propertiesForm +if not USE_BASE_TYPE: + ERP5TypeInformation.manage_propertiesForm = PropertyManager_manage_propertiesForm from ZPublisher.Converters import type_converters, field2string -- 2.30.9