Skip to content

Commit

Permalink
[master][noticket][xs]: Docstring addded.
Browse files Browse the repository at this point in the history
  • Loading branch information
David Read committed Feb 7, 2012
1 parent 3f03187 commit ed0d130
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion ckan/lib/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,18 @@ def __before__(self, action, **params):
i18n.handle_request(request, c)

def _identify_user(self):
'''
Identifies the user using two methods:
a) If he has logged into the web interface then repoze.who will
set REMOTE_USER.
b) For API calls he may set a header with his API key.
If the user is identified then:
c.user = user name (unicode)
c.author = user name
otherwise:
c.user = None
c.author = user\'s IP address (unicode)
'''
# see if it was proxied first
c.remote_addr = request.environ.get('HTTP_X_FORWARDED_FOR', '')
if not c.remote_addr:
Expand All @@ -98,7 +110,7 @@ def _identify_user(self):
c.user = c.user.decode('utf8')
c.userobj = model.User.by_name(c.user)
if c.userobj is None:
# This occurs when you are logged in with openid, clean db
# This occurs when you are logged in, clean db
# and then restart i.e. only really for testers. There is no
# user object, so even though repoze thinks you are logged in
# and your cookie has ckan_display_name, we need to force user
Expand Down

0 comments on commit ed0d130

Please sign in to comment.