Ajouts messages de retour du formulaire de demande de réinitialisation de mot de...
[Plinn.git] / profiles / default / various.py
1 ## Script (Python) "various.py"
2 ##bind container=container
3 ##bind context=context
4 ##bind namespace=
5 ##bind script=script
6 ##bind subpath=traverse_subpath
7 ##parameters=site
8 ##title=Import various Plinn setting
9 ##
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
17 #---
18
19
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'))
25
26
27 dispatcher = site.manage_addProduct
28 for m in misc :
29 try : getattr(dispatcher[m[0]], m[1])(m[2])
30 except : pass
31
32 if site.acl_users.Users.acl_users.encrypt_passwords :
33 site.acl_users.Users.acl_users.manage_setUserFolderProperties(encrypt_passwords=False)
34
35
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')
39
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
45
46 # contents
47 ttool = getToolByName(site, 'portal_types')
48 wtool = getToolByName(site, 'portal_workflow')
49
50 def constructOrSkip(*args, **kw) :
51 try : ttool.constructContent(*args, **kw)
52 except BadRequest : pass
53
54 def addBlockOrSkip(container, *args, **kw) :
55 try : container.addBlock(*args, **kw)
56 except BadRequest : pass
57
58 def doActionForOrSkip(*args, **kw) :
59 try : wtool.doActionFor(*args, **kw)
60 except WorkflowException : pass
61
62 # home page
63 constructOrSkip( 'Document', site, 'index_html'
64 , title = translate('Home')
65 , text_format='html'
66 , text=site.default_home_page_content().encode('utf-8'))
67 doActionForOrSkip(site.index_html, 'direct_publish')
68
69 # default folders
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')
76
77 # left boxes
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')
83
84 # right boxes
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')
92
93 # tools settings
94 mtool = getToolByName(site, 'portal_membership')
95 mtool.setMemberAreaPortalType('Huge Plinn Folder')
96
97 gtool = getToolByName(site, 'portal_groups')
98 gtool.setGroupWorkspaceContainerType('Plinn Folder')
99 gtool.setGroupWorkspaceType('Plinn Folder')
100
101 caltool = getToolByName(site, 'portal_calendar')
102 caltool.configureTool(['created', 'modified', 'DateTimeOriginal'], [9, 18])
103
104 # Caches
105 HTTPCache = site.HTTPCache
106 HTTPCache.manage_editProps(title='Accelerated HTTP Cache',
107 settings={'anonymous_only' : False, 'interval' : 3600,'notify_urls' : []})
108
109 gtool = getToolByName(site, 'portal_groups')
110 gtool.ZCacheable_setManagerId('rcm')
111
112 return 'Various Plinn settings imported'