How to use the cornice.validators.colander_body_validator function in cornice

To help you get started, we’ve selected a few cornice examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Cornices / cornice / tests / validationapp.py View on Github external
                validators=(colander_body_validator,), header='X-foo')
    def bound_post_with_override(request):
        return request.validated
github bird-house / twitcher / twitcher / api.py View on Github external
                   validators=(colander_body_validator, ),
                   schema=ServicesPostBodySchema())
    def register_service(request):
        """Register a service."""
        LOGGER.debug("request validated={}".format(request.validated))
        return request.owsregistry.register_service(**request.validated)
github fedora-infra / bodhi / bodhi / server / services / updates.py View on Github external
                           validators=(colander_body_validator,
                                       validate_update_id,
                                       validate_acls),
                           permission='edit', renderer='json',
                           error_handler=bodhi.server.services.errors.json_handler)
def trigger_tests(request):
    """
    Trigger tests for update.

    Args:
        request (pyramid.request): The current request.
    Returns:
        dict: A dictionary mapping the key "update" to the update.
    """
    update = request.validated['update']

    if update.status != UpdateStatus.testing:
github fedora-infra / bodhi / bodhi / server / services / overrides.py View on Github external
                    colander_body_validator,
                    validate_override_builds,
                    validate_expiration_date,
                ))
@overrides.post(schema=bodhi.server.schemas.SaveOverrideSchema,
                permission='edit',
                accept=("application/javascript"), renderer="jsonp",
                error_handler=bodhi.server.services.errors.jsonp_handler,
                validators=(
                    colander_body_validator,
                    validate_override_builds,
                    validate_expiration_date,
                ))
def save_override(request):
    """
    Create or edit a buildroot override.
github webpush-channels / webpush-channels / webpush_channels / views / channels.py View on Github external
@channel.post(permission=PRIVATE, schema=PayloadSchema(), validators=(colander_body_validator,))
def send_push_notifications(request):
    channel_id = request.matchdict['channel_id']
    parent_id = '/channels/{}'.format(channel_id)

    registrations, count = request.registry.storage.get_all(
        collection_id=REGISTRATION_COLLECTION_ID,
        parent_id=parent_id)

    subscriptions = []

    for registration in registrations:
        user_subscriptions, count = request.registry.storage.get_all(
            collection_id=SUBSCRIPTION_COLLECTION_ID,
            parent_id=registration['id'])
        subscriptions += user_subscriptions
github Cornices / cornice.ext.swagger / examples / minimalist.py View on Github external
    @values.put(tags=['values'], validators=(colander_body_validator, ),
                schema=BodySchema(), response_schemas=response_schemas)
    def set_value(request):
        """Set the value and returns *True* or *False*."""

        key = request.matchdict['key']
        _VALUES[key] = request.json_body
        return _VALUES.get(key)
github loggi / edwiges / edwiges / views.py View on Github external
@mail_service.post(schema=EmailSchema(), validators=(colander_body_validator,))
def send_mail(request):

    settings = request.registry.settings

    logger.info("Send email request received",
                extra={"request": request.validated})

    host = settings["edwiges.provider_host"]
    port = settings["edwiges.provider_port"]
    username = settings["edwiges.provider_username"]
    password = settings["edwiges.provider_password"]

    with SMTP_SSL(host, port) as smtp:
        try:
            smtp.ehlo()
            if username and password:
github fedora-infra / bodhi / bodhi / server / services / comments.py View on Github external
                   colander_body_validator,
                   validate_update,
                   validate_bug_feedback,
                   validate_testcase_feedback,
                   validate_comments_open,
               ))
def new_comment(request):
    """
    Add a new comment to an update.

    Args:
        request (pyramid.request): The current request.
    Returns:
        dict: A dictionary with two keys. "comment" indexes the new comment, and "caveats" indexes
            an iterable of messages to display to the user.
    """
    data = request.validated
github Cornices / cornice.ext.swagger / cornice_swagger / util.py View on Github external
def body_schema_transformer(schema, args):
    validators = args.get('validators', [])
    if colander_body_validator in validators:
        body_schema = schema
        schema = colander.MappingSchema()
        schema['body'] = body_schema
    return schema
github fedora-infra / bodhi / bodhi / server / services / releases.py View on Github external
               validators=(colander_body_validator, validate_tags, validate_enums)
               )
def save_release(request):
    """
    Save a release.

    This entails either creating a new release, or editing an existing one. To
    edit an existing release, the release's original name must be specified in
    the ``edited`` parameter.

    Args:
        request (pyramid.request): The current request.
    Returns:
        bodhi.server.models.Request: The created or edited Request.
    """
    data = request.validated