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

Python web.url函数代码示例

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

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



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

示例1: request

    def request(self):
        return_to = self.query.get('return_to', web.ctx.homedomain + web.url('/account'))

        data = filter(lambda item: item[0] not in ['password'], self.query.items())

        form = WebOpenIDLoginForm(password_manager)()

        session['no_password'] = False

        if self.method == 'POST':
            try:
                if form.validates(self.query):
                    session.login()
                    data.append(('logged_in', True))
                    return web.found(return_to + '?' + web.http.urlencode(dict(data)))

            except PasswordManager.NoPassword:
                session['no_password'] = True
                session.login()
                data.append(('logged_in', True))
                return web.found(return_to + '?' + web.http.urlencode(dict(data)))

        web.header('Content-type', 'text/html')
        return render.login(
                logged_in=session.logged_in,
                login_url=web.ctx.homedomain + web.url('/account/login'),
                logout_url=web.ctx.homedomain + web.url('/account/logout'),
                change_password_url=web.ctx.homedomain + web.url('/account/change_password'),
                no_password=session.get('no_password', False),
                form=form,
                query=data,
            )
开发者ID:imankulov,项目名称:ownopenidserver,代码行数:32,代码来源:openidserver.py


示例2: POST

 def POST(self):
     form = web.input(
         poster=utils.get_default_name(),
         title='',
         syntax='text',
         body='',
         do_preview=None,
     )
     is_valid, error = utils.check_captcha(web.ctx['ip'], form)
     if not is_valid or form.do_preview is not None:
         return render.post(
             user=form.poster,
             title=form.title,
             syntax=form.syntax,
             body=form.body,
             captcha_error=error,
             preview=form.do_preview is not None,
         )
     utils.save_poster(form.poster)
     if form.body.strip() == '':
         return web.seeother(web.url('/'))
     paste_id = db.add_paste(
         form.poster,
         form.title.strip(),
         [(form.body, form.syntax)],
     )
     return web.seeother(web.url('/%d' % (paste_id,)))
开发者ID:kgaughan,项目名称:pastetron,代码行数:27,代码来源:views.py


示例3: apicall

    def apicall(self,type1):
        web.header('Content-Type','text/html; charset=utf-8', unique=True)

        access_token = {}
            
        f1 = open(settings.get_home_dir() + 'token.txt','r')
        str1 = f1.read()
        f1.close()
        l1 = str1.split(';')
        if '1' == l1[2].replace(r'ss=',''):
            access_token['oauth_token'] = l1[0].replace(r'ot=','')
            access_token['oauth_token_secret'] = l1[1].replace(r'ots=','')
            
        if web.url().startswith('/api/'):
            url1 = web.url().replace(r'/api/','',1)
        i1 = web.input().copy()


        #for new twitter ,home_timeline
        #home timeline
        pop_earned = not -1 == url1.find('statuses/home_timeline') or\
            not -1 == url1.find('statuses/user_timeline') or\
            not -1 == url1.find('statuses/show')
        if pop_earned:
            if i1.has_key('earned'):
                i1.pop('earned')

        rv = twitUtil.MakeApiCall(access_token,url1,type1,dict(i1))
        if url1.endswith('.json'):
            rv = self.sub_url(rv)
        return rv
开发者ID:wynemo,项目名称:501fun_t_api,代码行数:31,代码来源:ttapi.py


示例4: request

    def request(self):
        # check for login
        if not session.logged_in:
            return WebOpenIDLoginRequired(self.query)

        form = WebOpenIDChangePasswordForm()

        if self.method == 'POST':
            if form.validates(self.query):
                password_manager.set(self.query['password'])

                session['no_password'] = False

                return web.found(
                    homedomain(web.ctx) + web.url('/account'))

        web.header('Content-type', 'text/html')
        return render.password(
            home_url=homedomain(web.ctx) + web.url('/'),
            logged_in=session.logged_in,
            logout_url=homedomain(web.ctx) + web.url('/account/logout'),
            change_password_url=homedomain(web.ctx) + web.url(
                '/account/change_password'),
            no_password=session.get('no_password', False),
            form=form,
        )
