From ad1b9457298745e78a5870421fe37f0c3df74362 Mon Sep 17 00:00:00 2001 From: Jean-Paul Smets <jp@nexedi.com> Date: Wed, 23 Jun 2004 13:45:11 +0000 Subject: [PATCH] factory_information now auto generated git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@1071 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5Type/Utils.py | 65 +++++++++++++++++++++++++++++++++------ 1 file changed, 55 insertions(+), 10 deletions(-) diff --git a/product/ERP5Type/Utils.py b/product/ERP5Type/Utils.py index ed8571e67e..063bc312ac 100755 --- a/product/ERP5Type/Utils.py +++ b/product/ERP5Type/Utils.py @@ -319,6 +319,59 @@ def writeLocalDocument(class_id, text): f = open(path, 'w') f.write(text) +def setDefaultClassProperties(document_class): + if not hasattr(document_class, 'isPortalContent'): + document_class.isPortalContent = 1 + if not hasattr(document_class, 'isRADContent'): + document_class.isRADContent = 1 + if not hasattr(document_class, 'add_permission'): + document_class.add_permission = Permissions.AddPortalContent + if not hasattr(document_class, '__implements__'): + document_class.__implements__ = () + if not hasattr(document_class, 'property_sheets'): + document_class.property_sheets = () + # Add default factory type information + if not hasattr(document_class, 'factory_type_information') and \ + hasattr(document_class, 'meta_type') and hasattr(document_class, 'portal_type'): + document_class.factory_type_information = \ + { 'id' : document_class.portal_type + , 'meta_type' : document_class.meta_type + , 'description' : getattr(document_class, '__doc__', "Type generated by ERPType") + , 'icon' : 'document.gif' + , 'product' : 'ERP5Type' + , 'factory' : 'add%s' % document_class.__name__ + , 'immediate_view' : '%s_view' % document_class.__name__ + , 'actions' : + ( { 'id' : 'view' + , 'name' : 'View' + , 'category' : 'object_view' + , 'action' : '%s_view' % document_class.__name__ + , 'permissions' : ( Permissions.View, ) + } + , { 'id' : 'print' + , 'name' : 'Print' + , 'category' : 'object_print' + , 'action' : '%s_print' % document_class.__name__ + , 'permissions' : ( + Permissions.View, ) + } + , { 'id' : 'metadata' + , 'name' : 'Metadata' + , 'category' : 'object_view' + , 'action' : 'metadata_view' + , 'permissions' : ( + Permissions.View, ) + } + , { 'id' : 'translate' + , 'name' : 'Translate' + , 'category' : 'object_action' + , 'action' : 'translation_template_view' + , 'permissions' : ( + Permissions.TranslateContent, ) + } + ) + } + def importLocalDocument(class_id, document_path = None): """ Imports a document class and registers it as @@ -344,16 +397,7 @@ def importLocalDocument(class_id, document_path = None): document_constructor.__roles__=None # XXX This is a security breach which needs to be fixed setattr(Products.ERP5Type.Document, class_id, document_module) setattr(Products.ERP5Type.Document, document_constructor_name, document_constructor) - if not hasattr(document_class, 'isPortalContent'): - document_class.isPortalContent = 1 - if not hasattr(document_class, 'isRADContent'): - document_class.isRADContent = 1 - if not hasattr(document_class, 'add_permission'): - document_class.add_permission = Permissions.AddPortalContent - if not hasattr(document_class, '__implements__'): - document_class.__implements__ = () - if not hasattr(document_class, 'property_sheets'): - document_class.property_sheets = () + setDefaultClassProperties(document_class) pr=PermissionRole(document_class.add_permission, default_permission) initializeDefaultProperties([document_class]) InitializeClass(document_class) @@ -576,6 +620,7 @@ def initializeDefaultProperties(klasses): """ for klass in klasses: if getattr(klass, 'isRADContent', 0): + setDefaultClassProperties(klass) setDefaultProperties(klass) def setDefaultProperties(klass): -- 2.30.9