File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -116,14 +116,21 @@ def locked_get(self):
116
116
credential .set_store (self )
117
117
return credential
118
118
119
- def locked_put (self , credentials ):
119
+ def locked_put (self , credentials , overwrite = False ):
120
120
"""Write a Credentials to the datastore.
121
121
122
122
Args:
123
123
credentials: Credentials, the credentials to store.
124
+ overwrite: Boolean, indicates whether you would like these credentials to
125
+ overwrite any existing stored credentials.
124
126
"""
125
127
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
+
127
134
setattr (entity , self .property_name , credentials )
128
135
entity .save ()
129
136
You can’t perform that action at this time.
0 commit comments