Commits

Luke Plant committed 391c880

Changed 'varchar' to do max_length introspection at runtime.

Comments (0)

Files changed (3)

+Version 0.1.2
+-------------
+
+* Changed 'varchar' field to do max_length introspection at runtime.
+  This breaks the previous signature of the function.
+
 
 Version 0.1.1
 -------------

anonymizer/base.py

 
     ### Public interace ##
 
-    def varchar(self, max_length, field=None):
+    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(0, max_length + 1))
             return "".join(random.choice(general_chars) for i in xrange(length))

anonymizer/introspect.py

             return '"lorem"'
 
         # Just try some random chars
-        max_length = field.max_length
-        return "lambda self, obj, field, val: self.faker.varchar(%d, field=field)" % max_length
+        return '"varchar"'
 
 
     try: