• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python util.parse_qsl函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中mod_python.util.parse_qsl函数的典型用法代码示例。如果您正苦于以下问题:Python parse_qsl函数的具体用法?Python parse_qsl怎么用?Python parse_qsl使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了parse_qsl函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: __init__

    def __init__(self, apreq):

        self.apreq = apreq

        if OSRF_HTTP_HEADER_XID in apreq.headers_in:
            osrf.log.log_debug('read XID from client %s' % apreq.headers_in.get(OSRF_HTTP_HEADER_XID))
            osrf.log.set_xid(apreq.headers_in.get(OSRF_HTTP_HEADER_XID))
            self.local_xid = False
        else:
            osrf.log.make_xid()
            osrf.log.log_debug('created new XID %s' % osrf.log.get_xid())
            self.local_xid = True

        if apreq.header_only: 
            return

        for k,v in apreq.headers_in.iteritems():
            osrf.log.log_internal('HEADER: %s = %s' % (k, v))

        try:
            #post = util.parse_qsl(apreq.read(int(apreq.headers_in['Content-length'])))
            post = util.parse_qsl(apreq.read())
            osrf.log.log_debug('post = ' + str(post))
            self.body = [d for d in post if d[0] == 'osrf-msg'][0][1]
            osrf.log.log_debug(self.body)
        except Exception, e: 
            osrf.log.log_warn("error parsing osrf message: %s" % unicode(e))
            self.body = None
            return
开发者ID:StephenGWills,项目名称:OpenSRF,代码行数:29,代码来源:http_translator.py


示例2: track_page_view

def track_page_view(environ):
    time_tup = time.localtime(time.time() + COOKIE_USER_PERSISTENCE)
    
    environ['COOKIES'] = parse_cookie(environ.get('HTTP_COOKIE', ''))
    environ['GET'] = {}
    for key, value in parse_qsl(environ.get('QUERY_STRING', ''), True):
        environ['GET'][key] = value 
    x_utmac = environ['GET'].get('x_utmac', None)
    
    domain = environ.get('HTTP_HOST', '')
    document_referer = environ['GET'].get("utmr", "")
    if not document_referer or document_referer == "0":
        document_referer = "-"
    else:
        document_referer = unquote(document_referer)

    document_path = environ['GET'].get('utmp', "")
    if document_path:
        document_path = unquote(document_path)

    account = environ['GET'].get('utmac', '')      
    user_agent = environ.get("HTTP_USER_AGENT", '')    

    cookie = environ['COOKIES'].get(COOKIE_NAME)

    visitor_id = get_visitor_id(environ.get("HTTP_X_DCMGUID", ''), account, user_agent, cookie)
    
    cookie = SimpleCookie()
    cookie[COOKIE_NAME] = visitor_id
    morsel = cookie[COOKIE_NAME]
    morsel['expires'] = time.strftime('%a, %d-%b-%Y %H:%M:%S %Z', time_tup) 
    morsel['path'] = COOKIE_PATH

    utm_gif_location = "http://www.google-analytics.com/__utm.gif"

    for utmac in [account, x_utmac]:
        if not utmac:
            continue
        utm_url = utm_gif_location + "?" + \
                "utmwv=" + VERSION + \
                "&utmn=" + get_random_number() + \
                "&utmhn=" + quote(domain) + \
                "&utmr=" + quote(document_referer) + \
                "&utmp=" + quote(document_path) + \
                "&utmac=" + utmac + \
                "&utmcc=__utma" + "%3D" + gen_utma() + "%3B"
                #"&utmvid=" + visitor_id + \
                #"&utmip=" + get_ip(environ.get("REMOTE_ADDR",''))
        send_request_to_google_analytics(utm_url, environ)

    headers = [('Set-Cookie', str(cookie).split(': ')[1])]
    if environ['GET'].get('utmdebug', False):
        headers.append(('X-GA-MOBILE-URL', utm_url))
    
    response = write_gif_data()
    response_headers = response['response_headers']
    response_headers.extend(headers)
    return response
开发者ID:GuoJing,项目名称:Google-Analytics-Mobile-Python,代码行数:58,代码来源:ga.py


示例3: __init__

 def __init__(self, query_string, mutable=False, encoding=None):
     MultiValueDict.__init__(self)
     if not encoding:
         encoding = settings.DEFAULT_CHARSET
     self.encoding = encoding
     for key, value in parse_qsl((query_string or ''), True): # keep_blank_values=True
         self.appendlist(force_unicode(key, encoding, errors='replace'),
                         force_unicode(value, encoding, errors='replace'))
     self._mutable = mutable
