python-redmine icon indicating copy to clipboard operation
python-redmine copied to clipboard

Project's parent attribute doesn't exist if project is retrieved from a group membership

Open matletix opened this issue 3 years ago • 0 comments

Here is a minimal working example. I have a redmine group "My Redmine Group" associated with the 2 following projects :

Root Project (id=1) └── Subproject (id=4)

########## Explicitly get project with id=4 and get its parent : working
>>> p = redmine.project.get(4)
>>> p
<redminelib.resources.Project #4 "Subproject">
>>> p.id
4
>>> p.parent
<redminelib.resources.Project #1 "Root Project">

########## Get project through group membership and get its parent : not working
>>> group
<redminelib.resources.Group #7 "My Redmine Group">

# Fetch the projects associated to the group via the "membership" attribute
>>> projects = [membership.project for membership in group.memberships]
>>> projects
[<redminelib.resources.Project #1 "Root Project">, <redminelib.resources.Project #4 "Subproject">]

# Get the parent of project with id=4
>>> projects[1]
<redminelib.resources.Project #4 "Subproject">
>>> projects[1].id
4
>>> projects[1].parent
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.9/site-packages/redminelib/resources/base.py", line 197, in __getattr__
    raise exceptions.ResourceAttrError
redminelib.exceptions.ResourceAttrError: Resource doesn't have the requested attribute

# Expected behaviour : return <redminelib.resources.Project #1 "Root Project">

Versions:

  • Python: 3.9
  • python-redmine: 2.3.0

matletix avatar Jul 06 '22 14:07 matletix