开发者ID:yottatsa,项目名称:ownopenidserver,代码行数:26,代码来源:openidserver.py


示例5: request

 def request(self):
     web.header('Content-type', 'text/html')
     return render.base(
             logged_in=True, #session.logged_in,
             #login_url=web.ctx.homedomain + web.url('/account/login'),
             #logout_url=web.ctx.homedomain + web.url('/account/logout'),
             #change_password_url=web.ctx.homedomain + web.url('/account/change_password'),
             #check_trusted_url=web.ctx.homedomain + web.url('/account/trusted'),
             no_password=session.get('no_password', False),
             endpoint=web.ctx.homedomain + web.url('/endpoint'),
             yadis=web.ctx.homedomain + web.url('/yadis.xrds'),
             homedomain=web.ctx.homedomain,
         )
开发者ID:muelli,项目名称:OpenID-Server,代码行数:13,代码来源:wideopenidserver.py


示例6: GET

    def GET(self, id = None):
        section = web.url().split('/')[1]
        i = web.input(page = 1)

        order = {'algorithm': 'subid DESC',
                 'problem': 'pid', 
                 'contest': 'cid DESC',
                 'accounts': 'uid'
                 }  # FIXME
        group = {'algorithm': 'subid',
                 'problem': 'pid', 
                 'contest': 'cid',
                 'accounts': 'uid'
                 }  # FIXME

        what = 'subid, uid, pid, addr, lang, created, stat, time, mmem'
        where = str((id == None) or ('%s = %s' % (group[section], str(id))))

        page = int(i.page)
        limit = 19  # Perfect size for my beloved X61 Thinkpad screen!
        offset = (page - 1) * limit

        query = db.select('shots', None, 
            what, where, 
            'subid DESC', None, #order[section], group[section], FIXME
            limit, offset)

        return renderer[section].status(query)
开发者ID:mahrud,项目名称:juxif,代码行数:28,代码来源:code.py


示例7: notFound

def notFound(filename):
    web.expires(60)
    web.header('Content-Type', 'text/html')
    s =  """<p>You were looking for "%s".</p>""" % filename
    s += """<p>(on host %s)</p>""" % web.ctx.host
    s += """<p>(that is, URL="%s")</p>""" % web.url()
    s += """<p>alas.</p>"""
    web.notfound()
    return s
开发者ID:sandhawke,项目名称:ldreg,代码行数:9,代码来源:webextras.py


示例8: login_required

def login_required():
	if not users.get_current_user():
		if renderer.get_mode() == 'html':
			# Redirect to a login page, coming back here when done.
			raise web.found(users.create_login_url(web.url()))
		elif renderer.get_mode() == 'json':
			# Return an error in JSON.
			renderer.addData('error', 'Not logged in.')
			return renderer.render('apionly.html')
开发者ID:firehot,项目名称:notifry,代码行数:9,代码来源:index.py


示例9: GET

	def GET(self):
		user = users.get_current_user()

		if user:
			# Is logged in.
			raise web.found('/profile')
		else:
			# Not logged in - redirect to login.
			raise web.found(users.create_login_url(web.url()))
开发者ID:thunderace,项目名称:newtifry,代码行数:9,代码来源:index.py


示例10: link_to

def link_to(obj_type, obj=None, method=None, **kw):
    link = "/a/" + obj_type
    if obj is not None:
        link += "/" + str(obj.get("id"))
    if method:
        link += "/" + method

    # Remove none values from kw
    params = dict((k, v) for k, v in kw.iteritems() if v is not None)
    return web.url(link, **params)
开发者ID:w0rm,项目名称:pre-stonegarden-dev,代码行数:10,代码来源:template.py


