<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def varchar(self, field=None):
 """ Returns a chunk of text, of maximum length 'max_length' """

        assert field is not None, "The field parameter must be passed to the 'varchar' method."
        max_length = field.max_length

        def source():
            length = random.choice(range(1, max_length + 1))
            return "".join(random.choice(general_chars) for i in xrange(length))
        return self.get_allowed_value(source, field)