Esempio n. 1
0
    def create_viewer(user, viewer_id, viewer_name):
        time_num = int(time.time())
        c_id = user.user_id + "_" + viewer_id + '_' + str(time_num)

        expire_time_num = time_num + (110 * 60)
        tkn = channel.create_channel(c_id, 120)
        viewer = Viewer(parent=user.key,
                        viewer_id=viewer_id,
                        viewer_name=viewer_name,
                        channel_id=c_id,
                        token=tkn,
                        token_expiration=expire_time_num)
        viewer.put()
        return viewer
Esempio n. 2
0
    def create_viewer(user, viewer_id, viewer_name):
        time_num = int(time.time())
        c_id = user.user_id + "_" + viewer_id + "_" + str(time_num)

        expire_time_num = time_num + (110 * 60)
        tkn = channel.create_channel(c_id, 120)
        viewer = Viewer(
            parent=user.key,
            viewer_id=viewer_id,
            viewer_name=viewer_name,
            channel_id=c_id,
            token=tkn,
            token_expiration=expire_time_num,
        )
        viewer.put()
        return viewer
Esempio n. 3
0
 def get_viewer(user, viewer_id, viewer_name=None):
     viewer = Viewer.query(Viewer.viewer_id == viewer_id, ancestor=user.key).get()
     if viewer == None:
         if viewer_name != None:
             viewer = ModelLoader.create_viewer(user, viewer_id, viewer_name)
     elif viewer.token_expiration < int(time.time()):
         v_name = viewer_name
         if viewer_name == None:
             v_name = viewer.viewer_name
         viewer = ModelLoader.create_viewer(user, viewer_id, v_name)
     return viewer
Esempio n. 4
0
 def get_viewer(user, viewer_id, viewer_name=None):
     viewer = Viewer.query(Viewer.viewer_id == viewer_id,
                           ancestor=user.key).get()
     if viewer == None:
         if viewer_name != None:
             viewer = ModelLoader.create_viewer(user, viewer_id,
                                                viewer_name)
     elif viewer.token_expiration < int(time.time()):
         v_name = viewer_name
         if viewer_name == None:
             v_name = viewer.viewer_name
         viewer = ModelLoader.create_viewer(user, viewer_id, v_name)
     return viewer