Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(368)

Side by Side Diff: third_party/oauth2client/django_orm.py

Issue 1094533003: Revert of Upgrade 3rd packages (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « third_party/oauth2client/devshell.py ('k') | third_party/oauth2client/file.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2014 Google Inc. All rights reserved. 1 # Copyright (C) 2010 Google Inc.
2 # 2 #
3 # Licensed under the Apache License, Version 2.0 (the "License"); 3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License. 4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at 5 # You may obtain a copy of the License at
6 # 6 #
7 # http://www.apache.org/licenses/LICENSE-2.0 7 # http://www.apache.org/licenses/LICENSE-2.0
8 # 8 #
9 # Unless required by applicable law or agreed to in writing, software 9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS, 10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 credential = None 109 credential = None
110 110
111 query = {self.key_name: self.key_value} 111 query = {self.key_name: self.key_value}
112 entities = self.model_class.objects.filter(**query) 112 entities = self.model_class.objects.filter(**query)
113 if len(entities) > 0: 113 if len(entities) > 0:
114 credential = getattr(entities[0], self.property_name) 114 credential = getattr(entities[0], self.property_name)
115 if credential and hasattr(credential, 'set_store'): 115 if credential and hasattr(credential, 'set_store'):
116 credential.set_store(self) 116 credential.set_store(self)
117 return credential 117 return credential
118 118
119 def locked_put(self, credentials, overwrite=False): 119 def locked_put(self, credentials):
120 """Write a Credentials to the datastore. 120 """Write a Credentials to the datastore.
121 121
122 Args: 122 Args:
123 credentials: Credentials, the credentials to store. 123 credentials: Credentials, the credentials to store.
124 overwrite: Boolean, indicates whether you would like these credentials to
125 overwrite any existing stored credentials.
126 """ 124 """
127 args = {self.key_name: self.key_value} 125 args = {self.key_name: self.key_value}
128 126 entity = self.model_class(**args)
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
134 setattr(entity, self.property_name, credentials) 127 setattr(entity, self.property_name, credentials)
135 entity.save() 128 entity.save()
136 129
137 def locked_delete(self): 130 def locked_delete(self):
138 """Delete Credentials from the datastore.""" 131 """Delete Credentials from the datastore."""
139 132
140 query = {self.key_name: self.key_value} 133 query = {self.key_name: self.key_value}
141 entities = self.model_class.objects.filter(**query).delete() 134 entities = self.model_class.objects.filter(**query).delete()
OLDNEW
« no previous file with comments | « third_party/oauth2client/devshell.py ('k') | third_party/oauth2client/file.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698