#NEWLINE# @ gen . engine #NEWLINE# def _HandleGet( self , short_url , identity_key , viewpoint_id , default_url , is_sms = False , is_first_click = True ) : #NEWLINE# #INDENT# 'Invoked when a user follows a prospective user invitation URL. Sets a prospective user\n    cookie that identifies the user and restricts access to a single viewpoint. Typically\n    redirects the user to the corresponding website conversation page.\n    ' #NEWLINE# identity = ( yield gen . Task ( Identity . Query , self . _client , identity_key , None , must_exist = False ) ) #NEWLINE# if ( ( identity is None ) or ( identity . user_id is None ) ) : #NEWLINE# #INDENT# raise ExpiredError ( 'The requested link has expired and can no longer be used.' ) #NEWLINE# #UNINDENT# next_url = self . get_argument ( 'next' , default_url ) #NEWLINE# if ( urlparse . urlparse ( short_url ) . hostname is not None ) : #NEWLINE# #INDENT# raise InvalidRequestError ( ( 'Cannot redirect to absolute URL: %s' % next_url ) ) #NEWLINE# #UNINDENT# photostore_re = re . match ( '.*/episodes/(.*)/photos/(.*)(\\..)' , next_url ) #NEWLINE# if is_sms : #NEWLINE# #INDENT# settings = AccountSettings . CreateForUser ( identity . user_id , sms_count = 0 ) #NEWLINE# ( yield gen . Task ( settings . Update , self . _client ) ) #NEWLINE# #UNINDENT# user = ( yield gen . Task ( User . Query , self . _client , identity . user_id , None ) ) #NEWLINE# if user . IsRegistered ( ) : #NEWLINE# #INDENT# context = ViewfinderContext . current ( ) #NEWLINE# if ( context is None ) : #NEWLINE# #INDENT# current_user = None #NEWLINE# current_viewpoint_id = None #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# current_user = context . user #NEWLINE# current_viewpoint_id = context . viewpoint_id #NEWLINE# #UNINDENT# if ( ( current_user is None ) or ( current_user . user_id != identity . user_id ) or ( current_viewpoint_id is not None ) ) : #NEWLINE# #INDENT# self . ClearUserCookie ( ) #NEWLINE# self . redirect ( ( '/auth?%s' % urlencode ( dict ( next = next_url ) ) ) ) #NEWLINE# return #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if is_first_click : #NEWLINE# #INDENT# confirm_time = util . GetCurrentTimestamp ( ) #NEWLINE# new_json = deepcopy ( short_url . json ) #NEWLINE# new_json [ 'is_first_click' ] = False #NEWLINE# short_url . json = new_json #NEWLINE# ( yield gen . Task ( short_url . Update , self . _client ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# confirm_time = None #NEWLINE# #UNINDENT# user_cookie_dict = self . CreateUserCookieDict ( user . user_id , user . webapp_dev_id , user_name = user . name , viewpoint_id = viewpoint_id , confirm_time = confirm_time , is_session_cookie = True ) #NEWLINE# self . LoginUser ( user , user_cookie_dict , set_cookie = ( photostore_re is None ) ) #NEWLINE# #UNINDENT# if photostore_re : #NEWLINE# #INDENT# episode_id = photostore_re . group ( 1 ) #NEWLINE# photo_id = photostore_re . group ( 2 ) #NEWLINE# suffix = photostore_re . group ( 3 ) #NEWLINE# next_url = ( yield PhotoStoreHandler . GetPhotoUrl ( self . _client , self . _obj_store , episode_id , photo_id , suffix ) ) #NEWLINE# #UNINDENT# self . redirect ( next_url )