Reference all resource instances in a Resources object instance.

Review Request #4523 — Created Sept. 2, 2013 and discarded

Information

Review Board
master

Reviewers

Reference all resource instances in a Resources object instance.

This collects all the resource instances into a container object
called Resources. This is something that can be empty at first and
easily importable, and later filled in, helping with the upcoming
resources file split work. Resource code that executes after
initialization and needs to reference other resources can import this
object and reference the instances within.

Basically, this breaks the circular dependency problem.

Unit tests pass.

Description From Last Updated

Col: 80 E501 line too long (81 > 79 characters)

reviewbotreviewbot

Thoughts on making this instantiate the resources rather than having them globally?

daviddavid
reviewbot
  1. This is a review from Review Bot.
    Tool: PEP8 Style Checker
    Processed Files:
    reviewboard/webapi/tests/urls.py
    reviewboard/webapi/resources.py
    reviewboard/urls.py
    Ignored Files:

  2. reviewboard/webapi/resources.py (Diff revision 1)
     
     
    Show all issues

    Col: 80
    E501 line too long (81 > 79 characters)

  3. 
      
reviewbot
  1. This is a review from Review Bot.
    Tool: Pyflakes
    Processed Files:
    reviewboard/webapi/tests/urls.py
    reviewboard/webapi/resources.py
    reviewboard/urls.py
    Ignored Files:

  2. 
      
david
  1. 
      
  2. reviewboard/webapi/resources.py (Diff revision 1)
     
     
     
     
     
     
     
    Show all issues

    Thoughts on making this instantiate the resources rather than having them globally?

    1. I played around with different models. We basically need to instantiate after the class is defined for the child resource chaining (since {list,item}_child_resources[] references instances of other classes). That's too late for the resources class. We can't instantiate here.

      The model I'm going with is to have a class per resource. The file imports the instances from the other resource files that it needs for the child chaining. Each one does that. In the end, the init.py will load the Resources class instance and have it set all the members to the resources that are needed. That way, we break the circular references caused by handlers calling get_object on other resources. We still have the resource files importing dependencies, but only to build the tree.

  3. 
      
chipx86
Review request changed
Status:
Discarded