def sqlalchemy_validator(node, value, model, session=None, msg='%s is ongeldig'):
    """
    Validate a sqlalchemy object or identifier.
    Function checks if value is an instance of sqlalchemy model
    or an id of one.
    :param node: A colander SchemaNode.
    :param value: The value to be validated. Is the key of the
        SQLAlchemy model.
    :param model: A SQLAlchemy model.
    :param session: A SQLAlchemy session. Is required if value is not an
        instance of a SQLAlchemy model.
    :param msg: A msg to attach to a `colander.Invalid` exception.
    :raises colander.Invalid: If not a valid sqlalchemy model.
    """

    m = session.query(model).get(value)

    if not m:
        raise colander.Invalid(
            node,
            msg % value
        )

    return m
def sqlalchemy_validator ( node , value , model , session = None , msg = '%s is ongeldig' ) : m = session . query ( model ) . get ( value ) if not m : raise colander . Invalid ( node , msg % value ) return m
Validate a sqlalchemy object or identifier.
    Function checks if value is an instance of sqlalchemy model
    or an id of one.
    :param node: A colander SchemaNode.
    :param value: The value to be validated. Is the key of the
        SQLAlchemy model.
    :param model: A SQLAlchemy model.
    :param session: A SQLAlchemy session. Is required if value is not an
        instance of a SQLAlchemy model.
    :param msg: A msg to attach to a `colander.Invalid` exception.
    :raises colander.Invalid: If not a valid sqlalchemy model.