Skip to content
This repository has been archived by the owner on Sep 28, 2022. It is now read-only.

Commit

Permalink
Merge pull request #126 from postatum/107523186_requestuser_none
Browse files Browse the repository at this point in the history
Use getattr to get request.user
  • Loading branch information
jstoiko committed Nov 11, 2015
2 parents 3cb61bf + 99602cf commit 499532e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion nefertari/acl.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def authenticated_userid(request):
"""Helper function that can be used in ``db_key`` to support `self`
as a collection key.
"""
user = request.user
user = getattr(request, 'user', None)
key = user.pk_field()
return getattr(user, key)

Expand Down
5 changes: 3 additions & 2 deletions nefertari/tweens.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,10 @@ def enable_selfalias(config, id_name):

def context_found_subscriber(event):
request = event.request
user = getattr(request, 'user', None)
if (request.matchdict and
request.matchdict.get(id_name, None) == 'self' and
request.user):
request.matchdict[id_name] = request.user.username
user):
request.matchdict[id_name] = user.username

config.add_subscriber(context_found_subscriber, ContextFound)

0 comments on commit 499532e

Please sign in to comment.