[patch] context processors for fields and manipulators
|Reported by:||jkocherhans <jkocherhans@…>||Owned by:||adrian|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
The manupulator and the model currently have no way to acccess anything in the request. This makes it impossible (using admin or generic views) to do something like an auto-filled author field where the author is the current user. This patch creates a new type of context that is passed in to a manipulator's __init__ method. The context is normally a ManipulatorContext object, but can be any dict. By default, ManipulatorContext gets a list of context processors by calling f.get_context_processors() on each field in the model. This context object is passed to get_manipulator_new_data when an object is saved via the manipulator.
This could probably be used for callable choices and callable defaults for fields. Also, this should make everything in #1132 possible.