예제 #1
0
class _Touch(JsonRpcDispatcher):

    def GET(self, jrequest, jresponse):
        assert isinstance(jrequest, JsonRpcRequest)
        assert isinstance(jresponse, JsonRpcResponse)
        jresponse.setId()
        
        outlet_id = None
        relay_id = None
        card_type = None
        card_id = None
        try:
            outlet_id = unicode(jrequest.getValue("outletId")[0])
            assert isinstance(outlet_id, unicode)
            relay_id = unicode(jrequest.getValue("relayId")[0])
            assert isinstance(relay_id, unicode)
            card_id = unicode(jrequest.getValue("cardId")[0])
            assert isinstance(card_id, unicode)
            card_type = unicode(jrequest.getValue("cardType")[0])
            assert isinstance(card_type, unicode)
        except Exception, e:
            raise InvalidParams({"outletId":None, "relayId":None, "cardType":None, "cardId":None, "exception": e.__class__.__name__})
        
        try:
            outlet = Outlet.getByOutletId(outlet_id)
        except EntityNotFound: 
            outlet = Outlet.create(outlet_id)
        assert isinstance(outlet, Outlet)
        outlet.cardId = card_id
        outlet.cardType = card_type
        outlet.put_async()
        
        try:
            outlet_name = jrequest.getValue("outletName")[0]
            assert isinstance(outlet_name, unicode)
            outlet.outletName = outlet_name
            outlet.put_async()
        except: pass
        
        try:
            odenki_user = OdenkiUser.loadFromSession()
            outlet.odenkiId = odenki_user.odenkiId
            outlet.put_async()
        except: pass
        
        outlet.saveToSession()
        
        jresponse.setResultObject(outlet)
        jresponse.setRedirectTarget("/html/outlet.html")
예제 #2
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:
         outlet = Outlet.loadFromSession()
         assert isinstance(outlet, Outlet)
     except EntityNotFound: 
         outlet = None
     jresponse.setResultObject(odenki_user)
     jresponse.setResultObject(outlet)
예제 #3
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:
            outlet = Outlet.loadFromSession()
            assert isinstance(outlet, Outlet)
        except EntityNotFound:
            outlet = None
        jresponse.setResultObject(odenki_user)
        jresponse.setResultObject(outlet)
예제 #4
0
 def GET(self, jrequest, jresponse):
     assert isinstance(jrequest, JsonRpcRequest)
     assert isinstance(jresponse, JsonRpcResponse)
     jresponse.setId()
     for outlet in Outlet.query():
         jresponse.addResult(outlet)
예제 #5
0
 def GET(self, jrequest, jresponse):
     assert isinstance(jrequest, JsonRpcRequest)
     assert isinstance(jresponse, JsonRpcResponse)
     jresponse.setId()
     for outlet in Outlet.query():
         jresponse.addResult(outlet)