Ticket #446 (assigned enhancement)
introspection rules could accept callable for more flexibility
|Reported by:||carl@…||Owned by:||carl@…|
Where the introspection rules currently require a Field attribute name (with magically-handled dots), a callable could be accepted that takes the Field instance as its only argument and returns the parameter value to use. This would allow for much more flexible handling, without a profusion of special-case options in the options dict; including simple things that are impossible now, like correct handling of a boolean Field attribute that is stored as the inverse of the parameter passed in to the Field's init method.
This wouldn't need to affect backwards-compatibility, as the first tuple element can be asked if it is callable(); if not, it will be treated as it is currently.
I will provide a patch with tests, if the idea is accepted in principle.
(In the long run, IMO it'd be more Pythonic if all introspection rules were done this way; you could get rid of the "is_value" special-case option in favor of a simple "lambda f: 'the_value'"; normal attribute access could just be "lambda f: f.attr"; etc.)
- Owner changed from andrew to carl@…
- Status changed from new to assigned
- Milestone set to 0.7.1