Hi, I currently find myself needing something very similar to the validation framework. It's best explained with an example:
There is a form that configures email forwarding. The form will not only validate well-formedness of the target addresses, but it will also check whether its domain really exists (doing dns lookups). But if the domain does not exist, it shouldn't get a hard error, but the user will get a message about the problem. It's something like a warning or a hint. Just to have a term now, I call it "advisory". Some field types always have specific advisory functions, just like validators. All email addresses should have their domains checked, for an example. It comes very close to validators, but there a also differences: - The advisory methods have to be called for each GET, not for the POST. - It doesn't stop a POST request. A advisory method is not different from a validator, for example: ------------------------------- class hasExistingEmailTargets(object): def __call__(self, field_data, all_data=None): for line in field_data.split('\n'): line = line.strip() if line: at_pos = line.find('@') if at_pos != -1: # es ist eine Email-Adresse. if not is_resolvable(line[at_pos+1:], [dns.rdatatype.A, dns.rdatatype.MX]): raise validators.ValidationError, "%s: %s" % (line, gettext("Die angegebene Domain ist im DNS nicht vorhanden.")) else: # eine Mailbox if not models.Person.objects.filter(user__exact=line).has_flag("pwuse","mail")[:1]: raise validators.ValidationError, "%s: %s" % (line, gettext("Diese Mailbox ist bei noris network nicht registriert.")) -------------------------------- Advisories could be "pulled" into a field like validators in the form's __init__(). You can use a validator once as a validator, or in another case for an advisory. I'm now trying to make this similar to the validation framework (thus, patching FormFieldWrapper, generic views, etc.) Now, is there interest in having such a thing in Django? Currently, I try to keep the patching minimal, but I don't see how I could avoid it. If this would go into Django eventually, it could be solved cleaner and easier. For example, currently I have a separate AdvisoryFieldMixin, and fields that have advisories use this mixin as a second superclass (after django.forms.FormField) What do you think? Michael --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-developers -~----------~----~----~----~------~----~------~--~---