summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGauvain Pocentek <gauvain@pocentek.net>2017-03-17 16:41:07 +0100
committerGauvain Pocentek <gauvain@pocentek.net>2017-03-17 16:41:07 +0100
commit35339d667097d8b937c1f9f2407e4c109834ad54 (patch)
treed0ea35f668cfb3db4785297b9820852ce2630cf5
parent37ee7ea6a9354c0ea5bd618d48b4a2a3ddbc950c (diff)
downloadgitlab-35339d667097d8b937c1f9f2407e4c109834ad54.tar.gz
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
-rw-r--r--RELEASE_NOTES.rst19
-rw-r--r--gitlab/objects.py6
2 files changed, 24 insertions, 1 deletions
diff --git a/RELEASE_NOTES.rst b/RELEASE_NOTES.rst
new file mode 100644
index 0000000..669e00e
--- /dev/null
+++ b/RELEASE_NOTES.rst
@@ -0,0 +1,19 @@
+###############################
+Release notes for python-gitlab
+###############################
+
+This page describes important changes between python-gitlab releases.
+
+Changes from 0.19 to 0.20
+=========================
+
+* The ``projects`` attribute of ``Group`` objects is not a list of ``Project``
+ objects anymore. It is a Manager object giving access to ``GroupProject``
+ objects. To get the list of projects use:
+
+ .. code-block:: python
+
+ group.projects.list()
+
+ Documentation for ``Group`` objects:
+ http://python-gitlab.readthedocs.io/en/stable/gl_objects/groups.html#examples
diff --git a/gitlab/objects.py b/gitlab/objects.py
index efe75d0..3c38e8e 100644
--- a/gitlab/objects.py
+++ b/gitlab/objects.py
@@ -297,6 +297,11 @@ class GitlabObject(object):
return
for k, v in data.items():
+ # If a k attribute already exists and is a Manager, do nothing (see
+ # https://github.com/gpocentek/python-gitlab/issues/209)
+ if isinstance(getattr(self, k, None), BaseManager):
+ continue
+
if isinstance(v, list):
self.__dict__[k] = []
for i in v:
@@ -937,7 +942,6 @@ class GroupAccessRequestManager(BaseManager):
class Group(GitlabObject):
_url = '/groups'
- _constructorTypes = {'projects': 'Project'}
requiredCreateAttrs = ['name', 'path']
optionalCreateAttrs = ['description', 'visibility_level']
optionalUpdateAttrs = ['name', 'path', 'description', 'visibility_level']