def to_python(self, value):
    Field.to_python(self, value)
    m = DurationField.DURATION_RE.match(value)
    if (m is None):
        raise FieldValidationException(("The value of '%s' for the '%s' parameter is not a valid duration" % (str(value), self.name)))
    d = m.groupdict()
    units = d['units']
    try:
        duration = int(d['duration'])
    except ValueError:
        raise FieldValidationException(("The duration '%s' for the '%s' parameter is not a valid number" % (d['duration'], self.name)))
    if ((len(units) > 0) and (units not in DurationField.UNITS)):
        raise FieldValidationException(("The unit '%s' for the '%s' parameter is not a valid unit of duration" % (units, self.name)))
    if (len(units) > 0):
        return (duration * DurationField.UNITS[units])
    else:
        return duration
def to_python(self, value):
    Field.to_python(self, value)
    m = DurationField.DURATION_RE.match(value)
    if (m is None):
        raise FieldValidationException(("The value of '%s' for the '%s' parameter is not a valid duration" % (str(value), self.name)))
    d = m.groupdict()
    units = d['units']
    try:
        duration = int(d['duration'])
    except ValueError:
        raise FieldValidationException(("The duration '%s' for the '%s' parameter is not a valid number" % (d['duration'], self.name)))
    if ((len(units) > 0) and (units not in DurationField.UNITS)):
        raise FieldValidationException(("The unit '%s' for the '%s' parameter is not a valid unit of duration" % (units, self.name)))
    if (len(units) > 0):
        return (duration * DurationField.UNITS[units])
    else:
        return duration