Beispiel #1
0
def register_service(config, name, service, path):
    """Register a diecutter service in Pyramid routing."""
    hello = cornice.Service(name='{name}_hello'.format(name=name),
                            path=path,
                            description="The template API",
                            cors_origins=('*', ))
    template = cornice.Service(name='{name}_template'.format(name=name),
                               path='%s{template_path:.+}' % path,
                               description="Return the template render or raw")
    hello.add_view('GET', service.hello)
    template.add_view('PUT',
                      service.put,
                      validators=(diecutter.validators.token_validator, ))
    template.add_view('GET', service.get)
    template.add_view('POST', service.post)
    cornice.register_service_views(config, hello)
    cornice.register_service_views(config, template)
    # Deprecate 'template_engine' and 'filename_template_engine' settings.
    deprecated_settings = [
        'diecutter.filename_template_engine', 'diecutter.template_engine'
    ]
    for deprecated_key in deprecated_settings:
        if deprecated_key in config.registry.settings:
            raise DeprecationWarning(
                'Setting {deprecated} is deprecated, use {new} instead'.format(
                    deprecated=deprecated_key,
                    new=deprecated_key.replace('template_', '')))
Beispiel #2
0
def register_service(config, name, service, path):
    """Register a diecutter service in Pyramid routing."""
    hello = cornice.Service(name='{name}_hello'.format(name=name),
                            path=path,
                            description="The template API",
                            cors_origins=('*',))
    template = cornice.Service(
        name='{name}_template'.format(name=name),
        path='%s{template_path:.+}' % path,
        description="Return the template render or raw")
    hello.add_view('GET', service.hello)
    template.add_view('PUT', service.put,
                      validators=(diecutter.validators.token_validator,))
    template.add_view('GET', service.get)
    template.add_view('POST', service.post)
    cornice.register_service_views(config, hello)
    cornice.register_service_views(config, template)
    # Deprecate 'template_engine' and 'filename_template_engine' settings.
    deprecated_settings = ['diecutter.filename_template_engine',
                           'diecutter.template_engine']
    for deprecated_key in deprecated_settings:
        if deprecated_key in config.registry.settings:
            raise DeprecationWarning(
                'Setting {deprecated} is deprecated, use {new} instead'
                .format(deprecated=deprecated_key,
                        new=deprecated_key.replace('template_', '')))
Beispiel #3
0
def includeme(config):
    for svc in tasks.Task._services.values():
        cornice.register_service_views(config, svc)