Esempio n. 1
0
 def GET(self, jrequest, jresponse):
     assert isinstance(jrequest, JsonRpcRequest)
     assert isinstance(jresponse, JsonRpcResponse)
     jresponse.setId()
     
     try:
         odenki_user = OdenkiUser.loadFromSession()
         assert isinstance(odenki_user, OdenkiUser)
     except: odenki_user = None
     
     try:
         email_user = EmailUser.getByOdenkiId(odenki_user.odenkiId)
         assert isinstance(email_user, EmailUser)
     except: email_user = None
     
     try:
         twitter_user = TwitterUser.getByOdenkiId(odenki_user.odenkiId)
         assert isinstance(twitter_user, TwitterUser)
     except: twitter_user = None
     
     try:
         gmail_user = GmailUser.getByOdenkiId(odenki_user.odenkiId)
         assert isinstance(gmail_user, GmailUser)
     except: gmail_user = None
     
     jresponse.setResultValue(odenki_user.__class__.__name__, odenki_user)
     jresponse.setResultObject(email_user)
     jresponse.setResultObject(twitter_user)
     jresponse.setResultObject(gmail_user)
     login_url = users.create_login_url("/api/auth/Gmail/RedirectedFromGoogle")
     jresponse.setResultValue("login_url", login_url)
Esempio n. 2
0
 def deleteTwitterUser(self, jrequest, jresponse):
     assert isinstance(jrequest, JsonRpcRequest)
     assert isinstance(jresponse, JsonRpcResponse)
     jresponse.setId()
     odenki_user = OdenkiUser.loadFromSession()
     assert isinstance(odenki_user, OdenkiUser)
     twitter_user = TwitterUser.getByOdenkiId(odenki_user.odenkiId)
     assert isinstance(twitter_user, TwitterUser)
     twitter_user.key.delete()
     jresponse.setResultValue("OdenkiUser", odenki_user)
Esempio n. 3
0
 def deleteTwitterUser(self, jrequest, jresponse):
     assert isinstance(jrequest, JsonRpcRequest)
     assert isinstance(jresponse, JsonRpcResponse)
     jresponse.setId()
     odenki_user = OdenkiUser.loadFromSession()
     assert isinstance(odenki_user, OdenkiUser)
     twitter_user = TwitterUser.getByOdenkiId(odenki_user.odenkiId)
     assert isinstance(twitter_user, TwitterUser)
     twitter_user.key.delete()
     jresponse.setResultValue("OdenkiUser", odenki_user)
Esempio n. 4
0
    def GET(self, jrequest, jresponse):
        assert isinstance(jrequest, JsonRpcRequest)
        assert isinstance(jresponse, JsonRpcResponse)
        jresponse.setId()
        twitter_user = None
        odenki_user = None
        try:
            odenki_user = OdenkiUser.loadFromSession()
        except EntityNotFound: pass

        if odenki_user:
            try:
                twitter_user = TwitterUser.getByOdenkiId(odenki_user.odenkiId)
            except EntityNotFound: pass
        jresponse.setResult({"OdenkiUser": odenki_user, "TwitterUser":twitter_user})
Esempio n. 5
0
def fillTwitterUser():
    """fillTwitterUser() loads TwitterUser into the session if OdenkiUser is already in the session
    and fill TwitterUser.odenkiId if it does not exist.
    It also loads OdenkiUser into the session if TwitterUser is already in it and TwitterUser.odenkiId exists.  
    """
    odenki_user = OdenkiUser.loadFromSession()
    assert isinstance(odenki_user, OdenkiUser)
    try:
        twitter_user = TwitterUser.loadFromSession()
    except EntityNotFound:
        twitter_user = TwitterUser.getByOdenkiId(odenki_user.odenkiId)
    assert isinstance(twitter_user, TwitterUser)
    
    if twitter_user.odenkiId is None:
        twitter_user.odenkiId = odenki_user.odenkiId
        twitter_user.put() # put TwitterUser if odenkiId is updated
    twitter_user.saveToSession()
Esempio n. 6
0
def fillTwitterUser():
    """fillTwitterUser() loads TwitterUser into the session if OdenkiUser is already in the session
    and fill TwitterUser.odenkiId if it does not exist.
    It also loads OdenkiUser into the session if TwitterUser is already in it and TwitterUser.odenkiId exists.  
    """
    odenki_user = OdenkiUser.loadFromSession()
    assert isinstance(odenki_user, OdenkiUser)
    try:
        twitter_user = TwitterUser.loadFromSession()
    except EntityNotFound:
        twitter_user = TwitterUser.getByOdenkiId(odenki_user.odenkiId)
    assert isinstance(twitter_user, TwitterUser)

    if twitter_user.odenkiId is None:
        twitter_user.odenkiId = odenki_user.odenkiId
        twitter_user.put()  # put TwitterUser if odenkiId is updated
    twitter_user.saveToSession()
Esempio n. 7
0
    def GET(self, jrequest, jresponse):
        assert isinstance(jrequest, JsonRpcRequest)
        assert isinstance(jresponse, JsonRpcResponse)
        jresponse.setId()
        twitter_user = None
        odenki_user = None
        try:
            odenki_user = OdenkiUser.loadFromSession()
        except EntityNotFound:
            pass

        if odenki_user:
            try:
                twitter_user = TwitterUser.getByOdenkiId(odenki_user.odenkiId)
            except EntityNotFound:
                pass
        jresponse.setResult({
            "OdenkiUser": odenki_user,
            "TwitterUser": twitter_user
        })
Esempio n. 8
0
    def GET(self, jrequest, jresponse):
        assert isinstance(jrequest, JsonRpcRequest)
        assert isinstance(jresponse, JsonRpcResponse)
        jresponse.setId()

        try:
            odenki_user = OdenkiUser.loadFromSession()
            assert isinstance(odenki_user, OdenkiUser)
        except:
            odenki_user = None

        try:
            email_user = EmailUser.getByOdenkiId(odenki_user.odenkiId)
            assert isinstance(email_user, EmailUser)
        except:
            email_user = None

        try:
            twitter_user = TwitterUser.getByOdenkiId(odenki_user.odenkiId)
            assert isinstance(twitter_user, TwitterUser)
        except:
            twitter_user = None

        try:
            gmail_user = GmailUser.getByOdenkiId(odenki_user.odenkiId)
            assert isinstance(gmail_user, GmailUser)
        except:
            gmail_user = None

        jresponse.setResultValue(odenki_user.__class__.__name__, odenki_user)
        jresponse.setResultObject(email_user)
        jresponse.setResultObject(twitter_user)
        jresponse.setResultObject(gmail_user)
        login_url = users.create_login_url(
            "/api/auth/Gmail/RedirectedFromGoogle")
        jresponse.setResultValue("login_url", login_url)