1 # -*- coding: utf-8 -*-
2 #######################################################################################
3 # Plinn - http://plinn.org #
4 # Copyright (C) 2005-2007 Benoît PIN <benoit.pin@ensmp.fr> #
6 # This program is free software; you can redistribute it and/or #
7 # modify it under the terms of the GNU General Public License #
8 # as published by the Free Software Foundation; either version 2 #
9 # of the License, or (at your option) any later version. #
11 # This program is distributed in the hope that it will be useful, #
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
14 # GNU General Public License for more details. #
16 # You should have received a copy of the GNU General Public License #
17 # along with this program; if not, write to the Free Software #
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #
19 #######################################################################################
20 """ Plinn specific GenericSetup handlers
22 $Id: setuphandlers.py 1333 2008-07-31 12:10:34Z pin $
23 $URL: http://svn.cri.ensmp.fr/svn/Plinn/branches/CMF-2.1/setuphandlers.py $
26 from Products
.CMFCore
.utils
import getToolByName
27 from Products
.PythonScripts
.PythonScript
import PythonScript
29 VARIOUS_FILENAME
= 'various.py'
32 def importVarious(context
) :
33 """ exec python code from setup python script """
34 site
= context
.getSite()
35 text
= context
.readDataFile(VARIOUS_FILENAME
)
39 site
._setPortalTypeName
('CMF Site')
41 script
= PythonScript('various')
42 script
= script
.__of
__(site
)
46 # clone current authenticated user into portal's acl_users
47 from AccessControl
import getSecurityManager
48 sm
= getSecurityManager()
50 mtool
= getToolByName(site
, 'portal_membership')
51 mtool
.addMember(user
.getId(), user
._getPassword
(), user
.getRoles(), user
.getDomains())
55 def exportVarious(exportContext
):
56 site
= exportContext
.getSite()
58 stool
= getToolByName(site
, 'portal_setup')
59 importContext
= stool
._getImportContext
(stool
.getBaselineContextID())
61 exportContext
.writeDataFile( VARIOUS_FILENAME
,
62 importContext
.readDataFile(VARIOUS_FILENAME
),
65 return 'Various Plinn settings exported.'