How to use the colander.deferred function in colander

To help you get started, we’ve selected a few colander 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 Pylons / colander / colander / tests.py View on Github external
def _makeOne(self, wrapped):
        from colander import deferred
        return deferred(wrapped)
github liqd / adhocracy3 / src / adhocracy_core / adhocracy_core / sheets / badge.py View on Github external
    @deferred
    def validator(self, kw: dict) -> callable:
        """Validate the :term:`post_pool` for the object reference."""
        object_validator = create_post_pool_validator(self['object'], kw)
        badge_assignment_validator = create_unique_badge_assignment_validator(
            self['badge'], self['object'], kw)
        return All(object_validator, badge_assignment_validator)
github mazvv / travelcrm / travelcrm / forms / navigations.py View on Github external
@colander.deferred
def parent_validator(node, kw):
    request = kw.get('request')

    def validator(node, value):
        if request.params.get('id') and str(value) == request.params.get('id'):
            raise colander.Invalid(
                node,
                _(u'Can not be parent of self'),
            )
    return validator
github vcatalano / py-authorize / authorize / schemas.py View on Github external
@colander.deferred
def today(node, kw):
    return date.today().isoformat()
github Kotti / Kotti / kotti / views / widget.py View on Github external
@colander.deferred
def deferred_tag_it_widget(node, kw):
    all_tags = Tag.query.all()
    available_tags = [tag.title.encode('utf-8') for tag in all_tags]
    widget = TagItWidget(available_tags=available_tags,
                         missing='')
    return widget
github mazvv / travelcrm / travelcrm / forms / users.py View on Github external
@colander.deferred
def username_validator(node, kw):
    request = kw.get('request')

    def validator(node, value):
        user = User.by_username(value)
        if (
            user
            and str(user.id) != request.params.get('id')
        ):
            raise colander.Invalid(
                node,
                _(u'User with the same username exists'),
            )
    return colander.All(colander.Length(max=32), validator,)
github mazvv / travelcrm / travelcrm / forms / countries.py View on Github external
@colander.deferred
def iso_code_validator(node, kw):
    request = kw.get('request')

    def validator(node, value):
        country = Country.by_iso_code(value)
        if (
            country
            and str(country.id) != request.params.get('id')
        ):
            raise colander.Invalid(
                node,
                _(u'Country with the same iso code exists'),
            )
    return colander.All(colander.Length(min=2, max=2), validator,)
github Pylons / deform / deformdemo / app.py View on Github external
        @colander.deferred
        def deferred_date_description(node, kw):
            max_date = kw.get('max_date')
            if max_date is None:
                max_date = datetime.date.today()
            return 'Blog post date (no earlier than %s)' % max_date.ctime()
github mazvv / travelcrm / travelcrm / forms / positions.py View on Github external
@colander.deferred
def name_validator(node, kw):
    request = kw.get('request')

    def validator(node, value):
        position = (
            DBSession.query(Position)
            .filter(
                Position.name == value,
                Position.structure_id == request.params.get('structure_id')
            )
            .first()
        )
        if (
            position
            and (
                str(position.id) != request.params.get('id')
github mazvv / travelcrm / travelcrm / forms / licence.py View on Github external
@colander.deferred
def date_validator(node, kw):
    request = kw.get('request')

    def validator(node, value):
        if value >= parse_date(request.params.get('date_to')):
            raise colander.Invalid(node, _(u"Invalid dates, please check"))
    return colander.All(validator)