当前位置: 首页>>代码示例>>Python>>正文


Python web.urlquote函数代码示例

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


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

示例1: POST

    def POST(self):
        inp = web.input(close_after=False, item_host=None, item_path=None, item_name=None, content=None, item_user=None)

        model.new_comment(session.user.name, inp.item_host, inp.item_path, inp.item_name, inp.content, inp.item_user)

        page_owner = model.get_user(name=inp.item_user)
        if page_owner.mailmode == "all":
            web.sendmail(
                'Comment on This! <[email protected]>',
                page_owner.email,
                '[CoT] New comment on '+get_domain(inp.item_host),
                session.user.name+" posted a comment on "+inp.item_host+inp.item_path+"#"+inp.item_name+":"+
                "\n\n"+inp.content+
                "\n\n    -- The Comment on This Team"
            )

        if inp.close_after:
            return render.comment_thanks()
        else:
            raise web.seeother(
                "/comment"+
                "?item_host="+web.urlquote(inp.item_host)+
                "&item_path="+web.urlquote(inp.item_path)+
                "&item_name="+web.urlquote(inp.item_name)
            )
开发者ID:shish,项目名称:commentonthis,代码行数:25,代码来源:cot.py

示例2: uuap_sso

def uuap_sso():
    sso_username = web.config.session.get('sso_username')
    #如果有已经登陆则返回用户名,否则跳转到uuap登录页
    if sso_username:
        logging.debug('sso_username: %s' % sso_username)
        return sso_username
    service_url = '%s/zmon/auth?u=%s' % (web.ctx.homedomain, web.urlquote(web.ctx.homepath + web.ctx.fullpath))
    raise web.seeother('%s/login?service=%s' % (SSO_URL, web.urlquote(service_url)))
开发者ID:actank,项目名称:zmon,代码行数:8,代码来源:auth.py

示例3: GET

 def GET(self):
     user_data = web.input(u=None, ticket=None)
     if not user_data.u or not user_data.ticket:
         return render.forbidden(userName)
     service_url = '%s/sso?u=%s' % (web.ctx.homedomain, web.urlquote(user_data.u))
     validate_url = '%s/validate?service=%s&ticket=%s' % (SSO_URL, web.urlquote(service_url), web.urlquote(user_data.ticket))
     r = urllib.urlopen(validate_url).readlines()
     if len(r) == 2 and r[0].strip() == 'yes':
         web.config.session.sso_username = r[1].strip()
         raise web.seeother(user_data.u)
     else:
         return render.forbidden(userName)
开发者ID:actank,项目名称:zmon,代码行数:12,代码来源:sso.py

示例4: POST

    def POST(self):
        i = web.input(_unicode=False, mail=[])

        self.mails = i.get('mail', [])
        self.action = i.get('action', None)
        msg = i.get('msg', None)

        adminLib = adminlib.Admin()

        if self.action == 'delete':
            result = adminLib.delete(mails=self.mails,)
            msg = 'DELETED'
        elif self.action == 'disable':
            result = adminLib.enableOrDisableAccount(accounts=self.mails, active=False,)
            msg = 'DISABLED'
        elif self.action == 'enable':
            result = adminLib.enableOrDisableAccount(accounts=self.mails, active=True,)
            msg = 'ENABLED'
        else:
            result = (False, 'INVALID_ACTION')

        if result[0] is True:
            raise web.seeother('/admins?msg=%s' % msg)
        else:
            raise web.seeother('/admins?msg=?' + web.urlquote(result[1]))
开发者ID:CBEPX,项目名称:iredadmin,代码行数:25,代码来源:admin.py

示例5: POST

    def POST(self, domain):
        i = web.input(_unicode=False, mail=[])
        self.domain = web.safestr(domain)
        self.mails = i.get('mail', [])
        self.action = i.get('action', None)

        userLib = user.User()

        if self.action == 'delete':
            result = userLib.delete(domain=self.domain, mails=self.mails,)
            msg = 'DELETED'
        elif self.action == 'disable':
            result = userLib.enableOrDisableAccount(domain=self.domain, mails=self.mails, action='disable',)
            msg = 'DISABLED'
        elif self.action == 'enable':
            result = userLib.enableOrDisableAccount(domain=self.domain, mails=self.mails, action='enable',)
            msg = 'ENABLED'
        else:
            result = (False, 'INVALID_ACTION')
            msg = i.get('msg', None)

        if result[0] is True:
            cur_page = i.get('cur_page', '1')
            raise web.seeother('/users/%s/page/%s?msg=%s' % (self.domain, str(cur_page), msg, ))
        else:
            raise web.seeother('/users/%s?msg=%s' % (self.domain, web.urlquote(result[1])))
开发者ID:CBEPX,项目名称:iredadmin,代码行数:26,代码来源:user.py

