summaryrefslogtreecommitdiff
path: root/gitlab/objects.py
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 /gitlab/objects.py
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
Diffstat (limited to 'gitlab/objects.py')
-rw-r--r--gitlab/objects.py6
1 files changed, 5 insertions, 1 deletions
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']