Commit ad1b9457 authored by Jean-Paul Smets's avatar Jean-Paul Smets

factory_information now auto generated


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@1071 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 86c28b9c
...@@ -319,6 +319,59 @@ def writeLocalDocument(class_id, text): ...@@ -319,6 +319,59 @@ def writeLocalDocument(class_id, text):
f = open(path, 'w') f = open(path, 'w')
f.write(text) 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): def importLocalDocument(class_id, document_path = None):
""" """
Imports a document class and registers it as Imports a document class and registers it as
...@@ -344,16 +397,7 @@ def importLocalDocument(class_id, document_path = None): ...@@ -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 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, class_id, document_module)
setattr(Products.ERP5Type.Document, document_constructor_name, document_constructor) setattr(Products.ERP5Type.Document, document_constructor_name, document_constructor)
if not hasattr(document_class, 'isPortalContent'): setDefaultClassProperties(document_class)
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 = ()
pr=PermissionRole(document_class.add_permission, default_permission) pr=PermissionRole(document_class.add_permission, default_permission)
initializeDefaultProperties([document_class]) initializeDefaultProperties([document_class])
InitializeClass(document_class) InitializeClass(document_class)
...@@ -576,6 +620,7 @@ def initializeDefaultProperties(klasses): ...@@ -576,6 +620,7 @@ def initializeDefaultProperties(klasses):
""" """
for klass in klasses: for klass in klasses:
if getattr(klass, 'isRADContent', 0): if getattr(klass, 'isRADContent', 0):
setDefaultClassProperties(klass)
setDefaultProperties(klass) setDefaultProperties(klass)
def setDefaultProperties(klass): def setDefaultProperties(klass):
......
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