def addConfiguredPAS(dispatcher, base_profile, extension_profiles=(), create_snapshot=True, setup_tool_id='setup_tool', REQUEST=None): """ Add a PluggableAuthService to 'self. """ from Products.GenericSetup.tool import SetupTool pas = PluggableAuthService() preg = PluginRegistry(_PLUGIN_TYPE_INFO) preg._setId('plugins') pas._setObject('plugins', preg) dispatcher._setObject(pas.getId(), pas) pas = dispatcher._getOb(pas.getId()) # wrapped tool = SetupTool(setup_tool_id) pas._setObject(tool.getId(), tool) tool = pas._getOb(tool.getId()) # wrapped tool.runAllImportStepsFromProfile('profile-%s' % base_profile) for extension_profile in extension_profiles: tool.runAllImportStepsFromProfile('profile-%s' % extension_profile) if create_snapshot: tool.createSnapshot('initial_configuration') if REQUEST is not None: REQUEST['RESPONSE'].redirect('%s/manage_workspace' '?manage_tabs_message=' 'PluggableAuthService+added.' % dispatcher.absolute_url())
def addConfiguredSite(dispatcher, site_id, profile_id, snapshot=True, RESPONSE=None, extension_ids=()): """ Add a CMFSite to 'dispatcher', configured according to 'profile_id'. """ site = CMFSite(site_id) dispatcher._setObject(site_id, site) site = dispatcher._getOb(site_id) site._setObject(_TOOL_ID, SetupTool(_TOOL_ID)) setup_tool = getToolByName(site, _TOOL_ID) setup_tool.setImportContext('profile-%s' % profile_id) setup_tool.runAllImportSteps() for extension_id in extension_ids: setup_tool.setImportContext('profile-%s' % extension_id) setup_tool.runAllImportSteps() setup_tool.setImportContext('profile-%s' % profile_id) if snapshot is True: setup_tool.createSnapshot('initial_configuration') if RESPONSE is not None: RESPONSE.redirect('%s/manage_main?update_menu=1' % dispatcher.absolute_url())
def addPloneSite(context, site_id, title='Plone site', description='', create_userfolder=True, email_from_address='', email_from_name='', validate_email=True, profile_id=_DEFAULT_PROFILE, snapshot=False, extension_ids=(), base_contenttypes_profile=_ATCONTENTTYPES_PROFILE, setup_content=True, default_language='en'): """Add a PloneSite to the context.""" context._setObject(site_id, PloneSite(site_id)) site = context._getOb(site_id) site.setLanguage(default_language) site[_TOOL_ID] = SetupTool(_TOOL_ID) setup_tool = site[_TOOL_ID] notify(SiteManagerCreatedEvent(site)) setSite(site) setup_tool.setBaselineContext('profile-%s' % profile_id) setup_tool.runAllImportStepsFromProfile('profile-%s' % profile_id) if base_contenttypes_profile is not None \ and base_contenttypes_profile in _CONTENTTYPES_PROFILES: profile = 'profile-%s' % base_contenttypes_profile setup_tool.runAllImportStepsFromProfile(profile) # Only set up content if a base contenttypes profile has been provided. if setup_content: if base_contenttypes_profile == _ATCONTENTTYPES_PROFILE: content_profile = _AT_CONTENT_PROFILE else: content_profile = _DEX_CONTENT_PROFILE setup_tool.runAllImportStepsFromProfile('profile-%s' % content_profile) props = dict( title=title, description=description, email_from_address=email_from_address, email_from_name=email_from_name, validate_email=validate_email, ) # Do this before applying extension profiles, so the settings from a # properties.xml file are applied and not overwritten by this site.manage_changeProperties(**props) for extension_id in extension_ids: setup_tool.runAllImportStepsFromProfile('profile-%s' % extension_id) if snapshot is True: setup_tool.createSnapshot('initial_configuration') return site
def _initSite( self ): from Products.GenericSetup.tool import SetupTool site = Folder() site._setId( 'site' ) self.root._setObject( 'site', site ) site = self.root._getOb( 'site' ) site._setObject('setup_tool', SetupTool('setup_tool')) return site
def addPloneSite(context, site_id, title='Plone site', description='', profile_id=_DEFAULT_PROFILE, content_profile_id=_CONTENT_PROFILE, snapshot=False, extension_ids=(), setup_content=True, default_language='en', portal_timezone='UTC'): """Add a PloneSite to the context.""" context._setObject(site_id, PloneSite(site_id)) site = context._getOb(site_id) site.setLanguage(default_language) # Set the accepted language for the rest of the request. This makes sure # the front-page text gets the correct translation also when your browser # prefers non-English and you choose English as language for the Plone # Site. request = context.REQUEST request['HTTP_ACCEPT_LANGUAGE'] = default_language site[_TOOL_ID] = SetupTool(_TOOL_ID) setup_tool = site[_TOOL_ID] notify(SiteManagerCreatedEvent(site)) setSite(site) setup_tool.setBaselineContext('profile-%s' % profile_id) setup_tool.runAllImportStepsFromProfile('profile-%s' % profile_id) reg = queryUtility(IRegistry, context=site) reg['plone.portal_timezone'] = portal_timezone reg['plone.available_timezones'] = [portal_timezone] reg['plone.default_language'] = default_language reg['plone.available_languages'] = [default_language] if setup_content: setup_tool.runAllImportStepsFromProfile('profile-%s' % content_profile_id) props = dict( title=title, description=description, ) # Do this before applying extension profiles, so the settings from a # properties.xml file are applied and not overwritten by this site.manage_changeProperties(**props) for extension_id in extension_ids: setup_tool.runAllImportStepsFromProfile('profile-%s' % extension_id) if snapshot is True: setup_tool.createSnapshot('initial_configuration') return site
def addPloneSite(context, site_id, title='Plone site', description='', profile_id=_DEFAULT_PROFILE, content_profile_id=_CONTENT_PROFILE, snapshot=False, extension_ids=(), setup_content=True, default_language='en', portal_timezone='UTC'): """Add a PloneSite to the context.""" context._setObject(site_id, PloneSite(site_id)) site = context._getOb(site_id) site.setLanguage(default_language) site[_TOOL_ID] = SetupTool(_TOOL_ID) setup_tool = site[_TOOL_ID] notify(SiteManagerCreatedEvent(site)) setSite(site) setup_tool.setBaselineContext('profile-%s' % profile_id) setup_tool.runAllImportStepsFromProfile('profile-%s' % profile_id) reg = queryUtility(IRegistry, context=site) reg['plone.portal_timezone'] = portal_timezone reg['plone.available_timezones'] = [portal_timezone] reg['plone.default_language'] = default_language reg['plone.available_languages'] = [default_language] if setup_content: setup_tool.runAllImportStepsFromProfile('profile-%s' % content_profile_id) props = dict( title=title, description=description, ) # Do this before applying extension profiles, so the settings from a # properties.xml file are applied and not overwritten by this site.manage_changeProperties(**props) for extension_id in extension_ids: setup_tool.runAllImportStepsFromProfile('profile-%s' % extension_id) if snapshot is True: setup_tool.createSnapshot('initial_configuration') return site
def manage_addSAGL(context, id, title='SAGL-OpenLegis', description='', database='MySQL', profile_id=_DEFAULT_PROFILE, RESPONSE=None): """ Adicionar uma instancia do SAGL-OpenLegis. """ context._setObject(id, SAGL(id)) site = context._getOb(id) setSite(site) site._setObject(_TOOL_ID, SetupTool(_TOOL_ID)) setup_tool = getToolByName(site, _TOOL_ID) setup_tool.setBaselineContext('profile-Products.CMFDefault:default') setup_tool.runAllImportStepsFromProfile( 'profile-Products.CMFDefault:default') setup_tool.setBaselineContext('profile-%s' % profile_id) setup_tool.runAllImportStepsFromProfile('profile-%s' % profile_id) props = dict( title=title, description=description, ) site.manage_changeProperties(**props) if database == 'MySQL': site.manage_addProduct['ZMySQLDA'].manage_addZMySQLConnection( id='dbcon_openlegis', title='Banco de Dados do SAGL-OpenLegis (MySQL)', use_unicode=True, connection_string='openlegis sagl sagl') else: site.manage_addProduct['ZPsycopgDA'].manage_addZPsycopgConnection( id='dbcon_openlegis', title='Banco de Dados do SAGL-OpenLegis (PostgreSQL)', connection_string= 'dbname=openlegis user=sagl password=sagl host=localhost') if RESPONSE is not None: RESPONSE.redirect('%s/%s/manage_main?update_menu=1' % (context.absolute_url(), id))
def manage_addDove(self, id, title='', REQUEST=None): """ """ self._setObject(id, CMFDove(id, title)) dove = self._getOb(id) # add generic set up tool for dove. dove._setObject(_SETUP_TOOL_ID, SetupTool(_SETUP_TOOL_ID)) setup_tool = getattr(dove, _SETUP_TOOL_ID) # set up the baseline context for setup tool and import # the dove gs profile. setup_tool.setBaselineContext('profile-%s' % _DOVE_PROFILE_ID) setup_tool.runAllImportStepsFromProfile('profile-%s' % _DOVE_PROFILE_ID) if REQUEST: REQUEST['RESPONSE'].redirect('%s/index_html' % dove.absolute_url(), lock=1)
def _makeSetupTool(self): from Products.GenericSetup.tool import SetupTool return SetupTool('portal_setup')
def __init__(self, id='portal_setup'): BaseTool.__init__(self, id)
def addConfiguredPAS( dispatcher , base_profile , extension_profiles=() , create_snapshot=True , setup_tool_id='setup_tool' , REQUEST=None ): """ Add a PluggableAuthService to 'self. """ from Products.GenericSetup.tool import SetupTool pas = PluggableAuthService() preg = PluginRegistry( _PLUGIN_TYPE_INFO ) preg._setId( 'plugins' ) pas._setObject( 'plugins', preg ) dispatcher._setObject( pas.getId(), pas ) pas = dispatcher._getOb( pas.getId() ) # wrapped tool = SetupTool( setup_tool_id ) pas._setObject( tool.getId(), tool ) tool = pas._getOb( tool.getId() ) # wrapped tool.setImportContext( 'profile-%s' % base_profile ) tool.runAllImportSteps() for extension_profile in extension_profiles: tool.setImportContext( 'profile-%s' % extension_profile ) tool.runAllImportSteps() tool.setImportContext( 'profile-%s' % base_profile ) if create_snapshot: tool.createSnapshot( 'initial_configuration' ) if REQUEST is not None: REQUEST['RESPONSE'].redirect( '%s/manage_workspace' '?manage_tabs_message=' 'PluggableAuthService+added.' % dispatcher.absolute_url() )
def addPloneSite(context, site_id, title='Plone site', description='', profile_id=_DEFAULT_PROFILE, content_profile_id=_CONTENT_PROFILE, snapshot=False, extension_ids=(), setup_content=True, default_language='en', portal_timezone='UTC'): """Add a PloneSite to the context.""" context._setObject(site_id, PloneSite(site_id)) site = context._getOb(site_id) site.setLanguage(default_language) # Set the accepted language for the rest of the request. This makes sure # the front-page text gets the correct translation also when your browser # prefers non-English and you choose English as language for the Plone # Site. request = context.REQUEST request['HTTP_ACCEPT_LANGUAGE'] = default_language site[_TOOL_ID] = SetupTool(_TOOL_ID) setup_tool = site[_TOOL_ID] notify(SiteManagerCreatedEvent(site)) setSite(site) setup_tool.setBaselineContext('profile-%s' % profile_id) setup_tool.runAllImportStepsFromProfile('profile-%s' % profile_id) reg = queryUtility(IRegistry, context=site) reg['plone.portal_timezone'] = portal_timezone reg['plone.available_timezones'] = [portal_timezone] reg['plone.default_language'] = default_language reg['plone.available_languages'] = [default_language] if setup_content: setup_tool.runAllImportStepsFromProfile('profile-%s' % content_profile_id) props = dict( title=title, description=description, ) # Do this before applying extension profiles, so the settings from a # properties.xml file are applied and not overwritten by this site.manage_changeProperties(**props) for extension_id in extension_ids: try: setup_tool.runAllImportStepsFromProfile('profile-%s' % extension_id) except Exception as msg: IStatusMessage(request).add(_( 'Could not install ${profile_id}: ${error_msg}! ' 'Please try to install it manually using the "Addons" ' 'controlpanel and report any issues to the ' 'addon maintainers.', mapping={ 'profile_id': extension_id, 'error_msg': msg.args, }), type='error') logger.exception( 'Error while installing addon {}. ' 'See traceback below for details.'.format(extension_id)) if snapshot is True: setup_tool.createSnapshot('initial_configuration') return site