Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(45)

Delta Between Two Patch Sets: appengine_django/auth/middleware.py

Issue 908: [issue6] Google's Users API Integration (Closed) SVN Base: http://google-app-engine-django.googlecode.com/svn/trunk/
Left Patch Set: mail method fixed, code style Created 5 months, 1 week ago
Right Patch Set: Created 5 months, 1 week ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
LEFTRIGHT
1 # Copyright 2008 Google Inc.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License"); 1 # Licensed under the Apache License, Version 2.0 (the "License");
mattbrown.nz 2008/05/09 10:40:20 again, add author or copyright line.
aalbrecht 2008/05/09 20:23:23 On 2008/05/09 10:40:20, mattbrown.nz wrote: > agai
4 # you may not use this file except in compliance with the License. 2 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at 3 # You may obtain a copy of the License at
6 # 4 #
7 # http://www.apache.org/licenses/LICENSE-2.0 5 # http://www.apache.org/licenses/LICENSE-2.0
8 # 6 #
9 # Unless required by applicable law or agreed to in writing, software 7 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS, 8 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and 10 # See the License for the specific language governing permissions and
13 # limitations under the License. 11 # limitations under the License.
14 12
15 from django.contrib.auth.models import AnonymousUser 13 from django.contrib.auth.models import AnonymousUser
16 14
17 from google.appengine.api import users 15 from google.appengine.api import users
18 16
19 from appengine_django.auth import DjangoUser 17 from appengine_django.auth import DjangoUser
20 18
21 19
22 class LazyUser(object): 20 class LazyUser(object):
23 def __get__(self, request, obj_type=None): 21 def __get__(self, request, obj_type=None):
24 if not hasattr(request, '_cached_user'): 22 if not hasattr(request, '_cached_user'):
25 user = users.get_current_user() 23 user = users.get_current_user()
26 if user: 24 if user:
27 request._cached_user = DjangoUser() 25 request._cached_user = DjangoUser()
28 else: 26 else:
29 request._cached_user = AnonymousUser() 27 request._cached_user = AnonymousUser()
30 return request._cached_user 28 return request._cached_user
31 29
mattbrown.nz 2008/05/09 10:40:20 add blank line
aalbrecht 2008/05/09 20:23:23 On 2008/05/09 10:40:20, mattbrown.nz wrote: > add
32
33 class AuthenticationMiddleware(object): 30 class AuthenticationMiddleware(object):
34 def process_request(self, request): 31 def process_request(self, request):
35 request.__class__.user = LazyUser() 32 request.__class__.user = LazyUser()
36 return None 33 return None
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld r338