开发者ID:farstarinc,项目名称:django,代码行数:9,代码来源:__init__.py


示例4: __init__

 def __init__(self, query_string, mutable=False, encoding=None):
     MultiValueDict.__init__(self)
     if not encoding:
         # *Important*: do not import settings any earlier because of note
         # in core.handlers.modpython.
         from django.conf import settings
         encoding = settings.DEFAULT_CHARSET
     self.encoding = encoding
     for key, value in parse_qsl((query_string or ''), True): # keep_blank_values=True
         self.appendlist(force_unicode(key, encoding, errors='replace'),
                         force_unicode(value, encoding, errors='replace'))
     self._mutable = mutable
开发者ID:9gix,项目名称:RC-Tech,代码行数:12,代码来源:__init__.py


示例5: get_post

    def get_post(self):
        if not hasattr(self, "_post"):
            try:
                content_length = int(self.environ.get("CONTENT_LENGTH", 0))
            except (ValueError, TypeError):
                content_length = 0

            if content_length > 0:
                body = self.environ["wsgi.input"].read(int(self.environ.get("CONTENT_LENGTH", 0)))
                self._post = dict((k, v) for k, v in parse_qsl(body, True))
            else:
                self._post = {}
        return self._post
开发者ID:Derecho,项目名称:rivr,代码行数:13,代码来源:wsgi.py


示例6: get_openid_return_url

def get_openid_return_url(request,
        return_view_name='openid_auth-complete_openid_login',
        redirect_field_name=REDIRECT_FIELD_NAME,
        redirect=None):
    """
    Get the URL to tell the openid server to redirect back to and, if
    available, append the redirect query parameter.
    """
    url = urlparse.urljoin(get_openid_return_host(request),
                           get_openid_return_path(return_view_name))
    (scheme, location, path, query, fragment) = urlparse.urlsplit(url)
    #If a 'redirect' attribute is provided, append that to the openid_return_url
    if redirect and is_valid_redirect_url(redirect):
        query_kv = parse_qsl(query)
        query_kv.append((redirect_field_name, redirect))
        query = urllib.urlencode(query_kv)
    return iri_to_uri(urlparse.urlunsplit((scheme, location, path, query, fragment)))
开发者ID:ejconlon,项目名称:Wecolage_Django,代码行数:17,代码来源:auth_controller.py


示例7: grab

def grab(req):
    req.content_type = 'text/html'
    out=""
    pairs = dict(util.parse_qsl(req.args))
    if pairs.has_key("refresh"):
        out+="<p style='background-color: #DDFFEE'>Refresh</p>"
    if pairs.has_key("str"):
        poss= difflib.get_close_matches(pairs["str"],rules, cutoff=0.3)
        out+="<dl>\n"
        for i in poss:
            out+= "<dt>%s</dt><dd>%s</dd>\n"%(i,r[i])
        out+="</dl>\n"
        return out

        
    else:
        return "NO"
开发者ID:digehode,项目名称:easyList,代码行数:17,代码来源:index.py


示例8: __init__

 def __init__(self, query_string):
     try:
         from mod_python.util import parse_qsl
     except ImportError:
         from cgi import parse_qsl
     if not query_string:
         self.data = {}
         self._keys = []
     else:
         self.data = {}
         self._keys = []
         for name, value in parse_qsl(query_string, True): # keep_blank_values=True
             if name in self.data:
                 self.data[name].append(value)
             else:
                 self.data[name] = [value]
             if name not in self._keys:
                 self._keys.append(name)
     self._mutable = False
开发者ID:BackupTheBerlios,项目名称:gappy-svn,代码行数:19,代码来源:httpwrappers.py


示例9: parse_backend_uri

def parse_backend_uri(backend_uri):
    """
    Converts the "backend_uri" into a cache scheme ('db', 'memcached', etc), a
    host and any extra params that are required for the backend. Returns a
    (scheme, host, params) tuple.
    """
    if backend_uri.find(':') == -1:
        raise InvalidCacheBackendError("Backend URI must start with scheme://")
    scheme, rest = backend_uri.split(':', 1)
    if not rest.startswith('//'):
        raise InvalidCacheBackendError("Backend URI must start with scheme://")

    host = rest[2:]
    qpos = rest.find('?')
    if qpos != -1:
        params = dict(parse_qsl(rest[qpos+1:]))
        host = rest[2:qpos]
    else:
        params = {}
    if host.endswith('/'):
        host = host[:-1]

    return scheme, host, params
