diff --git a/product/ERP5Type/Utils.py b/product/ERP5Type/Utils.py index ed8571e67ebaf82372bba0dce42e4811ae96f6bb..063bc312ac3e44c322c384699d480db26618aee3 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):