1 ## Script (Python) "various.py"
2 ##bind container=container
6 ##bind subpath=traverse_subpath
8 ##title=Import various Plinn setting
10 from Products
.CMFCore
.utils
import getToolByName
11 from Products
.CMFCore
.exceptions
import BadRequest
12 from Products
.Plinn
.exceptions
import WorkflowException
13 # TODO : CMF-2.1 compat
14 #from Products.PlacelessTranslationService.MessageID import MessageIDFactory
15 #_ = MessageIDFactory('plinn')
16 translate
= lambda msg
: msg
20 # constructs misc objects
21 # (productName, factory, id)
22 misc
=(('StandardCacheManagers', 'manage_addAcceleratedHTTPCacheManager', 'HTTPCache'),
23 ('StandardCacheManagers', 'manage_addRAMCacheManager', 'rcm'),
24 ('GroupUserFolder', 'manage_addGroupUserFolder', 'acl_users'))
27 dispatcher
= site
.manage_addProduct
29 try : getattr(dispatcher
[m
[0]], m
[1])(m
[2])
32 if site
.acl_users
.Users
.acl_users
.encrypt_passwords
:
33 site
.acl_users
.Users
.acl_users
.manage_setUserFolderProperties(encrypt_passwords
=False)
36 # configure mosaicTool
37 blockTypes
= ('Action Box Block', 'Container Block', 'File Block', 'Image Block', 'Mosaic Document',
38 'Section Block', 'Spacer Block', 'Text Block', 'Tree Box Block')
40 mostool
= getToolByName(site
, 'mosaic_tool')
41 addBI
= mostool
.manage_addProduct
['MosaicDocument'].addMosaicBlockInformation
42 for bt
in blockTypes
:
43 try : addBI(blockType
=bt
)
44 except BadRequest
: pass
47 ttool
= getToolByName(site
, 'portal_types')
48 wtool
= getToolByName(site
, 'portal_workflow')
50 def constructOrSkip(*args
, **kw
) :
51 try : ttool
.constructContent(*args
, **kw
)
52 except BadRequest
: pass
54 def addBlockOrSkip(container
, *args
, **kw
) :
55 try : container
.addBlock(*args
, **kw
)
56 except BadRequest
: pass
58 def doActionForOrSkip(*args
, **kw
) :
59 try : wtool
.doActionFor(*args
, **kw
)
60 except WorkflowException
: pass
63 constructOrSkip( 'Document', site
, 'index_html'
64 , title
= translate('Home')
66 , text
=site
.default_home_page_content())
67 doActionForOrSkip(site
.index_html
, 'direct_publish')
70 constructOrSkip('Plinn Folder', site
, 'Members', title
= translate('Members'))
71 #constructOrSkip('Plinn Folder', site, 'global_settings', title = translate('Portlets'))
72 if not hasattr(site
, 'global_settings') :
73 site
.manage_addProduct
['OFSP'].manage_addFolder('global_settings')
74 if not site
.global_settings
.hasProperty('noIndex'):
75 site
.global_settings
.manage_addProperty('noIndex', True, 'boolean')
78 constructOrSkip('Mosaic Document', site
.global_settings
, 'left_boxes', title
=translate('Left boxes'))
79 lb
= site
.global_settings
.left_boxes
80 addBlockOrSkip(lb
, 'Tree Box Block', 0, id='nav_tree')
81 lb
.nav_tree
.saveBlock(filteredMetaTypes
={'text' : ['Plinn Folder', 'Portfolio', 'Topic']})
82 doActionForOrSkip(lb
, 'direct_publish')
85 constructOrSkip('Mosaic Document', site
.global_settings
, 'right_boxes', title
=translate('Right boxes'))
86 rb
= site
.global_settings
.right_boxes
87 addBlockOrSkip(rb
, 'Action Box Block', 0, id='global_actions')
88 rb
.global_actions
.saveBlock(boxTitle
={'text' : translate('Global actions')}, categories
={'text' : ['global']})
89 addBlockOrSkip(rb
, 'Action Box Block', 0, id='workflow_actions')
90 rb
.workflow_actions
.saveBlock(boxTitle
={'text' : translate('Workflow')}, categories
={'text' : ['workflow']})
91 doActionForOrSkip(rb
, 'direct_publish')
94 mtool
= getToolByName(site
, 'portal_membership')
95 mtool
.setMemberAreaPortalType('Plinn Folder')
97 gtool
= getToolByName(site
, 'portal_groups')
98 gtool
.setGroupWorkspaceContainerType('Plinn Folder')
99 gtool
.setGroupWorkspaceType('Plinn Folder')
101 caltool
= getToolByName(site
, 'portal_calendar')
102 caltool
.configureTool(['created', 'modified', 'DateTimeOriginal'], [9, 18])
104 pimtool
= getToolByName(site
, 'portal_image_manipulation')
105 if not pimtool
.hasObject('image') :
106 pimtool
.manage_addProduct
['OFSP'].manage_addFolder('image')
107 if not pimtool
.hasObject('tile') :
108 pimtool
.manage_addProduct
['OFSP'].manage_addFolder('tile')
110 ctool
= getToolByName(site
, 'portal_catalog')
111 if not 'position' in ctool
.indexes() :
112 ctool
.manage_addProduct
['ProxyIndex'].manage_addProxyIndex('position',
113 extra
= { 'idx_type' : 'FieldIndex'
114 , 'value_expr' : 'python:object.getParentNode().getObjectPosition(object.getId())'})
117 HTTPCache
= site
.HTTPCache
118 HTTPCache
.manage_editProps(title
='Accelerated HTTP Cache',
119 settings
={'anonymous_only' : False, 'interval' : 3600,'notify_urls' : []})
121 gtool
= getToolByName(site
, 'portal_groups')
122 gtool
.ZCacheable_setManagerId('rcm')
124 return 'Various Plinn settings imported'