Exemplo n.º 1
0
def pyramid_auth_provider(config, name, provider):
    """ pyramid configurator directive for
    authentication provider registration::

       class AuthProvider(object):
           ...

       config = Configurator()
       config.include('ptah')
       config.ptah_auth_provider('my-provider', AuthProvider())
    """
    info = ptah.config.DirectiveInfo()
    discr = (AUTH_PROVIDER_ID, name)
    intr = ptah.config.Introspectable(
        AUTH_PROVIDER_ID, discr, name, AUTH_PROVIDER_ID)
    intr['id'] = name
    intr['name'] = '{0}.{1}'.format(
        info.codeinfo.module, provider.__class__.__name__)
    intr['provider'] = provider
    intr['codeinfo'] = info.codeinfo

    config.action(
        discr,
        lambda config, n, p: \
            config.get_cfg_storage(AUTH_PROVIDER_ID).update({n: p}),
        (config, name, provider), introspectables=(intr,))
Exemplo n.º 2
0
def pyramid_password_changer(config, schema, changer):
    """ pyramid configurator utility for password changer registration """
    discr = (ID_PASSWORD_CHANGER, schema)

    intr = ptah.config.Introspectable(
        ID_PASSWORD_CHANGER, discr, changer.__doc__, ID_PASSWORD_CHANGER)
    intr.update(schema = schema, callable = changer)

    config.action(
        discr,
        lambda config, schema, changer: \
            config.get_cfg_storage(ID_PASSWORD_CHANGER).update({schema:changer}),
        (config, schema, changer), introspectables = (intr,))
Exemplo n.º 3
0
def pyramid_password_changer(config, schema, changer):
    """ pyramid configurator utility for password changer registration """
    discr = (ID_PASSWORD_CHANGER, schema)

    intr = ptah.config.Introspectable(ID_PASSWORD_CHANGER, discr,
                                      changer.__doc__, ID_PASSWORD_CHANGER)
    intr.update(schema=schema, callable=changer)

    config.action(
        discr,
        lambda config, schema, changer: \
            config.get_cfg_storage(ID_PASSWORD_CHANGER).update({schema:changer}),
        (config, schema, changer), introspectables = (intr,))
Exemplo n.º 4
0
def pyramid_principal_searcher(config, name, searcher):
    """ pyramid configurator directive for principal searcher registration """
    discr = (AUTH_SEARCHER_ID, name)
    intr = ptah.config.Introspectable(
        AUTH_SEARCHER_ID, discr, name, AUTH_SEARCHER_ID)
    intr['name'] = name
    intr['callable'] = searcher

    config.action(
        (AUTH_SEARCHER_ID, name),
        lambda config, name, searcher:
            config.get_cfg_storage(AUTH_SEARCHER_ID).update({name:searcher}),
        (config, name, searcher), introspectables=(intr,))
Exemplo n.º 5
0
Arquivo: uri.py Projeto: runyaga/ptah
def pyramid_uri_resolver(config, schema, resolver):
    """ pyramid configurator directive 'ptah_uri_resolver' """
    info = ptah.config.DirectiveInfo()
    discr = (ID_RESOLVER, schema)
    intr = ptah.config.Introspectable(ID_RESOLVER, discr, resolver.__doc__, ID_RESOLVER)
    intr["schema"] = schema
    intr["callable"] = resolver
    intr["codeinfo"] = info.codeinfo

    config.action(
        discr,
        lambda config, schema, resolver: config.get_cfg_storage(ID_RESOLVER).update({schema: resolver}),
        (config, schema, resolver),
        introspectables=(intr,),
    )
Exemplo n.º 6
0
def pyramid_uri_resolver(config, schema, resolver):
    """ pyramid configurator directive 'ptah_uri_resolver' """
    info = ptah.config.DirectiveInfo()
    discr = (ID_RESOLVER, schema)
    intr = ptah.config.Introspectable(ID_RESOLVER, discr, resolver.__doc__,
                                      ID_RESOLVER)
    intr['schema'] = schema
    intr['callable'] = resolver
    intr['codeinfo'] = info.codeinfo

    config.action(discr,
                  lambda config, schema, resolver: config.get_cfg_storage(
                      ID_RESOLVER).update({schema: resolver}),
                  (config, schema, resolver),
                  introspectables=(intr, ))
Exemplo n.º 7
0
def pyramid_auth_checker(config, checker):
    """ pyramid configurator directive for authentication checker registration::

        config = Configurator()
        config.include('ptah')

        def my_checker(info):
           ...

        config.ptah_auth_checker(my_checker)
    """
    discr = (AUTH_CHECKER_ID, hash(checker))
    intr = ptah.config.Introspectable(AUTH_CHECKER_ID, discr, '', AUTH_CHECKER_ID)
    intr['callable'] = checker

    config.action(
        discr,
        lambda config, checker: config.get_cfg_storage(AUTH_CHECKER_ID)\
            .update({id(checker): checker}),
        (config, checker), introspectables=(intr,))