Skip to content

Commit b2b6053

Browse files
committed
Merge branch 'master' of github.com:google/oauth2client
2 parents 993913d + 0960cae commit b2b6053

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

oauth2client/django_orm.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,21 @@ def locked_get(self):
116116
credential.set_store(self)
117117
return credential
118118

119-
def locked_put(self, credentials):
119+
def locked_put(self, credentials, overwrite=False):
120120
"""Write a Credentials to the datastore.
121121
122122
Args:
123123
credentials: Credentials, the credentials to store.
124+
overwrite: Boolean, indicates whether you would like these credentials to
125+
overwrite any existing stored credentials.
124126
"""
125127
args = {self.key_name: self.key_value}
126-
entity = self.model_class(**args)
128+
129+
if overwrite:
130+
entity, unused_is_new = self.model_class.objects.get_or_create(**args)
131+
else:
132+
entity = self.model_class(**args)
133+
127134
setattr(entity, self.property_name, credentials)
128135
entity.save()
129136

0 commit comments

Comments
 (0)