I would like html2python be instance method. Consider the following
RelaxedDateField class which can accept date in various formats. It can
use day, month, and year from another date (reference date) if they are
not provided. The following inputs are valid:

27
2006-27-01
27.1.2006
27.1.
27-01

These all mean 2006-27-01 provided the reference date is 2006-27-01.

class RelaxedDateField(formfields.TextField):

    def __init__(self, reference_date, ...):
        self.reference_date = reference_date
        validator_list.append(self.guess_date)
        formfields.TextField.__init__(self, ....)

    def guess_date(self, field_data, all_data):
        #scan field_data for errors
        ...

    def html2python(self, data):
    #def html2python(data):
        #use self.reference_date if year and/or month is left out
        ...

The question is, is there a way of achieving the same result? I can add
another method to the class but then I have to call it explicitely.

TIA,
jbar

Reply via email to