本文整理汇总了Python中tipfy.url_for函数的典型用法代码示例。如果您正苦于以下问题:Python url_for函数的具体用法?Python url_for怎么用?Python url_for使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了url_for函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: post
def post(self, **kwargs):
redirect_url = self.redirect_path()
if self.auth_current_user:
# User is already registered, so don't display the signup form.
return redirect(redirect_url)
if self.form.validate():
username = self.form.username.data
password = self.form.password.data
remember = self.form.remember.data
user = self.auth_get_user_entity(username=username)
if user is not None and user.disabled is not None and user.disabled is True:
self.set_message('error', 'Your account has been disabled. You can request a new account if you like. ', life=None)
else :
res = self.auth_login_with_form(username, password, remember)
if self.auth_current_user and self.auth_current_user.assigned_to is not None:
logging.log(logging.INFO, "assigned to client " + self.auth_current_user.assigned_to)
self.session['client'] = self.auth_current_user.assigned_to
redirect_url = url_for("clients-pretty")
if self.auth_current_user and self.auth_current_user.is_admin:
redirect_url = url_for("admin-dashboard")
if res:
return redirect(redirect_url)
self.set_message('error', 'Authentication failed. Please try again.', life=None)
return self.get(**kwargs)
开发者ID:nebulae,项目名称:vbitools,代码行数:28,代码来源:handlers.py
示例2: test_url_for_with_anchor
def test_url_for_with_anchor(self):
app = get_app()
request = get_request(app, base_url='http://foo.com')
app.match_url(request)
assert url_for('home', _anchor='my-little-anchor') == '/#my-little-anchor'
assert url_for('home', _full=True, _anchor='my-little-anchor') == 'http://foo.com/#my-little-anchor'
开发者ID:strogo,项目名称:tipfy,代码行数:7,代码来源:test_routing.py
示例3: test_url_for2
def test_url_for2(self):
app = get_app()
request = get_request(app, base_url='http://foo.com')
app.match_url(request)
assert url_for('profile', username='calvin') == '/people/calvin'
assert url_for('profile', username='hobbes') == '/people/hobbes'
assert url_for('profile', username='moe') == '/people/moe'
开发者ID:strogo,项目名称:tipfy,代码行数:8,代码来源:test_routing.py
示例4: get
def get(self, **kwargs):
if self.auth_current_user:
if self.auth_current_user.is_admin or self.auth_current_user.is_staff:
return self.redirect(url_for('admin-dashboard'))
else:
return self.redirect(url_for('clients-pretty'))
else:
return self.redirect(url_for('auth/login'))
开发者ID:nebulae,项目名称:vbitools,代码行数:8,代码来源:handlers.py
示例5: get
def get(self, **kwargs):
redirect_url = self.redirect_path()
if self.auth_current_user:
# User is already registered, so don't display the signup form.
return redirect(redirect_url)
opts = {'continue': self.redirect_path()}
context = {
'form': self.form,
'facebook_login_url': url_for('auth/facebook', **opts),
'google_login_url': url_for('auth/google', **opts),
'twitter_login_url': url_for('auth/twitter', **opts),
}
return self.render_response('users/login.html', **context)
开发者ID:macat,项目名称:Piratetitler,代码行数:15,代码来源:handlers.py
示例6: get
def get(self, exception=None, handler=None):
logging.exception(exception)
# Initial breadcrumbs for this app.
self.request.context['breadcrumbs'] = [
(url_for('home/index', area_name=self.area.name),
i18n._('Home'))
]
kwargs = {}
code = 500
template = 'base/error_500.html'
if isinstance(exception, HTTPException):
kwargs = {}
code = exception.code
if code in (404, 500):
if exception.description != exception.__class__.description:
kwargs['message'] = exception.description
template = 'base/error_%d.html' % code
else:
kwargs['message'] = exception.description
response = self.render_response(template, **kwargs)
response.status_code = code
return response
开发者ID:ac001,项目名称:moe,代码行数:25,代码来源:handlers.py
示例7: get
def get(self, **kwargs):
race = db.get(kwargs['id'])
templateValues = {'title' : 'Update Race',
'submit_url' : url_for('race/update', id=kwargs['id']),
'existingRace' : get_property_dict(race)}
templateValues['existingRace']['imageUrl'] = race.imageUrl
return self.render_page('race-form.html', **templateValues)
开发者ID:cconger,项目名称:BuildCraft,代码行数:7,代码来源:race.py
示例8: get
def get(self, exception=None, handler=None):
# Always log exceptions.
logging.exception(exception)
# Get the exception code and description, if it is an HTTPException,
# or assume 500.
code = getattr(exception, "code", 500)
message = getattr(exception, "description", None)
if self.app.dev and code not in (404,):
# Raise the exception in dev except for NotFound.
raise
if code in (403, 404):
# Render a special template for these codes.
template = "base/error_%d.html" % code
else:
# Render a generic 500 template.
template = "base/error_500.html"
# Set breadcrumbs to follow rest of the site.
self.request.context["breadcrumbs"] = [(url_for("home/index", area_name=self.area.name), i18n._("Home"))]
# Render the template using the exception message, if any, and set
# the status code.
response = self.render_response(template, message=message)
response.status_code = code
return response
开发者ID:wvega,项目名称:sp-unal,代码行数:28,代码来源:handlers.py
示例9: post
def post(self):
entity=db.get(db.Key(self.request.form.get('entity_key')))
entity.status=self.request.form.get('new_status')
entity.put()
return redirect(url_for('links/review'))
开发者ID:Hubble1,项目名称:eventgrinder,代码行数:5,代码来源:handlers.py
示例10: get
def get(self, **kwargs):
results = GameVersion.all().fetch(10)
templateValues = {'gameVersions' : results,
'create_url' : url_for('version/create')}
return self.render_page('game-versions.html', **templateValues)
开发者ID:cconger,项目名称:BuildCraft,代码行数:7,代码来源:gameversion.py
示例11: get
def get(self, file_key=None, **kwargs):
template = 'admin/files/new.html'
context = {
'form': self.form,
'upload_url': blobstore.create_upload_url(url_for('blobstore/upload'))
}
return self.render_response(template, **context)
开发者ID:tresacton,项目名称:gae-shop,代码行数:7,代码来源:handlers.py
示例12: get
def get(self, **kwargs):
templateValues = {'title' : 'Create Buildable',
'submit_url' : url_for('buildable/create'),
'races' : Race.all().fetch(10),
'gameVersions' : GameVersion.all().fetch(10)}
return self.render_page('buildable-form.html', **templateValues)
开发者ID:cconger,项目名称:BuildCraft,代码行数:7,代码来源:buildable.py
示例13: get
def get(self, **kwargs):
tasks = self._getTasks()
context = {
'tasks': tasks,
'add_task_url': url_for('tasks-new'),
}
return self.render_response('tasks/index.html', **context)
开发者ID:nulltoken,项目名称:Theoleyre,代码行数:8,代码来源:handlers.py
示例14: get
def get(self):
download_url = url_for('cashblob/download')
html = ''
html += '<html><body>'
html += '<form action="%s" method="POST">' % download_url
html += """Account: <input type="text" name="account"><br> <input type="submit"
name="submit" value="Submit"> </form></body></html>"""
return Response(html, mimetype='text/html')
开发者ID:brunsky,项目名称:CashBlob,代码行数:9,代码来源:handlers.py
示例15: getPages
def getPages(self):
pages = Page.gql('ORDER BY sequenceNumber')
processedPages=[]
for page in pages:
p={
'url': url_for('page_def', number=page.pageLabel),
'name': 'Page %s' % (page.pageLabel),
}
processedPages.append(p)
return processedPages
开发者ID:hamish,项目名称:HotCurrie,代码行数:10,代码来源:handlers.py
示例16: get
def get(self, number='1', size='24'):
pageLabel=number
sizeIndex=int(size)
#pageLabel = kwargs.get('number')
pages = Page.gql("WHERE pageLabel=:1", pageLabel)
page = pages.get()
#if (page.loginRequired):
# logging.debug("loginRequired:")
# if not self.auth_current_user:
# logging.debug("failed:")
# return redirect(self.auth_login_url())
url = images.get_serving_url(page.blobKey, size=IMG_SERVING_SIZES[sizeIndex], crop=False)
if (containsAny(pageLabel, '0123456789')):
pageSequence = int(pageLabel)+ 13
else:
pageSequence = fromRoman(pageLabel)-1
arguments={
'pageImageURL':url,
}
if(pageSequence>0):
prevLabel = getPageLabel(pageSequence - 1)
arguments['hasPrevious']=1
arguments['previousURL']=url_for('page', number=prevLabel, size=size)
if (pageSequence<223):
nextLabel = getPageLabel(pageSequence + 1)
arguments['hasNext']=1
arguments['nextURL']=url_for('page', number=nextLabel, size=size)
if(sizeIndex>0):
sizeStr=str(sizeIndex-1)
arguments['hasSmaller']=1
arguments['smallerURL']=url_for('page', number=number, size=sizeStr)
if(sizeIndex<29):
sizeStr=str(sizeIndex+1)
arguments['hasBigger']=1
arguments['biggerURL']=url_for('page', number=number, size=sizeStr)
return self.render_response('Page.html', **arguments)
开发者ID:hamish,项目名称:HotCurrie,代码行数:42,代码来源:handlers.py
示例17: create_login_url
def create_login_url(self, dest_url):
"""Returns the login URL for this request and specified destination URL.
By default returns the URL for the endpoint :attr:`login_endpoint`.
:param dest_url:
String that is the desired final destination URL for the user once
login is complete.
:return:
An URL to perform login.
"""
return url_for(self.login_endpoint, redirect=dest_url, full=True)
开发者ID:aristidb,项目名称:cppbash,代码行数:11,代码来源:__init__.py
示例18: get
def get(self, **kwargs):
u = users.get_current_user()
if models.Reviewer.all(keys_only = True).filter('user =', u).count(1) != 1:
if users.is_current_user_admin():
r = models.Reviewer(user = u)
r.put()
else:
return redirect(users.create_login_url(url_for('review-start')))
q = models.Quote.all().filter('accepted =', False).order('creation_date')
if q.count(1) == 0:
return redirect_to('home')
return render_response('cppbash/review.html', quotes = q)
开发者ID:aristidb,项目名称:cppbash,代码行数:12,代码来源:review.py
示例19: create_wiki_link
def create_wiki_link(path):
"""Creates a wiki link given a path."""
anchor = None
parts = path.split('#', 1)
if len(parts) > 1:
path = parts[0]
anchor = parts[1]
page_path = WikiPath(path).normalized_path
url = url_for('wiki/index', page_path=page_path, area_name=area.name)
if anchor:
url += '#' + url_quote(anchor)
return url
开发者ID:wvega,项目名称:sp-unal,代码行数:14,代码来源:parser.py
示例20: get
def get(self, **kwargs):
upload_url = blobstore.create_upload_url(url_for('blobstore/upload'))
p = Poof.all().filter('username = ',self.auth_current_user.username).get()
job_list = []
finish = False
if p:
image_url = ''
if p.picture:
image_url=images.get_serving_url(str(p.picture.key()))+"=s200"
if p.is_active:
for j in p.poofers:
job_list.append(j)
if (date.today() - p.end_date) >= timedelta (days = 0):
finish = True
return self.render_response('content.html', section='content', up_url=upload_url, picture = image_url, poof =p, job_collection = job_list, finish = finish)
return self.render_response('content.html', section='content', up_url=upload_url, poof=Poof())
开发者ID:adriancbjie,项目名称:pooofme,代码行数:16,代码来源:handlers.py
注:本文中的tipfy.url_for函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论