Chris Lambacher added the comment:

My use case is a generic mixin for Enums and a generic mixin for Django ORM 
fields that uses the Enums to generate choices. 

The Enum mixin has to call cls.__class__._get_mixins_(cls.__bases__) to get the 
member_type so that it can call the member_type.__new__ method (currently using 
this for int and str). I'm currently setting _member_type_ on the class if it 
doesn't already exist in the Enum class.

The Django ORM field mixin has a to_python method where it is supposed to take 
input from the db/web and turn it into the python type (in this case an Enum). 
If we get a str from the web and we are going to an int, we need to run int on 
it. The generic way to do this in the mixin is to pass the value to 
_member_type_ as a function.

I think I have all the bugs out of my implementation so I should be able to 
extract it out of my app and make it open source this week.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue18635>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to