Opened 4 weeks ago
Allow Media objects to have their own MEDIA_TYPES
|Reported by:||Keryn Knight <django@…>||Owned by:||nobody|
|Has patch:||no||Needs documentation:|
|Needs tests:||Patch needs improvement:|
Currently, instances of Media look to the module scope to get the known MEDIA_TYPES. This makes it difficult to subclass Media to add extra render_x/add_x methods because MEDIA_TYPES is hardcoded in __init__, render, __getitem__ and __add__ and isn't easily available for a subclass to add to without monkeypatching the module constant. As far as I can tell, the only use of MEDIA_TYPES is in the widgets module, and could be shifted to the class itself, leaving the module level one to raise a deprecation warning.
Rationale is that I want to be able to add inline_css and inline_js, or text (for JS templates etc) to a Media object, and currently that's more difficult than just adjusting a subclass' attribute and adding the appropriate methods.