params
doesn't make sense if we don't have a request
#126
Conversation
Tests are failing because of an unrelated problem. |
Should we change the lookup mechanism instead? What if someone had a |
@tsx what do you suggest as an alternative for the lookup mechanism? I think the simplest solution here doesn't feel wrong, and it would be to also |
Another alternative is to blacklist some attribute names for documents based on what attributes a default resource has. Blacklist For example, in the future an unknowingly developer could want to overwrite the In a sense, the blacklist strategy feels more future-proof. But simply raising @tsx do you have an opinion on this? |
Yes this is an issue with current design in general. I'd suggest separating resource's own processing stuff from these "magic accessors". But obviously this breaking design change is way out of scope of current fix. But simply raising AttributeError from both My alternative (it might be a little controversial because of more introspection involved) is to check the resource's class (not resource instance) for the existence of the attribute (you'll get just the property descriptor so it won't try to execute it), and do that in a way that doesn't include superclasses - so we can ignore anything coming from a base Resource. At the end of the day though, |
I tried a proof-of-concept of a more introspective solution like the one you described, and I think it becomes complex really quickly for not that much benefit over the simpler solution of raising The one I tried is to go for the class's
So, maybe I should evaluate also the I think the tradeoff between complexity, maintainability and readability here makes me prefer the simplest implementation. Even if there's a simpler introspective solution than the one I tried, we can always improve things later by revisiting this topic at a later time. |
If we don't have an active request context, evaluating
params
doesn't make sense and is analogous to the attribute not existing at all, so we raise anAttributeError
to makehasattr
returnFalse
.