Exemplo n.º 1
0
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())
Exemplo n.º 2
0
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() )