示例11: GET

 def GET(self):
     url = web.url()
     if url == '/': url = '/index'
     user = users.get_current_user()
     if user:
         user_url = users.create_logout_url('/')
     else:
         user_url = users.create_login_url('/manage')
     return template.render('templates%s.html' % url, 
       {'user':user,'user_url':user_url})
开发者ID:evanlong,项目名称:publicgit,代码行数:10,代码来源:main.py


示例12: get_nextprev

 def get_nextprev(self, key, rev, offset):
     """Returns next url when offset is 1 and prev url when offset is -1.
     """
     i = web.input(_method="GET")
     where = index().prepare_where(i)
     items = [(row.key, row.revision) for row in db.select('reports', where=where, order="time desc", vars=i)]
     try:
         row_index = items.index((key, int(rev)))
         key, rev = items[row_index+offset]
         return web.url("/diff%[email protected]%s" % (key, rev), **i)
     except IndexError:
         return None
开发者ID:internetarchive,项目名称:IAWatchBot,代码行数:12,代码来源:vandalismcenter.py


示例13: GET

	def GET(self, name=None):
		name = web.url()
		lname = name.split("/")
		web.header('Content-Type', 'application/json')
		if lname[1] in specific_filters:
			dao = DAO.DAO()
			if len(lname) > 2:
				pass
			else:
				status, finaltags, msg = dao.getTagsByCategory(lname[1])
				return json.dumps({"%ss" % lname[1]: finaltags})
		return json.dumps(lname)
开发者ID:MTG,项目名称:cmbrowser-orig,代码行数:12,代码来源:API.py


示例14: GET

 def GET(self, page_num=None):
     mime_type = utils.get_preferred_mimetype(
         ('text/html', 'application/atom+xml'),
         'text/html')
     if mime_type == 'text/html':
         if page_num is None:
             return web.seeother(web.url('/pastes/1'))
         return self.recent(int(page_num))
     if mime_type == 'application/atom+xml':
         return self.feed()
     # Should never be called.
     return web.notacceptable()
开发者ID:kgaughan,项目名称:pastetron,代码行数:12,代码来源:views.py


示例15: GET

 def GET(self):
     name = web.input(term = 'super mario')
     result_list = []
     set_name = name['term'].lower()+':star'
     results = r.zrevrange(set_name,0,10)
     if ALLOW_THIRD_PARTY_ACCESS:
         web.header('Access-Control-Allow-Origin','*')        
     if 'term' in web.input():
         key = 'sug:'+web.url()+'?term='+web.input()['term']
         key = key.replace(' ','+')
         cache.set(key, json.dumps(results), CACHE_DURATION)
     return json.dumps(results)
开发者ID:yonglehou,项目名称:suggestit,代码行数:12,代码来源:suggest.py


示例16: request

 def request(self):
     web.header('Content-type', 'text/html')
     return render.base(
             home_url=_secure_homedomain(web.ctx) + web.url('/'),
             logged_in=session.logged_in,
             login_url=_secure_homedomain(web.ctx) + web.url('/account/login'),
             logout_url=_secure_homedomain(web.ctx) + web.url('/account/logout'),
             change_password_url=_secure_homedomain(web.ctx) + web.url('/account/change_password'),
             check_trusted_url=_secure_homedomain(web.ctx) + web.url('/account/trusted'),
             no_password=session.get('no_password', False),
             endpoint=_secure_homedomain(web.ctx) + web.url('/endpoint'),
             yadis=_secure_homedomain(web.ctx) + web.url('/yadis.xrds'),
         )
开发者ID:thedod,项目名称:ownopenidserver,代码行数:13,代码来源:openidserver.py


