コード例 #1
0
    def POST(self,contactid):
        try:
            logger = getLogger()
            logger.debug("start Order Page POST response")

            globalDefine.globalOrderInfoErrorlog = "No Error"

            #TODO: open the auth in future.also need purview.
#            authreq = checkUserAuth(web)
#
#            if authreq:
#                web.header('WWW-Authenticate','Basic realm="Auth example"')
#                web.ctx.status = '401 Unauthorized'
#                logger.debug("no right HTTP_AUTHORIZATION")
#                return render.error(error = web.ctx.status)

            if contactid is None:
                return render.error(error = 'no contactid')
            else:
                #get POST form data
                data = web.input()
                #call REST post data
                #TODO: 1 means 待审核订单
                status = '1'

                retStr = OrderDomainHandler.postOrderInfoContact(contactid,data,status,web.ctx.session.session_usrid,web.ctx.session.session_grpid)

                if retStr is None:
                    return render.error(error = 'add failure.')

                #according the response
                retDict = json.loads(retStr)
                if (retDict["RETURNFLAG"] == True):
                    #refresh the order.
                    orderidStr = retDict["OrderID"]
                    role = web.ctx.session.session_role;
                    return render.order(contactid = contactid,orderid = orderidStr,outrole = role)
                else:
                    return render.error(error = 'add failure.')

        except :
            logger.error("exception occur, see the traceback.log")
            #异常写入日志文件.
            f = open('traceback.txt','a')
            traceback.print_exc()
            traceback.print_exc(file = f)
            f.flush()
            f.close()
        else:
            pass
        finally:
            pass
コード例 #2
0
    def GET(self,page,usrid,pwd):
        try:
            logger = getLogger()
            logger.debug("start login GET response")

            globalDefine.globalOrderInfoErrorlog = "No Error"

            #TODO:传过来的usrid和pwd要是加密的.未来完成权限的取得.
            #如何加密usrid,pwd

            #连接逻辑层验证用户信息.
            retDict = OrderDomainHandler.getUsrPurview(usrid,pwd)

            if (retDict["right"] is True):
                #保存用户信息到session里面
                web.ctx.session.session_loginned = True
                web.ctx.session.session_usrid = usrid
                return retDict
                pass
            else:
                return render.error(error = retDict["log"])

            #如何跳转登录到其它页面?传入页面的参数.

            #直接登录其它页面是需要登录信息的.

        except :
            logger.error("exception occur, see the traceback.log")
            #异常写入日志文件.
            f = open('traceback.txt','a')
            traceback.print_exc()
            traceback.print_exc(file = f)
            f.flush()
            f.close()
        else:
            pass
        finally:
            pass