Comments (5)
Okay, you convinced me ;-)
I like your idea about per session field names memorization, but I don't think it will work, because if a first object in a queue won't have a requested field an exception will be thrown anyway.
So I believe the option 2 is the best we can do. I added the raise_attr_exception kwarg to Redmine object which defaults to True to not break existing code. See 11d3f5e. You can set it to False to completely disable the ResourceAttrError or you can give it a list or tuple of resource class names and it will continue to raise an exception only for this types of resources. All other resources will return None and remain silent. Details can be found in the documentation.
Please reopen if anything isn't working like it should. Thanks.
from python-redmine.
Only two things come to my mind at the moment:
- We can hardcode all the valid attributes for each resource and then check if a requested attribute is in the list of valid attributes we fail silently. But this is what I always trying to avoid, for example if a new version of Redmine will be released and there will be some new fields we will have to add them to this list of valid attributes every time. Not good.
- Add a global or per resource option whether to raise an exception if an unset attribute is requested. This will solve this problem but it may give you another problems, e.g. imagine you mistyped a resource attribute (issue.subjekt) and it won't tell you anything about it and you won't get any subject of course. Not good also.
What do you think ?
from python-redmine.
I agree that a solution to such a problem is not available without some sort of compromise. I also agree that the first solution you listed would be a support nightmare.
But the second, if it's given as a constructor parameter for the main Redmine object or wherever, is a "risk" the user takes - just like setting https request verification to False - I find this less of a problem.
I hit this problem while listing issues inside a template, some had an optional field set, some didn't. For this case, a different kind of compromise can be imagined: each Redmine session could infer existing field names for the current connection for each resource type, and return None in getattr whenever we know this field existed in at least one resource of this type, not necessarily the current one.
This will at least give the connector knowledge of the fields that it received up to one point. These may very well not be all fields, but it might be a step forward (also, at least in some usecases, an user is less likely to request attrs that none of the resources he requested has, right?)
from python-redmine.
Great, thanks!
from python-redmine.
It turned out very useful.
from python-redmine.
Related Issues (20)
- tags from task HOT 2
- check the existence of a task HOT 1
- Copy project HOT 2
- Is it possible to integrate a "geojson" parameter in issue creation? HOT 2
- KeyError: 'time_entry' HOT 3
- Cant Set priority_id HOT 5
- When adding a user to a group that they are already a member of get "User is invalid" HOT 2
- How to: Create Issue onbehalf of another user HOT 4
- Bug: User does not return status HOT 3
- Bug: Users.all() does not return all users HOT 4
- When querying resources, why is there a default_includes HOT 2
- Leaks API key on exception HOT 2
- Filter by application subject HOT 2
- BytesIO is not JSON serializable HOT 4
- ResourceNotFoundError: Requested resource doesn't exist HOT 2
- Get Request - ResourceNotFoundError: Requested resource doesn't exist HOT 2
- filter error HOT 2
- ???????? for Russian text HOT 6
- adding custom fields to project HOT 2
- Get member users from project_membership HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-redmine.