Example #1
0
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=LHBMap()
    queryobject.clear()
    for i in range(len(out)):
        queryobject.put(out[i][0], out[i][1])
    return queryobject
Example #2
0
import cx_Oracle
from awspy.database import DbModel, Db


class DbOracle(Db):
    '''
    classdocs
    '''


    def __init__(self,connstr=None,host=None,user=None,passwd=None,db=None):
        Db.__init__(self,connstr,host,user,passwd,db)
        
    def getCursor(self):
        self.conn=cx_Oracle.connect(self.connstr)
        self.cursor = self.conn.cursor()    

if __name__=="__main__":
    db=DbOracle("jjoa/[email protected]:1521/ORCL1")
    model= DbModel(db,"t_count")
    f=LHBMap();
    f.put("countname as tt","newid1")
    f.put("countcontent.string","2")
#    print model.getInsertResult(f)
#    print model.getUpdateResult(f, "countname='newid1'")
    rs=model.getSelectResult(f)
    print rs.getitem()
#
#    print model.getDeleteResult("countname='newid1'")
#    print model.getSelectResult(f)
        
Example #3
0
def http_parse_query(meg):
    http=LHBMap();
    regex = re.compile("(GET|POST)\s+(.+?)\s+(.+?)\r\n", re.IGNORECASE)
    out=regex.findall(meg)
    if len(out)>0:
        http.setvalue("HTTP_METHOD", out[0][0])
        http.setvalue("HTTP_QUERY_STRING", out[0][1])
        http.setvalue("HTTP_PROTOCOL", out[0][2])
    else:
        http.setvalue("HTTP_METHOD", "")
        http.setvalue("HTTP_QUERY_STRING", "")
        http.setvalue("HTTP_PROTOCOL", "")
    http_parse_query_item(meg,"Accept:\s+(.+?)\r\n",http,"HTTP_ACCEPT")
    http_parse_query_item(meg,"Accept-Language:\s+(.+?)\r\n",http,"HTTP_ACCEPT_LANGUAGE")
    http_parse_query_item(meg,"User-Agent:\s+(.+?)\r\n",http,"HTTP_USER_AGENT")
    http_parse_query_item(meg,"Content-Type:\s+(.+?)\r\n",http,"HTTP_CONTENT_TYPE")
    http_parse_query_item(meg,"Accept-Encoding:\s+(.+?)\r\n",http,"HTTP_ACCEPT_ENCODING")
    http_parse_query_item(meg,"Host:\s+(.+?)\r\n",http,"HTTP_HOST")
    http_parse_query_item(meg,"Connection:\s+(.+?)\r\n",http,"HTTP_CONNECTION")
    http_parse_query_item(meg,"Content-Length:\s+(.+?)\r\n",http,"HTTP_CONNECTION_LENGTH")
    http_parse_query_item(meg,"Cache-Control:\s+(.+?)\r\n",http,"HTTP_CACHE_CONTROL")
    regex = re.compile("\r\n\r\n(.+)", re.IGNORECASE)
    out=regex.findall(meg)
    if len(out)>0:
        http.setvalue("HTTP_POST_VARS", out[0])
    else:
        http.setvalue("HTTP_POST_VARS", "")
    return http