vendor/CMF/1.5.3/CMFSetup

view factory.py @ 0:3ed006215eb6

Vendor import of CMF 1.5.3
author fguillaume
date Tue, 09 Aug 2005 10:47:34 +0000
parents
children
line source
1 ##############################################################################
2 #
3 # Copyright (c) 2004 Zope Corporation and Contributors. All Rights Reserved.
4 #
5 # This software is subject to the provisions of the Zope Public License,
6 # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
7 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
8 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
9 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
10 # FOR A PARTICULAR PURPOSE.
11 #
12 ##############################################################################
13 """ Configured site factory implementation.
15 $Id: factory.py 36896 2005-04-05 15:17:18Z yuppie $
16 """
18 from Products.PageTemplates.PageTemplateFile import PageTemplateFile
20 from Products.CMFCore.utils import getToolByName
21 from Products.CMFDefault.Portal import CMFSite
23 from interfaces import EXTENSION
24 from registry import _profile_registry as profile_registry
25 from tool import SetupTool
26 from utils import _wwwdir
28 def addConfiguredSiteForm( dispatcher ):
30 """ Wrap the PTF in 'dispatcher', including 'profile_registry' in options.
31 """
32 wrapped = PageTemplateFile( 'siteAddForm', _wwwdir ).__of__( dispatcher )
34 base_profiles = []
35 extension_profiles = []
37 for info in profile_registry.listProfileInfo():
38 if info.get('type') == EXTENSION:
39 extension_profiles.append(info)
40 else:
41 base_profiles.append(info)
43 return wrapped( base_profiles=tuple(base_profiles),
44 extension_profiles =tuple(extension_profiles) )
46 def addConfiguredSite( dispatcher
47 , site_id
48 , profile_id
49 , snapshot=True
50 , RESPONSE=None
51 , extension_ids=()
52 ):
54 """ Add a CMFSite to 'dispatcher', configured according to 'profile_id'.
55 """
56 site = CMFSite( site_id )
57 dispatcher._setObject( site_id, site )
58 site = dispatcher._getOb( site_id )
60 setup_tool = SetupTool()
61 site._setObject( 'portal_setup', setup_tool )
62 setup_tool = getToolByName( site, 'portal_setup' )
64 setup_tool.setImportContext( 'profile-%s' % profile_id )
65 setup_tool.runAllImportSteps()
66 for extension_id in extension_ids:
67 setup_tool.setImportContext( 'profile-%s' % extension_id )
68 setup_tool.runAllImportSteps()
69 setup_tool.setImportContext( 'profile-%s' % profile_id )
71 if snapshot is True:
72 setup_tool.createSnapshot( 'initial_configuration' )
74 if RESPONSE is not None:
75 RESPONSE.redirect( '%s/manage_main?update_menu=1'
76 % dispatcher.absolute_url() )