示例17: render

	def render(self, template_name):
		# Determine the mode from the parameters.
		if self.get_mode() == 'html':
			self.addTemplate('uri', web.url())
			template = self.template_lookup.get_template(template_name)
			return template.render(**self.data)
		elif self.get_mode() == 'json':
			# Filter the data. Only data/data-list go out.
			outputdata = {}
			web.header('Content-Type', 'application/json')
			for key, value in self.data.iteritems():
				if self.types[key] == 'data' or self.types[key] == 'data-list':
					outputdata[key] = self.prepareToJson(value)
			return json.dumps(outputdata)
		else:
			# Not a supported mode.
			return None
开发者ID:badrul,项目名称:newtifry,代码行数:17,代码来源:Renderer.py


示例18: _setup_xmlinfo

	def _setup_xmlinfo(self):
		root = etree.Element('request')
		n = etree.SubElement(root, 'querytime')
		n.text = datetime.today().strftime("%Y-%m-%d %H:%M:%S%z")
		n = etree.SubElement(root, 'queryvalue')
		n.text = web.url()
		n = etree.SubElement(root, 'cachekey')
		n.text = self.cachekey;
		n = etree.SubElement(root, 'backendtime')
		n.text = '%.2f' % self._backendtime
		n = etree.SubElement(root, 'time')
		n.text = self._time.strftime("%Y-%m-%d %H:%M")
		conc = lambda x: x['type']+ ':' + x['value']
		n = etree.SubElement(root, 'from')
		n.text = conc(self._query)
		n = etree.SubElement(root, 'filters')
		n.text = str(self._filters)
		self.xmlinfo = etree.tostring(root, method='xml', encoding='UTF-8')
开发者ID:marcammann,项目名称:zvvapi,代码行数:18,代码来源:station.py


示例19: POST

    def POST(self):
        section = web.url().split('/')[1]
        i = web.input(
            identity = None, 
            passwd = None
            )

        identity = i.identity
        passwd = i.passwd

        what = 'uid, email, username, password'
        where = "(email='%s' OR username='%s')" % (identity, identity)

        query = db.select('users', None, what, where)

        if len(list(query)) == 0:
            return renderer.login(1) # username / email not found

        row = query[0]

        hash = SHA256.new()
        hash.update(secret.salt)
        hash.update(row.email)
        hash.update(passwd)
        shadow = hash.digest()

        # TODO: implement HTTP Digest Authentication :-fsck yeah!
        # https://github.com/mahrud/webpy_http-digest-auth
        if shadow.encode('hex') == row.password:
            session.auth = True
            session.time = time.time()
            session.uid  = row.uid
            session.email = row.email
            session.uname = row.username

            return web.seeother("/")
        else:
            return renderer.login(2, identity) # wrong password
开发者ID:mahrud,项目名称:juxif,代码行数:38,代码来源:accounts.py


示例20: POST

    def POST(self):
        section = web.url().split('/')[1]
        i = web.input(code={})

        uid = int(i.uid)
        pid = int(i.pid)
        cid = int(i.cid)
        orig = '%s/sources/%s' % (os.getcwd(), i.code.filename)
        code = file(orig, 'w')
        code.write(i.code.value)
        code.close()
        lang = i.lang

        subid = db.insert('shots', 
            # subid has AUTO_INCREMENT, 
            uid = uid, 
            pid = pid, 
            cid = cid, 
            addr = orig, 
            lang = lang,
            mode = 0 # mode[i.cid]  #FIXME
            # created is set to CURRENT_TIMESTAMP,
            # TODO: update `access` by judge
            # TODO: update `modify` by judge
            )

        addr = '%s/sources/%d-%s' % (os.getcwd(), subid, i.code.filename)
        shutil.move(orig, addr)

        db.update('shots', 
            where = "subid=%d" % subid, 
            addr = addr
            )

        jucs.submit(subid, uid, pid, lang, addr)
        raise web.seeother('/algorithm/status/%s' % (subid))
开发者ID:mahrud,项目名称:juxif,代码行数:36,代码来源:code.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python web.urlquote函数代码示例发布时间:2022-05-26
下一篇:
Python web.unloadhook函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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