Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0a1bb94

Browse files
author
Gauvain Pocentek
committed
Rework the Gitlab.delete method
Fixes#107
1 parentc3f5b3a commit0a1bb94

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

‎gitlab/__init__.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -471,16 +471,18 @@ def delete(self, obj, id=None, **kwargs):
471471
ifinspect.isclass(obj):
472472
ifnotissubclass(obj,GitlabObject):
473473
raiseGitlabError("Invalid class: %s"%obj)
474-
params= {}
475-
params[obj.idAttr]=id
476-
else:
477-
params=obj.__dict__.copy()
474+
475+
params= {obj.idAttr:idifidelsegetattr(obj,obj.idAttr)}
478476
params.update(kwargs)
477+
479478
missing= []
480479
forkinitertools.chain(obj.requiredUrlAttrs,
481480
obj.requiredDeleteAttrs):
482481
ifknotinparams:
483-
missing.append(k)
482+
try:
483+
params[k]=getattr(obj,k)
484+
exceptKeyError:
485+
missing.append(k)
484486
ifmissing:
485487
raiseGitlabDeleteError('Missing attribute(s): %s'%
486488
", ".join(missing))
@@ -493,6 +495,10 @@ def delete(self, obj, id=None, **kwargs):
493495
# url-parameters left
494496
forattributeinobj.requiredUrlAttrs:
495497
delparams[attribute]
498+
ifobj._id_in_delete_url:
499+
# The ID is already built, no need to add it as extra key in query
500+
# string
501+
params.pop(obj.idAttr)
496502

497503
try:
498504
r=self.session.delete(url,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp