Permalink
Browse files

Fixes search for generator by field class. Now search is performed no…

…t only in

field class, but also in all bases of field class.
  • Loading branch information...
1 parent a45e519 commit 777ffcf71fbc2cd54a4d2c3573045d9b8821ec96 @sirex committed May 10, 2011
Showing with 6 additions and 2 deletions.
  1. +6 −2 mockups/factory.py
View
8 mockups/factory.py
@@ -85,8 +85,12 @@ def get_generator(self, field, **kwargs):
return generators.ChoiceFieldGenerator(field)
elif field.default is not models.NOT_PROVIDED:
return None # bail out
- elif field.__class__ in self.fieldclass_to_generator:
- obj = self.fieldclass_to_generator.get(field.__class__)
+ # check if any of bases exests in self.fieldclass_to_generator
+ elif (set(field.__class__.__mro__).
+ intersection(self.fieldclass_to_generator)):
+ for cls in field.__class__.__mro__:
+ if cls in self.fieldclass_to_generator:
+ obj = self.fieldclass_to_generator.get(cls)
else:
return None # No matching generator found

0 comments on commit 777ffcf

Please sign in to comment.