def deferred_group_validator(node, kw): """ Return a validator that checks that the validated datas matches the existing groups """ request = kw['request'] groups = get_groups(request) validator = colander.ContainsOnly([group[0] for group in groups]) return colander.All(colander.Length(min=1), validator)
def _deferred_group_validator(node, kw): """ Build a validator for group name validation :param obj node: The form schema node :param dict kw: The form schema bind params :returns: A colander validator """ request = kw['request'] groups = get_groups(request) validator = colander.ContainsOnly([group[0] for group in groups]) return validator
class OldInstancesConfigurationSchema(colander.MappingSchema): max_age = colander.SchemaNode( colander.Integer(), title="Maximum age", description="Maximum age for instances in this state. In seconds.", default=3600 * 24, missing=3600 * 24) states = colander.SchemaNode( colander.Set(), title="States to remove", description="A set of states to remove after the timeout.", default=[], missing=[], validator=colander.ContainsOnly(constants.INSTANCE.ALL)) only_inactive = colander.SchemaNode( colander.Boolean(), title="Only Inactive Versions", description="Only operate on inactive versions of an application.", default=True, missing=True)
def possible_applications_validator(node, kw): possible_apps = [int(a) for a in kw['resources']] return colander.All(colander.ContainsOnly(possible_apps), colander.Length(1))
def current_user_or_system_users(node, kw): request = kw['request'] values = [request.authenticated_userid] values.extend(request.meeting.system_userids) return colander.All(colander.ContainsOnly(values), colander.Length(min=1, max=1))