Skip to content
This repository has been archived by the owner on May 29, 2024. It is now read-only.

Improve usage of _resolve_variable method #2

Open
toirl opened this issue Jan 18, 2016 · 0 comments
Open

Improve usage of _resolve_variable method #2

toirl opened this issue Jan 18, 2016 · 0 comments

Comments

@toirl
Copy link
Member

toirl commented Jan 18, 2016

The method _resolve_variable is used to resolve a $foo variable within a rule into a pythonic value . The valuea are given in a dictionary. So if the dictionary contains a value for the key "foo" the value will be returned. Otherwise a error is logged if the value can not be found.

The problem with this behavior is that the logging is done regardless on the context in which the function is called. Consider the following rule:

bool($foo) with a empty dictionary. Currently the foo variable would be resolved and the bool method is called with the result. Logging the fact that the variable is missing is senseless here because the bool method is used to check if a value is present. In this case a missing value is an expected case and should not be logged.

An improvement might be to call the method not globally but in context of a specific function. So the bool method may catch the case the the value is missing and silently continue while other functions can log or even raise an exception.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant