Skip to content

Commit 35339d6

Browse files
author
Gauvain Pocentek
committed
Make sure that manager objects are never overwritten
Group.projects (manager) can be replaced by a list of Project objects when creating/updating objects. The GroupObject API is more consistent and closer to the GitLab API, so make sure it is always used. Fixes #209
1 parent 37ee7ea commit 35339d6

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

RELEASE_NOTES.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
###############################
2+
Release notes for python-gitlab
3+
###############################
4+
5+
This page describes important changes between python-gitlab releases.
6+
7+
Changes from 0.19 to 0.20
8+
=========================
9+
10+
* The ``projects`` attribute of ``Group`` objects is not a list of ``Project``
11+
objects anymore. It is a Manager object giving access to ``GroupProject``
12+
objects. To get the list of projects use:
13+
14+
.. code-block:: python
15+
16+
group.projects.list()
17+
18+
Documentation for ``Group`` objects:
19+
http://python-gitlab.readthedocs.io/en/stable/gl_objects/groups.html#examples

gitlab/objects.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,11 @@ def _set_from_dict(self, data, **kwargs):
297297
return
298298

299299
for k, v in data.items():
300+
# If a k attribute already exists and is a Manager, do nothing (see
301+
# https://github.com/gpocentek/python-gitlab/issues/209)
302+
if isinstance(getattr(self, k, None), BaseManager):
303+
continue
304+
300305
if isinstance(v, list):
301306
self.__dict__[k] = []
302307
for i in v:
@@ -937,7 +942,6 @@ class GroupAccessRequestManager(BaseManager):
937942

938943
class Group(GitlabObject):
939944
_url = '/groups'
940-
_constructorTypes = {'projects': 'Project'}
941945
requiredCreateAttrs = ['name', 'path']
942946
optionalCreateAttrs = ['description', 'visibility_level']
943947
optionalUpdateAttrs = ['name', 'path', 'description', 'visibility_level']

0 commit comments

Comments
 (0)