Пример #1
0
    def get_app_settings(self, additional_settings=None):
        settings = DEFAULT_SETTINGS.copy()
        settings['cliquet.project_name'] = 'cliquet'
        settings['cliquet.project_docs'] = 'https://cliquet.rtfd.org/'
        settings['multiauth.authorization_policy'] = (
            'cliquet.tests.support.AllowAuthorizationPolicy')

        if additional_settings is not None:
            settings.update(additional_settings)
        return settings
Пример #2
0
    def get_app_settings(self, additional_settings=None):
        settings = DEFAULT_SETTINGS.copy()
        settings['cliquet.project_name'] = 'cliquet'
        settings['cliquet.project_docs'] = 'https://cliquet.rtfd.org/'
        settings['fxa-oauth.relier.enabled'] = True
        settings['fxa-oauth.oauth_uri'] = 'https://oauth-stable.dev.lcip.org'
        settings['fxa-oauth.webapp.authorized_domains'] = ['*.firefox.com', ]

        if additional_settings is not None:
            settings.update(additional_settings)
        return settings
Пример #3
0
def initialize(config, version=None, project_name='', default_settings=None):
    """Initialize Cliquet with the given configuration, version and project
    name.

    This will basically include cliquet in Pyramid and set route prefix based
    on the specified version.

    :param config: Pyramid configuration
    :type config: ~pyramid:pyramid.config.Configurator
    :param str version: Current project version (e.g. '0.0.1') if not defined
        in application settings.
    :param str project_name: Project name if not defined
        in application settings.
    :param dict default_settings: Override cliquet default settings values.
    """
    from cliquet import DEFAULT_SETTINGS

    settings = config.get_settings()

    project_name = settings.pop('cliquet.project_name',
                                settings.get('project_name')) or project_name
    settings['project_name'] = project_name
    if not project_name:
        warnings.warn('No value specified for `project_name`')

    cliquet_defaults = DEFAULT_SETTINGS.copy()

    if default_settings:
        cliquet_defaults.update(default_settings)

    load_default_settings(config, cliquet_defaults)

    # Override project version from settings.
    project_version = settings.get('project_version') or version
    if not project_version:
        error_msg = "Invalid project version: %s" % project_version
        raise ConfigurationError(error_msg)
    settings['project_version'] = project_version = str(project_version)

    # HTTP API version.
    http_api_version = settings.get('http_api_version')
    if http_api_version is None:
        # The API version is derivated from the module version if not provided.
        http_api_version = '.'.join(project_version.split('.')[0:2])
    settings['http_api_version'] = http_api_version = str(http_api_version)
    api_version = 'v%s' % http_api_version.split('.')[0]

    # Include cliquet views with the correct api version prefix.
    config.include("cliquet", route_prefix=api_version)
    config.route_prefix = api_version
Пример #4
0
def initialize(config, version=None, project_name='', default_settings=None):
    """Initialize Cliquet with the given configuration, version and project
    name.

    This will basically include cliquet in Pyramid and set route prefix based
    on the specified version.

    :param config: Pyramid configuration
    :type config: ~pyramid:pyramid.config.Configurator
    :param str version: Current project version (e.g. '0.0.1') if not defined
        in application settings.
    :param str project_name: Project name if not defined
        in application settings.
    :param dict default_settings: Override cliquet default settings values.
    """
    from cliquet import DEFAULT_SETTINGS

    settings = config.get_settings()

    project_name = settings.pop('cliquet.project_name',
                                settings.get('project_name')) or project_name
    settings['project_name'] = project_name
    if not project_name:
        warnings.warn('No value specified for `project_name`')

    cliquet_defaults = DEFAULT_SETTINGS.copy()

    if default_settings:
        cliquet_defaults.update(default_settings)

    load_default_settings(config, cliquet_defaults)

    # Override project version from settings.
    project_version = settings.get('project_version') or version
    if not project_version:
        error_msg = "Invalid project version: %s" % project_version
        raise ConfigurationError(error_msg)
    settings['project_version'] = project_version = str(project_version)

    # HTTP API version.
    http_api_version = settings.get('http_api_version')
    if http_api_version is None:
        # The API version is derivated from the module version if not provided.
        http_api_version = '.'.join(project_version.split('.')[0:2])
    settings['http_api_version'] = http_api_version = str(http_api_version)
    api_version = 'v%s' % http_api_version.split('.')[0]

    # Include cliquet views with the correct api version prefix.
    config.include("cliquet", route_prefix=api_version)
    config.route_prefix = api_version
Пример #5
0
    def get_app_settings(self, additional_settings=None):
        settings = DEFAULT_SETTINGS.copy()

        settings['storage_backend'] = 'cliquet.storage.redis'
        settings['cache_backend'] = 'cliquet.cache.redis'
        settings['permission_backend'] = 'cliquet.permission.redis'

        settings['project_name'] = 'myapp'
        settings['project_version'] = '0.0.1'
        settings['project_docs'] = 'https://cliquet.rtfd.org/'
        settings['multiauth.authorization_policy'] = self.authorization_policy

        if additional_settings is not None:
            settings.update(additional_settings)
        return settings
Пример #6
0
    def get_app_settings(self, additional_settings=None):
        settings = DEFAULT_SETTINGS.copy()

        settings['storage_backend'] = 'cliquet.storage.redis'
        settings['cache_backend'] = 'cliquet.cache.redis'
        settings['permission_backend'] = 'cliquet.permission.redis'

        settings['project_name'] = 'myapp'
        settings['project_version'] = '0.0.1'
        settings['project_docs'] = 'https://cliquet.rtfd.org/'
        settings['multiauth.authorization_policy'] = self.authorization_policy

        if additional_settings is not None:
            settings.update(additional_settings)
        return settings
Пример #7
0
    def __init__(self, *args, **kwargs):
        super(DummyRequest, self).__init__(*args, **kwargs)
        self.upath_info = '/v0/'
        self.registry = mock.MagicMock(settings=DEFAULT_SETTINGS.copy())
        self.registry.id_generator = generators.UUID4()
        self.GET = {}
        self.headers = {}
        self.errors = cornice_errors.Errors(request=self)
        self.authenticated_userid = 'bob'
        self.authn_type = 'basicauth'
        self.prefixed_userid = 'basicauth:bob'
        self.json = {}
        self.validated = {}
        self.matchdict = {}
        self.response = mock.MagicMock(headers={})

        def route_url(*a, **kw):
            # XXX: refactor DummyRequest to take advantage of `pyramid.testing`
            parts = parse_url_overrides(kw)
            return ''.join([p for p in parts if p])

        self.route_url = route_url
Пример #8
0
    def __init__(self, *args, **kwargs):
        super(DummyRequest, self).__init__(*args, **kwargs)
        self.upath_info = '/v0/'
        self.registry = mock.MagicMock(settings=DEFAULT_SETTINGS.copy())
        self.registry.id_generator = generators.UUID4()
        self.GET = {}
        self.headers = {}
        self.errors = cornice_errors.Errors(request=self)
        self.authenticated_userid = 'bob'
        self.authn_type = 'basicauth'
        self.prefixed_userid = 'basicauth:bob'
        self.json = {}
        self.validated = {}
        self.matchdict = {}
        self.response = mock.MagicMock(headers={})

        def route_url(*a, **kw):
            # XXX: refactor DummyRequest to take advantage of `pyramid.testing`
            parts = parse_url_overrides(kw)
            return ''.join([p for p in parts if p])

        self.route_url = route_url