开发者ID:LittleForker,项目名称:django,代码行数:23,代码来源:__init__.py


示例10: __init__

 def __init__(self, query_string, mutable=False):
     MultiValueDict.__init__(self)
     self._mutable = True
     for key, value in parse_qsl((query_string or ''), True): # keep_blank_values=True
         self.appendlist(key, value)
     self._mutable = mutable
开发者ID:0xmilk,项目名称:appscale,代码行数:6,代码来源:__init__.py


示例11: track_page_view

def track_page_view(environ):
    """
    // Track a page view, updates all the cookies and campaign tracker,
    // makes a server side request to Google Analytics and writes the transparent
    // gif byte data to the response.
    """    
    time_tup = time.localtime(time.time() + COOKIE_USER_PERSISTENCE)
    
    # set some useful items in environ: 
    environ['COOKIES'] = parse_cookie(environ.get('HTTP_COOKIE', ''))
    environ['GET'] = {}
    for key, value in parse_qsl(environ.get('QUERY_STRING', ''), True):
        environ['GET'][key] = value # we only have one value per key name, right? :) 
    x_utmac = environ['GET'].get('x_utmac', None)
    
    domain = environ.get('HTTP_HOST', '')
            
    # Get the referrer from the utmr parameter, this is the referrer to the
    # page that contains the tracking pixel, not the referrer for tracking
    # pixel.    
    document_referer = environ['GET'].get("utmr", "")
    if not document_referer or document_referer == "0":
        document_referer = "-"
    else:
        document_referer = unquote(document_referer)

    document_path = environ['GET'].get('utmp', "")
    if document_path:
        document_path = unquote(document_path)

    account = environ['GET'].get('utmac', '')      
    user_agent = environ.get("HTTP_USER_AGENT", '')    

    # // Try and get visitor cookie from the request.
    cookie = environ['COOKIES'].get(COOKIE_NAME)

    visitor_id = get_visitor_id(environ.get("HTTP_X_DCMGUID", ''), account, user_agent, cookie)
    
    # // Always try and add the cookie to the response.
    cookie = SimpleCookie()
    cookie[COOKIE_NAME] = visitor_id
    morsel = cookie[COOKIE_NAME]
    morsel['expires'] = time.strftime('%a, %d-%b-%Y %H:%M:%S %Z', time_tup) 
    morsel['path'] = COOKIE_PATH

    utm_gif_location = "http://www.google-analytics.com/__utm.gif"

    for utmac in [account, x_utmac]:
        if not utmac:
            continue # ignore empty utmacs
        # // Construct the gif hit url.
        utm_url = utm_gif_location + "?" + \
                "utmwv=" + VERSION + \
                "&utmn=" + get_random_number() + \
                "&utmhn=" + quote(domain) + \
                "&utmsr=" + environ['GET'].get('utmsr', '') + \
                "&utme=" + environ['GET'].get('utme', '') + \
                "&utmr=" + quote(document_referer) + \
                "&utmp=" + quote(document_path) + \
                "&utmac=" + utmac + \
                "&utmcc=__utma%3D999.999.999.999.999.1%3B" + \
                "&utmvid=" + visitor_id + \
                "&utmip=" + get_ip(environ.get("REMOTE_ADDR",''))
        # dbgMsg("utm_url: " + utm_url)    
        send_request_to_google_analytics(utm_url, environ)

    # // If the debug parameter is on, add a header to the response that contains
    # // the url that was used to contact Google Analytics.
    headers = [('Set-Cookie', str(cookie).split(': ')[1])]
    if environ['GET'].get('utmdebug', False):
        headers.append(('X-GA-MOBILE-URL', utm_url))
    
    # Finally write the gif data to the response
    response = write_gif_data()
    response_headers = response['response_headers']
    response_headers.extend(headers)
    return response
开发者ID:MiCHiLU,项目名称:Google-Analytics-for-Mobile--Google-App-Engine,代码行数:77,代码来源:ga.py


示例12: get_get

 def get_get(self):
     if not hasattr(self, "_get"):
         self._get = dict((k, v) for k, v in parse_qsl(self.environ.get("QUERY_STRING", ""), True))
     return self._get
开发者ID:Derecho,项目名称:rivr,代码行数:4,代码来源:wsgi.py



注:本文中的mod_python.util.parse_qsl函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python util.redirect函数代码示例发布时间:2022-05-27
下一篇:
Python apache.log_error函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap