Make Djblets Extension Template Loader Usable immediately after enabling an extension

Review Request #3907 — Created Feb. 23, 2013 and discarded

Information

Djblets

Reviewers

Note: This partially reverts Mike Conley's patch (Rev: 4fc4092) that was done couple years ago.

Immediately after enabling an extension (Before restart), the djblets extension template loader uses pkg_resources.ResourceLoader.resource_string, which for some reason throws a "NoneType is not callable" exception. Upon restart, everything is fine as Django will add it to the app_directories loader but it doesnt seem to load immediately. This patch reverts parts of mikeconley's patch (rev: 4fc4092) that uses the ResourceLoader to load the resource_string. Instead directly calling pkg_resources.resource_string seems to work just fine.

Tested this with Python 2.7 and a few extensions and was able to load the templates immediately after enabling them. With manager.resource_string, I was getting a "NoneType is not callable". 
Tested with couple of extensions that use Templates. Enabled the extension and Loading the templates works fine. Tested after restart as well.
Description From Last Updated

Should be up by the pkg_resources. Can we not just hasattr(pkg_resources, 'resource_string') below? Under what conditions do we not have …

chipx86chipx86
reviewbot
  1. This is a review from Review Bot.
      Tool: PEP8 Style Checker
      Processed Files:
        djblets/extensions/loaders.py
      Ignored Files:
    
    
  2. 
      
chipx86
  1. You said this is tested with Python 2.7, but we'll need to see testing for 2.5/2.6 as well, since we need to claim compatibility with these versions. The possible non-existence of resource_string concerns me.
  2. djblets/extensions/loaders.py (Diff revision 1)
     
     
     
     
     
    Show all issues
    Should be up by the pkg_resources.
    
    Can we not just hasattr(pkg_resources, 'resource_string') below?
    
    Under what conditions do we not have this? We should document this in a comment.
  3. 
      
HU
  1. test

  2. 
      
HU
  1. Ship It!

    1. This is a production instance of Review Board. Please do your testing on http://demo.reviewboard.org. Thanks!

  2. 
      
RA
Review request changed

Status: Discarded

Loading...