示例6: GET

    def GET(self, profile_type, domain):
        i = web.input()
        self.domain = web.safestr(domain.split('/', 1)[0])
        self.profile_type = web.safestr(profile_type)

        if not iredutils.is_domain(self.domain):
            raise web.seeother('/domains?msg=EMPTY_DOMAIN')

        domainLib = domainlib.Domain()
        result = domainLib.profile(domain=self.domain)

        if result[0] is False:
            raise web.seeother('/domains?msg=' + web.urlquote(result[1]))

        r = domainLib.listAccounts(attrs=['domainName'])
        if r[0] is True:
            allDomains = r[1]
        else:
            return r

        allAccountSettings = ldaputils.getAccountSettingFromLdapQueryResult(result[1], key='domainName',)

        return web.render(
            'ldap/domain/profile.html',
            cur_domain=self.domain,
            allDomains=allDomains,
            allAccountSettings=allAccountSettings,
            profile=result[1],
            profile_type=self.profile_type,
            msg=i.get('msg', None),
        )
开发者ID:CBEPX,项目名称:iredadmin,代码行数:31,代码来源:domain.py

示例7: login_hook

def login_hook(handler):
    path_info = web.ctx.env['PATH_INFO']
    if path_info != '/login' and not session.login:
        uri = web.ctx.env['REQUEST_URI']
        web.seeother('/login?return_url=' + web.urlquote(uri))
    else:
        return handler()
开发者ID:felix021,项目名称:expense,代码行数:7,代码来源:main.py

示例8: get_results

    def get_results(self, q, offset=0, limit=100):
        if config.get('single_core_solr'):            
            valid_fields = ['key', 'name', 'subject_type', 'work_count']
        else:
            valid_fields = ['key', 'name', 'type', 'count']

        q = escape_colon(escape_bracket(q), valid_fields)
        params = {
            "q.op": "AND",
            "q": web.urlquote(q),
            "start": offset,
            "rows": limit,
            "fl": ",".join(valid_fields),
            "qt": "standard",
            "wt": "json"
        }
        if config.get('single_core_solr'):
            params['fq'] = 'type:subject'
            params['sort'] = 'work_count desc'
        else:                
            params['sort'] = 'count desc'

        solr_select = solr_subject_select_url + "?" + urllib.urlencode(params)
        results = run_solr_search(solr_select)
        response = results['response']

        if config.get('single_core_solr'):
            response['docs'] = [self.process_doc(doc) for doc in response['docs']]

        return results
开发者ID:RaceList,项目名称:openlibrary,代码行数:30,代码来源:code.py

示例9: get_results

 def get_results(q, offset=0, limit=100, snippets=3, fragsize=200, hl_phrase=False):
     m = re_bad_fields.match(q)
     if m:
         return { 'error': m.group(1) + ' search not supported' }
     q = escape_q(q)
     solr_params = [
         ('fl', 'ia,body_length,page_count'),
         ('hl', 'true'),
         ('hl.fl', 'body'),
         ('hl.snippets', snippets),
         ('hl.mergeContiguous', 'true'),
         ('hl.usePhraseHighlighter', 'true' if hl_phrase else 'false'),
         ('hl.simple.pre', '{{{'),
         ('hl.simple.post', '}}}'),
         ('hl.fragsize', fragsize),
         ('q.op', 'AND'),
         ('q', web.urlquote(q)),
         ('start', offset),
         ('rows', limit),
         ('qf', 'body'),
         ('qt', 'standard'),
         ('hl.maxAnalyzedChars', '-1'),
         ('wt', 'json'),
     ]
     solr_select = solr_select_url + '?' + '&'.join("%s=%s" % (k, unicode(v)) for k, v in solr_params)
     stats.begin("solr", url=solr_select)
     json_data = urllib.urlopen(solr_select).read()
     stats.end()
     try:
         return simplejson.loads(json_data)
     except:
         m = re_query_parser_error.search(json_data)
         return { 'error': web.htmlunquote(m.group(1)) }
开发者ID:amoghravish,项目名称:openlibrary,代码行数:33,代码来源:code.py

示例10: GET

    def GET(self, domain, cur_page=1):
        self.domain = web.safestr(domain).split('/', 1)[0]
        cur_page = int(cur_page)

        if not iredutils.is_domain(self.domain):
            raise web.seeother('/domains?msg=INVALID_DOMAIN_NAME')

        if cur_page == 0:
            cur_page = 1

        userLib = userlib.User()
        result = userLib.listAccounts(domain=self.domain, cur_page=cur_page,)
        if result[0] is True:
            (total, records) = (result[1], result[2])

            return web.render(
                'pgsql/user/list.html',
                cur_domain=self.domain,
                cur_page=cur_page,
                total=total,
                users=records,
                msg=web.input().get('msg', None),
            )
        else:
            raise web.seeother('/domains?msg=%s' % web.urlquote(result[1]))
开发者ID:CBEPX,项目名称:iredadmin,代码行数:25,代码来源:user.py

示例11: POST

    def POST(self):
        i = web.input(domainName=[], _unicode=False,)

        self.domainName = i.get('domainName', [])
        self.action = i.get('action', None)

        domainLib = domainlib.Domain()

        if self.action == 'delete':
            result = domainLib.delete(domains=self.domainName)
            msg = 'DELETED'
        elif self.action == 'disable':
            result = domainLib.enableOrDisableAccount(domains=self.domainName, action='disable',)
            msg = 'DISABLED'
        elif self.action == 'enable':
            result = domainLib.enableOrDisableAccount(domains=self.domainName, action='enable',)
            msg = 'ENABLED'
        else:
            result = (False, 'INVALID_ACTION')
            msg = i.get('msg', None)

        if result[0] is True:
            raise web.seeother('/domains?msg=%s' % msg)
        else:
            raise web.seeother('/domains?msg=' + web.urlquote(result[1]))
开发者ID:CBEPX,项目名称:iredadmin,代码行数:25,代码来源:domain.py

示例12: render

	def render(self,renderObject):
		if 'frameview' == self.m_renderType or 'view' == self.m_renderType:
			if not self.view():
				self.buildView()
			
			# 在 json 请求中不需要此参数
			self.setVariable('urlPath',self.m_urlPath)
			self.setVariable('url',web.ctx.fullpath)
			self.setVariable('urlquote',web.urlquote( web.ctx.fullpath ) )
			
			if 'frameview' == self.m_renderType:
				return self.view().rootView().render(
					renderObject,
					self.m_variableDict
				)
			else:
				return self.view().render(
					renderObject,
					self.m_variableDict
				)
		elif 'json' == self.m_renderType:
			if self.__status == 'ok':
				self.setVariable('result',True)
			else:
				self.setVariable('result',False)
			return json.dumps(self.m_variableDict)
		else:
			return self.m_renderType
开发者ID:chu888chu888,项目名称:Python-web.py-learn-webpy,代码行数:28,代码来源:Controller.py

示例13: simple_search

def simple_search(q, offset=0, rows=20, sort=None):
    solr_select = solr_select_url + "?version=2.2&q.op=AND&q=%s&fq=&start=%d&rows=%d&fl=*%%2Cscore&qt=standard&wt=json" % (web.urlquote(q), offset, rows)
    if sort:
        solr_select += "&sort=" + web.urlquote(sort)

    stats.begin("solr", url=solr_select)
    json_data = urllib.urlopen(solr_select)
    stats.end()
    return json.load(json_data)
开发者ID:bfalling,项目名称:openlibrary,代码行数:9,代码来源:code.py

示例14: GET

	def GET(self):
		login_error = '登录失败,可能是服务器与新浪oauth服务交互出现问题,请稍候重试,<a href="/">返回</a>'

		i = web.input()
		if i.get('act') == 'auth':
			try:
				token, secret = login_auth.get_weibo_token()
			except:
				web.header('Content-Type', 'text/html; charset=utf-8')
				traceback.print_exc()
				return login_error
			session.token = token
			session.secret = secret
			if web.ctx.env['SERVER_PORT'] == '9527':
				oauth_callback = web.urlquote('http://localhost:9527/login?act=callback')
			else:
				oauth_callback = web.urlquote('http://gaoding.me/login?act=callback')

			raise web.seeother('http://api.t.sina.com.cn/oauth/authorize?oauth_token=%(token)s&oauth_callback=%(oauth_callback)s' % locals())
		elif i.get('act') == 'callback':
			'''
			http://localhost:8080/login?act=callback&oauth_token=e43e721b87c0b1c5fc9ad0746fcd1c0f&oauth_verifier=186264
			'''
			token = i.get('oauth_token')
			secret = session.get('secret')
			oauth_verifier = i.get('oauth_verifier')
			
			try:
				token, secret, user_id = login_auth.get_weibo_access_token(token, secret, oauth_verifier)
				user_info = login_auth.get_weibo_info(token, secret)
			except:
				traceback.print_exc()
				web.header('Content-Type', 'text/html; charset=utf-8')
				return login_error

			user_info = simplejson.loads(user_info)
			
			user = User()
			user.login('weibo', user_info)

			raise web.seeother('/')

		return 'Access denied'
开发者ID:notsobad,项目名称:gaoding.me,代码行数:43,代码来源:ui.py

示例15: process

	def process(self):
		i = web.input()
		
		if 'redirect' in i:
			redirect = i['redirect']
		else:
			redirect = '/'
		
		self.setVariable('redirect',redirect)
		self.setVariable('redirect_quote',web.urlquote( redirect ) )
开发者ID:chu888chu888,项目名称:Python-web.py-learn-webpy,代码行数:10,代码来源:Login.py


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