Add support for custom context processors, and make them and apps ref-counted.

Review Request #5024 — Created Nov. 23, 2013 and submitted

Information

Djblets
master

Reviewers

Add support for custom context processors, and make them and apps ref-counted.

This introduces a new Extension.context_processors list, which defines
context processors the extension wants to have available for all
templates.

It also adds protection for both context_processors and apps.
Previously, extensions were assumed to never list an app that another
extension may list, or that the main application lists. Otherwise,
disabling the extension would remove the main item from that list.

The list of context processors and apps are now ref-counted.
ExtensionManager wraps its own access to
settings.TEMPLATE_CONTEXT_PROCESSORS and settings.INSTALLED_APPS.
It won't add new entries if they already exist, and won't remove
entries unless the ref count drops to 0.

Tested this with an extension reusing some apps from another.

Unit tests pass.

Description From Last Updated

In order to be more consistent with python lists, extend() instead of add_list()?

daviddavid
david
  1. 
      
  2. djblets/extensions/manager.py (Diff revision 1)
     
     

    In order to be more consistent with python lists, extend() instead of add_list()?

    1. What about remove_list?

      I'm okay making it like the list API, but I don't know that it's necessary for it to be the same. It's internal anyway.

    2. Just a suggestion. Feel free to ignore it.

    3. I'm totally fine changing the name, but the lack of a counterpart for removing a list irks me :)

  3. 
      
chipx86
Review request changed

Status: Closed (submitted)

Loading...