#NEWLINE# @ gen . coroutine #NEWLINE# def _Check( self ) : #NEWLINE# #INDENT# 'Gathers pre-mutation information:\n       1. Existing viewpoint and owner follower.\n       2. Followers of the existing viewpoint.\n       3. List of requested episodes and photos to share.\n       4. Checkpoints list of episode and post ids that need to be (re)created.\n       5. Checkpoints list of followers that need to be revived.\n       6. Checkpoints boolean indicating whether cover photo needs to be set.\n\n       Validates the following:\n       1. Permissions to share from source episodes.\n       2. Permission to share into existing viewpoint.\n    ' #NEWLINE# ( self . _viewpoint , self . _follower ) = ( yield gen . Task ( Viewpoint . QueryWithFollower , self . _client , self . _user_id , self . _viewpoint_id ) ) #NEWLINE# if ( ( self . _follower is None ) or ( not self . _follower . CanContribute ( ) ) ) : #NEWLINE# #INDENT# raise PermissionError ( ( 'User %d does not have permission to contribute to viewpoint "%s".' % ( self . _user_id , self . _viewpoint_id ) ) ) #NEWLINE# #UNINDENT# assert ( self . _viewpoint is not None ) , self . _viewpoint_id #NEWLINE# ( self . _followers , _ ) = ( yield gen . Task ( Viewpoint . QueryFollowers , self . _client , self . _viewpoint_id , limit = Viewpoint . MAX_FOLLOWERS ) ) #NEWLINE# self . _source_ep_posts_list = ( yield ViewfinderOperation . _CheckCopySources ( 'share' , self . _client , self . _user_id , self . _ep_dicts ) ) #NEWLINE# target_ep_ids = [ ep_dict [ 'new_episode_id' ] for ep_dict in self . _ep_dicts ] #NEWLINE# self . _new_ep_dicts = ViewfinderOperation . _CreateCopyTargetDicts ( self . _op . timestamp , self . _user_id , self . _viewpoint_id , self . _source_ep_posts_list , target_ep_ids ) #NEWLINE# if ( self . _op . checkpoint is None ) : #NEWLINE# #INDENT# self . _new_ids = ( yield self . _CheckCopyTargets ( 'share' , self . _client , self . _user_id , self . _viewpoint_id , self . _new_ep_dicts ) ) #NEWLINE# self . _revive_follower_ids = self . _GetRevivableFollowers ( self . _followers ) #NEWLINE# self . _need_cover_photo = ( ( not self . _viewpoint . IsDefault ( ) ) and ( not self . _viewpoint . IsCoverPhotoSet ( ) ) ) #NEWLINE# checkpoint = { #NEWLINE# #INDENT# 'new' : list ( self . _new_ids ) , #NEWLINE# 'revive' : self . _revive_follower_ids , #NEWLINE# 'cover' : self . _need_cover_photo , #NEWLINE# #UNINDENT# } #NEWLINE# ( yield self . _op . SetCheckpoint ( self . _client , checkpoint ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . _new_ids = set ( self . _op . checkpoint [ 'new' ] ) #NEWLINE# self . _revive_follower_ids = self . _op . checkpoint [ 'revive' ] #NEWLINE# self . _need_cover_photo = self . _op . checkpoint [ 'cover' ] #NEWLINE# #UNINDENT# raise gen . Return ( True )