def channel_session_user(func):
 @channel_session
 @functools.wraps(func)
 def inner(message, *args, **kwargs):
  if (not hasattr(message, 'channel_session')):
   raise ValueError('Did not see a channel session to get auth from')
  if (message.channel_session is None):
   from django.contrib.auth.models import AnonymousUser
   message.user = AnonymousUser()
  else:
   fake_request = type('FakeRequest', (object,), {'session': message.channel_session})
   message.user = auth.get_user(fake_request)
  return func(message, *args, **kwargs)
 return inner

def channel_session_user ( func ) : @ channel_session @ functools . wraps ( func ) def inner ( message , * args , ** kwargs ) : if ( not hasattr ( message , 'channel_session' ) ) : raise ValueError ( 'Did not see a channel session to get auth from' ) if ( message . channel_session is None ) : from django . contrib . auth . models import AnonymousUser message . user = AnonymousUser ( ) else : fake_request = type ( 'FakeRequest' , ( object , ) , { 'session' : message . channel_session } ) message . user = auth . get_user ( fake_request ) return func ( message , * args , ** kwargs ) return inner
presents a message .