def execFun(self,fun,str): f= BinMap() f.put("ojson","") rs=self.db.callproc("aws_entrance",[fun,str],f) rs=rs.getvalue(0,"ojson") print(rs) return json.loads(rs)
def http_queryobject(httpMap): querystring=""; regex = re.compile(".+\?(.+)", re.IGNORECASE) out=regex.findall(httpMap.getvalue("HTTP_QUERY_STRING")) if len(out)>0: querystring="&"+out[0] if httpMap.getvalue("HTTP_POST_VARS")!="": querystring="&"+httpMap.getvalue("HTTP_POST_VARS") regex = re.compile("&(\w+)=([^&]+)", re.IGNORECASE) out=regex.findall(querystring) queryobject=BinMap() queryobject.clear() for i in range(len(out)): queryobject.put(out[i][0], out[i][1]) return queryobject
# f.put("v_message","") # rs=db.getSelectResult(f,'1=1','validate_user(\'admin\',\' v_pwd\',null,null,\'web\')') # print rs.getitem() # f.put("ojson","") # rs=db.getSelectResult(f,'1=1','aws_entrance(\'validate_user\',\'admin\')') # print json.loads(rs.getvalue(0,"ojson")) # db.getCursor() # # db.conn.set_isolation_level(psycopg2.extensions.ISOLATION_LEVEL_AUTOCOMMIT) # db.cursor.callproc("validate_user", ['admin',' v_pwd',None,None,'web']) # print db.cursor.fetchone() # db.cursor.execute ( "fetch", [ "_ref" ] ) # fetch row from this cursor # db.cursor.fetchone() # # cur2 = db.cursor() # print cur2.fetchone() # db.closeCursor() # db.getCursor() # db.cursor.callproc("reffunc", ['curname']) # cur2 = db.conn.cursor('curname') # print cur2.fetchone() # db.getCursor() # db.cursor.callproc("aws_entrance", ['bcard_imgidentify_upload','{"rd": "1", "re": "2", "rf": "3", "ra": "4", "rb": "5", "rc": "6", "ri": "201408120326_0jpg"}']) # db.conn.commit() # print db.cursor.fetchall()[0][0] f.put("ojson","") rs=db.callproc("aws_entrance",['bcard_imgidentify_upload','{"rd": "1", "re": "2", "rf": "3", "ra": "4", "rb": "5", "rc": "6", "ri": "201408120326_0jpg"}'],f) print rs.getitem()
class ActionXml(Action): __dom=None; __root=None; __args=None; def __init__(self): self.init(); def getList(self,data,items,args=None): self.appendAttribute("type", "list") args.put('count',str(data.size())) self.initArgs(args); rows=self.appendElement('list') for i in range(0,data.size()): row=self.appendElement('item') for j in range(0,items.size()): yitem=str(items.getvalue(num=j)) p = re.compile(r'\[(\w+)\]') for m in p.finditer(yitem): yitem=yitem.replace(str(m.group()),str(data.getvalue(i,str(m.group(1))))) self.appendElement(items.getkey(num=j),yitem,row) rows.appendChild(row) self.__root.appendChild(rows) def getPageList(self,data,items,args=None): self.appendAttribute('type', 'pagelist') rowsCount=data.getvalue(key='rowsCount') rowsData=data.getvalue(key="rows") args.put('count',str(rowsCount)) self.initArgs(args); rows=self.appendElement('list') for i in range(0,rowsData.size()): row=self.appendElement('item') for j in range(0,items.size()): yitem=str(items.getvalue(num=j)) p = re.compile(r'\[(\w+)\]') for m in p.finditer(yitem): yitem=yitem.replace(str(m.group()),str(rowsData.getvalue(i,str(m.group(1))))) self.appendElement(items.getkey(num=j),yitem,row) rows.appendChild(row) self.__root.appendChild(rows) def getResult(self,args): self.initArgs(args); def getInfo(self,data,items,args=None): self.appendAttribute('type', 'info') args.put('count',str(data.size())) self.initArgs(args); rows=self.appendElement('list') for i in range(0,data.size()): content=""; for j in range(0,items.size()): content+="【"+items.getvalue(num=j)+"】"+data.getvalue(i,items.getkey(j)); if j is not items.size()-1: content+="\n"; self.appendElement("item", content, rows) self.__root.appendChild(rows) def init(self): impl = xml.dom.minidom.getDOMImplementation() self.__dom=impl.createDocument(None, "doc", None) self.__root=self.__dom.documentElement def initArgs(self,args): self.__args=args; if self.__args is None: self.__args=BinMap() self.__args.put('code', '1'); self.__args.put('message', '数据下载成功'); else: if not self.__args.isexists('code'): self.__args.put('code', '1'); if not self.__args.isexists('message'): self.__args.put('message', '数据下载成功'); if not self.__args.isexists('count'): self.__args.put('count', '0'); for i in range(0,self.__args.size()): self.appendElement(self.__args.getkey(i), self.__args.getvalue(num=i)) def appendElement(self,item,text=None,parent=None): element=self.__dom.createElement(item); if text is not None: text=self.__dom.createTextNode(text); element.appendChild(text); if parent is None: self.__root.appendChild(element); else: parent.appendChild(element); return element; def appendAttribute(self,key,value,element=None): if element is not None: element.setAttribute(key, value) else: self.__root.setAttribute(key, value) def reponse(self): return self.__dom.toxml('utf-8');
def getList(self,data,items,args=None): rs=BinMap() rs.put('code', '1') rs.put('message', '数据正常') rs.put('count', data.size()) rs.put('type','list') rows=[] for i in range(0,data.size()): row=BinMap() for j in range(0,items.size()): yitem=str(items.getvalue(num=j)) p = re.compile(r'\[(\w+)\]') for m in p.finditer(yitem): yitem=yitem.replace(str(m.group()),str(data.getvalue(i,str(m.group(1))))) row.put(items.getkey(num=j), yitem) rows.append(row.getitem()) rs.put('data', rows) return rs