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

Side by Side Diff: appengine/chromium_build_logs/third_party/apiclient/ext/django_orm.py

Issue 1260293009: make version of ts_mon compatible with appengine (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: clean up code Created 5 years, 4 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
OLDNEW
(Empty)
1 # Copyright (C) 2010 Google Inc.
2 #
3 # Licensed under the Apache License, Version 2.0 (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
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 import apiclient
16 import base64
17 import pickle
18
19 from django.db import models
20
21
22 class OAuthCredentialsField(models.Field):
23
24 __metaclass__ = models.SubfieldBase
25
26 def db_type(self):
27 return 'VARCHAR'
28
29 def to_python(self, value):
30 if value is None:
31 return None
32 if isinstance(value, apiclient.oauth.Credentials):
33 return value
34 return pickle.loads(base64.b64decode(value))
35
36 def get_db_prep_value(self, value):
37 return base64.b64encode(pickle.dumps(value))
38
39
40 class FlowThreeLeggedField(models.Field):
41
42 __metaclass__ = models.SubfieldBase
43
44 def db_type(self):
45 return 'VARCHAR'
46
47 def to_python(self, value):
48 print "In to_python", value
49 if value is None:
50 return None
51 if isinstance(value, apiclient.oauth.FlowThreeLegged):
52 return value
53 return pickle.loads(base64.b64decode(value))
54
55 def get_db_prep_value(self, value):
56 return base64.b64encode(pickle.dumps(value))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698