@application.route('/event_click')
def event_click():
 try:
  session_str = urllib.unquote(request.cookies.get('reddit_session', ''))
  user_id = int(session_str.split(',')[0])
 except ValueError:
  user_id = None
 args = request.args.to_dict()
 if user_id:
  payload = args.get('data').encode('utf-8')
  try:
   payload_json = json.loads(payload)
  except ValueError:
   pass
  else:
   payload_json['user_id'] = user_id
   args['data'] = json.dumps(payload_json)
 return _redirect_nocache(('/event_redirect?%s' % urllib.urlencode(args)))

@ application . route ( '/event_click' ) def event_click ( ) : try : session_str = urllib . unquote ( request . cookies . get ( 'reddit_session' , '' ) ) user_id = int ( session_str . split ( ',' ) [ 0 ] ) except ValueError : user_id = None args = request . args . to_dict ( ) if user_id : payload = args . get ( 'data' ) . encode ( 'utf-8' ) try : payload_json = json . loads ( payload ) except ValueError : pass else : payload_json [ 'user_id' ] = user_id args [ 'data' ] = json . dumps ( payload_json ) return _redirect_nocache ( ( '/event_redirect?%s' % urllib . urlencode ( args ) ) )
take in an evented request .