Add kwargs and caching of commonly computed condition values state.

Review Request #8344 — Created Aug. 25, 2016 and submitted

Information

Djblets
release-0.10.x
2d2fdc4...

Reviewers

Condition choices may need to hit the database or perform some other
expensive computation in order to make a match determination. Sometimes
these conditions need the same information, or sometimes a condition
will be used more than once. In these cases, it can be handy for the
implementations of those choices to be able to cache some common state,
like the results of the database queries.

This adds a new, optional value_state_cache keyword argument to the
get_match_value() methods, which can be used to populate that cache. The
cache is local to a ConditionSet match run, and does not otherwise
persist.

Along with this, BaseConditionChoice.get_match_value() and
BaseConditionOperator.matches() now take a **kwargs, in order to allow
for future expansion (and to swallow the new value_state_cache argument
for methods that don't need to use it).

Unit tests pass.

Made use of the new caching in an implementation.

reviewbot
  1. Tool: Pyflakes
    Processed Files:
        djblets/conditions/conditions.py
        djblets/conditions/choices.py
        djblets/conditions/operators.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        djblets/conditions/conditions.py
        djblets/conditions/choices.py
        djblets/conditions/operators.py
    
    
  2. 
      
david
  1. Ship It!
  2. 
      
chipx86
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to release-0.10.x (eaa01dd)
Loading...