Feature #1269

API: get_by_menu_item() for actors

Added by Bernhard Koschicek about 1 month ago. Updated about 1 month ago.

Target version:
Start date:
Estimated time:


I try to access the API with json payload. It works fine, but when I'm using the get_by_menu_item function with actor as argument the application crashes with following Stacktrace:

Traceback (most recent call last):
  File "C:\Users\bkoschicek\Desktop\tnt\python\venv\lib\site-packages\flask\", line 2463, in __call__
    return self.wsgi_app(environ, start_response)
  File "C:\Users\bkoschicek\Desktop\tnt\python\venv\lib\site-packages\flask\", line 2449, in wsgi_app
    response = self.handle_exception(e)
  File "C:\Users\bkoschicek\Desktop\tnt\python\venv\lib\site-packages\flask\", line 1866, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "C:\Users\bkoschicek\Desktop\tnt\python\venv\lib\site-packages\flask\", line 39, in reraise
    raise value
  File "C:\Users\bkoschicek\Desktop\tnt\python\venv\lib\site-packages\flask\", line 2446, in wsgi_app
    response = self.full_dispatch_request()
  File "C:\Users\bkoschicek\Desktop\tnt\python\venv\lib\site-packages\flask\", line 1951, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "C:\Users\bkoschicek\Desktop\tnt\python\venv\lib\site-packages\flask\", line 1820, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "C:\Users\bkoschicek\Desktop\tnt\python\venv\lib\site-packages\flask\", line 39, in reraise
    raise value
  File "C:\Users\bkoschicek\Desktop\tnt\python\venv\lib\site-packages\flask\", line 1949, in full_dispatch_request
    rv = self.dispatch_request()
  File "C:\Users\bkoschicek\Desktop\tnt\python\venv\lib\site-packages\flask\", line 1935, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "C:\Users\bkoschicek\Desktop\OpenAtlas\oa-dev\openatlas\util\", line 370, in wrapped
    return f(*args, **kwargs)
  File "C:\Users\bkoschicek\Desktop\OpenAtlas\oa-dev\openatlas\views\", line 42, in api_get_entities_by_json
    return jsonify(Api.get_entities_by_menu_item(code_=item))
  File "C:\Users\bkoschicek\Desktop\OpenAtlas\oa-dev\openatlas\models\", line 74, in get_entities_by_menu_item
    for entity in Entity.get_by_menu_item(code_):
  File "C:\Users\bkoschicek\Desktop\OpenAtlas\oa-dev\openatlas\models\", line 390, in get_by_menu_item
    aliases = True if menu_item == 'actor' and current_user.settings[
  File "C:\Users\bkoschicek\Desktop\tnt\python\venv\lib\site-packages\werkzeug\", line 348, in __getattr__
    return getattr(self._get_current_object(), name)
AttributeError: 'AnonymousUserMixin' object has no attribute 'settings'

The API is set to public and I'm not logged in



Updated by Alexander Watzinger about 1 month ago

  • Found in version set to 5.2.0
  • Target version set to 5.3.0
  • Assignee set to Bernhard Koschicek
  • Status changed from New to In Progress
  • Category set to API
  • Subject changed from get_by_menu_item with actor not working in postman to API: get_by_menu_item() with actor not working

Thank you for the detailed description. Problem was that this function is also used for table views and when trying to access user profile settings to show aliases it failed because a not logged in user has no settings.

Fixed it for now in develop (not logged in user gets no aliases) but depending on how you want to use the functions (e.g. with aliases or a parameter to toggle) we may have to make (not trivial) changes there. So assigned this issue back to you for further processing.

I also commented out some tests in because they are failing (at least on my machine). Since we all merge into develop tests there should always pass and ideally have a 100% code coverage. Correct way to do this is to first merge develop to the feature branch, run tests and only if they pass merge the feature branch to develop. I'm aware that this could get tricky with API development on different operating systems but please take a look at it.


Updated by Bernhard Koschicek about 1 month ago

  • Status changed from In Progress to Closed

Thank you for the fix. It works now.
I don't think, that I need more changes. But I have to test it further with token based authentication.

To the tests, yes this was my bad. I refactored the function names and didn't know that the IDE could not refactor the names in the test. Sorry, next time I will be more careful, it was just in the heat of the moment ;) I will try to concentrate more on tests soon.


Updated by Alexander Watzinger about 1 month ago

Glad that it works. No worries about the merging stuff that already happened. We all are learning to adapt the workflow as our team grows so I updated the Git workflow page with a more detailed workflow instruction as well.

Also I'm not sure about calling this issue a bug and think it's more about adding functionality. So maybe calling it "API: adapt get_by_menu_item() for actors" and changing it to a feature but it's your ticket and I leave it up to you.


Updated by Bernhard Koschicek about 1 month ago

  • Found in version deleted (5.2.0)
  • Subject changed from API: get_by_menu_item() with actor not working to API: get_by_menu_item() for actors
  • Tracker changed from Bug to Feature

Also available in: Atom PDF