From: Benoît Pin Date: Tue, 14 May 2013 20:01:24 +0000 (+0200) Subject: Problèmes d'acquisition contournés. X-Git-Url: https://scm.cri.ensmp.fr/git/MosaicDocument.git/commitdiff_plain/239d4f4fa94ff7f946206958329bf31ebc3f05a1 Problèmes d'acquisition contournés. --- diff --git a/MosaicBlockInformation.py b/MosaicBlockInformation.py index 1ff5c3a..444c791 100755 --- a/MosaicBlockInformation.py +++ b/MosaicBlockInformation.py @@ -25,6 +25,7 @@ from Globals import InitializeClass, DTMLFile from Products.CMFCore.TypesTool import FactoryTypeInformation from Products.CMFCore.utils import getToolByName from types import InstanceType +import config from AccessControl import ClassSecurityInfo, Unauthorized from Products.CMFCore.permissions import View, ModifyPortalContent, \ @@ -42,9 +43,8 @@ addMosaicBlockInformationForm = DTMLFile('dtml/addMosaicBlockForm', globals()) def addMosaicBlockInformation(self, id=None, blockType = '', metaFti = None, REQUEST=None) : """Add a MosaicBlock""" - mosaicTool = self.mosaic_tool if blockType : - metaFtis = mosaicTool.getDefaultBlockMetaFtis() + metaFtis = config.getDefaultBlockMetaFtis() if not metaFtis.has_key(blockType) : raise ValueError, "Unknown block type : %s" % blockType else : diff --git a/config.py b/config.py new file mode 100644 index 0000000..6764759 --- /dev/null +++ b/config.py @@ -0,0 +1,303 @@ +##parameters= +View = 'View' +ModifyPortalContent = 'Modify portal content' + + +# Mosaic Document regular fti +mosaicDocument_fti = {'id' : 'Mosaic Document', + 'title' : 'Mosaic Document', + 'content_icon' : 'mosaic_icon.png', + 'product' : 'MosaicDocument', + 'factory' : 'addMosaicDocument', + 'meta_type' : 'Mosaic Document', + 'immediate_view' : 'metadata_edit_form', + 'allow_discussion' : 1, + 'filter_content_types' : 0, + 'actions' : ( + {'id': 'view', + 'title': 'View', + 'action': 'mosaicdocument_view', + 'visible' : 1, + 'permissions': (View,)}, + + {'id': 'edit', + 'title': 'Edit', + 'action': 'mosaicdocument_edit_form', + 'visible' : 1, + 'permissions': (ModifyPortalContent,)}, + + {'id': 'metadata', + 'title': 'Metadata', + 'action': 'metadata_edit_form', + 'visible': 1, + 'permissions': ()},), + } + +# fixed fti part for basic blocks definitions +fixedFtiPart = {'product' : 'MosaicDocument', + 'factory' : 'addMosaicBlock', + 'immediate_view' : 'view', + 'filter_content_types' : 1, + } + +defaultActions = ({'id' : 'view', + 'title' : 'view', + 'action' : 'view', + 'permissions' : (View,), + 'category' : 'object', + },) + +# basic blocks definitions +metaFtis = ( + {'id': 'Image Block', + 'title': 'Image block', + 'icon': 'mosaic_tool/image_block_icon.gif', + 'meta_type': 'Image Block', + 'filter_content_types': 1, + 'allowed_content_types': (), + 'template' : 'mosaic_tool/block_image_template', + 'notify_wf' : 0, + 'slots' : ( + {'id': 'image', + 'type': 'Image Slot', + 'args': + {'thumb_width' : {'type' : 'int', 'value' : 440}, + 'thumb_height' : {'type' : 'int', 'value' : 440}, + 'blankThumbnail' : {'type' : 'string', 'value' : 'mosaic_tool/no_image.jpg'}, + } + }, + ), + 'rules' : (), + 'actions' : defaultActions, + }, + + {'id': 'Two Images Block', + 'title': 'Two images block', + 'icon': 'mosaic_tool/image_block_icon.gif', + 'meta_type': 'Two Images Block', + 'filter_content_types': 1, + 'allowed_content_types': (), + 'template' : 'mosaic_tool/block_two_images_template', + 'notify_wf' : 0, + 'slots' : ( + {'id': 'image', + 'type': 'Image Slot', + 'args': + {'thumb_width' : {'type' : 'int', 'value' : 440}, + 'thumb_height' : {'type' : 'int', 'value' : 440}, + 'blankThumbnail' : {'type' : 'string', 'value' : 'mosaic_tool/no_image.jpg'}, + } + }, + {'id': 'image2', + 'type': 'Image Slot', + 'args': + {'thumb_width' : {'type' : 'int', 'value' : 440}, + 'thumb_height' : {'type' : 'int', 'value' : 440}, + 'blankThumbnail' : {'type' : 'string', 'value' : 'mosaic_tool/no_image.jpg'}, + } + } + ), + 'rules' : (), + 'actions' : defaultActions, + }, + + {'id': 'Text Block', + 'title': 'Text block', + 'icon': 'mosaic_tool/image_block_icon.gif', + 'meta_type': 'Text Block', + 'filter_content_types': 1, + 'allowed_content_types': (), + 'template' : 'mosaic_tool/block_text_template', + 'notify_wf' : 0, + 'slots' : ( + {'id' : 'text', + 'type' : 'Text Slot', + 'args' : + {'text' : {'type' : 'text', 'value' : ''}, + 'text_format' : {'type' : 'string', 'value' : 'structured-text'}, + 'cols' : {'type' : 'int', 'value' : 68}, + 'rows' : {'type' : 'int', 'value' : 20}, + } + }, + ), + 'rules' : (), + 'actions' : defaultActions, + }, + + {'id': 'File Block', + 'title': 'File Block', + 'icon': 'mosaic_tool/image_block_icon.gif', + 'meta_type': 'File Block', + 'filter_content_types': 1, + 'allowed_content_types': (), + 'template' : 'mosaic_tool/block_file_template', + 'notify_wf' : 0, + 'slots' : ( + {'id': 'file', + 'type': 'File Slot', + 'args': {}, + }, + ), + 'rules' : (), + 'actions' : defaultActions, + }, + + {'id': 'Spacer Block', + 'title': 'Spacer block', + 'icon': 'mosaic_tool/image_block_icon.gif', + 'meta_type': 'Spacer Block', + 'filter_content_types': 1, + 'allowed_content_types': (), + 'template' : 'mosaic_tool/block_spacer_template', + 'notify_wf' : 0, + 'slots' : ( + {'id': 'space', + 'type': 'Spacer Slot', + 'args': {'nbOfSpaces' : {'type' : 'int', 'value' : 3},}, + }, + ), + 'rules' : (), + 'actions' : defaultActions, + }, + + {'id': 'Section Block', + 'title': 'Section block', + 'icon': 'mosaic_tool/image_block_icon.gif', + 'meta_type': 'Section Block', + 'filter_content_types': 1, + 'allowed_content_types': (), + 'template' : 'mosaic_tool/block_section_template', + 'notify_wf' : 0, + 'slots' : ( + {'id': 'section', + 'type': 'String Slot', + 'args': + {'text' : {'type' : 'string', 'value' : ''}, + 'size' : {'type' : 'int', 'value' : 60}, + 'choices' : {'type' : 'lines', 'value' : []}, + 'castOperator' : {'type' : 'string', 'value' : 'string'}, + }, + }, + ), + 'rules' : (), + 'actions' : defaultActions, + }, + + + {'id': 'Container Block', + 'title': 'Container block', + 'icon': 'mosaic_tool/image_block_icon.gif', + 'meta_type': 'Container Block', + 'filter_content_types': 1, + 'allowed_content_types': (), + 'actions' : defaultActions, + }, + +## Boxes blocks + {'id': 'Tree Box Block', + 'title': 'Tree Box Block', + 'icon': 'mosaic_tool/tree_block_icon.gif', + 'meta_type': 'Tree Box Block', + 'filter_content_types': 1, + 'allowed_content_types': (), + 'template' : 'mosaic_tool/tree_block_template', + 'notify_wf' : 0, + 'slots' : ( + {'id': 'rootObject', + 'type': 'String Slot', + 'args': + {'text' : {'type' : 'expr', 'value' : 'portal'}, + 'size' : {'type' : 'int', 'value' : 45}, + 'castOperator' : {'type' : 'string', 'value' : 'expr'}, + }, + }, + {'id': 'filteredMetaTypes', + 'type': 'List Slot', + 'args': + {'text' : {'type' : 'lines', 'value' : 'Plinn Folder'}, + 'cols' : {'type' : 'int', 'value' : 15}, + 'rows' : {'type' : 'int', 'value' : 5}, + 'castOperator' : {'type' : 'string', 'value' : 'lines'}, + }, + }, + ), + 'rules' : (), + 'actions' : defaultActions, + }, + + {'id': 'Action Box Block', + 'title': 'Action Box Block', + 'icon': 'mosaic_tool/action_block_icon.gif', + 'meta_type': 'Action Box Block', + 'filter_content_types': 1, + 'allowed_content_types': (), + 'template' : 'mosaic_tool/action_block_template', + 'notify_wf' : 0, + 'slots' : ( + {'id': 'boxTitle', + 'type': 'String Slot', + 'args': + {'text' : {'type' : 'string', 'value' : ''}, + 'size' : {'type' : 'int', 'value' : 45}, + 'castOperator' : {'type' : 'string', 'value' : 'string'}, + }, + }, + {'id': 'categories', + 'type': 'String Slot', + 'args': + {'text' : {'type' : 'tokens', 'value' : 'global'}, + 'size' : {'type' : 'int', 'value' : 45}, + 'castOperator' : {'type' : 'string', 'value' : 'tokens'}, + }, + }, + ), + 'rules' : (), + 'actions' : defaultActions, + }, + + ) + +metaFtisDic = {} +for mfti in metaFtis : + tempDic = mfti.copy() + mfti.update(fixedFtiPart) + metaFtisDic[tempDic['id']] = mfti + +# adding Mosaic Document block definition +metaFtisDic[mosaicDocument_fti['id']] = mosaicDocument_fti + +def completeMetaFti(dummyFti, + metaFtis, + slots = (), + template = '', + notify_wf = 0) : + allRules = () + for mfti in metaFtis : + rulesDic = {'blockType' : mfti['id'], + 'maxNbInstance' : 0, + 'allowMove' : 1, + 'mode' : 'wd', + }, + allRules += rulesDic + + ftiExtension = {'rules' : allRules, + 'slots' : (), + 'template' : template, + 'notify_wf' : 1, + } + ftiExtension.update(dummyFti) + return ftiExtension + +# complete meta fti for Mosaic Document block definition +metaFtisDic[mosaicDocument_fti['id']] = completeMetaFti(metaFtisDic[mosaicDocument_fti['id']], + metaFtis, + notify_wf = 1) + +# Idem for Container Block definition +metaFtisDic['Container Block'] = completeMetaFti(metaFtisDic['Container Block'], + metaFtis, + template = 'mosaic_tool/block_container_template') + + +def getDefaultBlockMetaFtis() : + return metaFtisDic