本文整理汇总了Python中models.Tag.by_name方法的典型用法代码示例。如果您正苦于以下问题:Python Tag.by_name方法的具体用法?Python Tag.by_name怎么用?Python Tag.by_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Tag
的用法示例。
在下文中一共展示了Tag.by_name方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from models import Tag [as 别名]
# 或者: from models.Tag import by_name [as 别名]
def post(self, *args, **kwargs):
''' Create the Dork in the system '''
form = Form(
title="Please enter a title",
description="Please enter a Description",
author="Please Enter an Author",
query="Please Enter the Shodan Hq Search Query",
tag="Please Select a Category"
)
try:
#Getting the user
session_manager = SessionManager.Instance()
session = session_manager.get_session(
self.get_secure_cookie('auth'), self.request.remote_ip)
user = User.by_user_name(session.data['user_name'])
#Get the tag
old_tag = Tag.by_name(self.get_argument('tag'))
#Get all the tags
tags = Tag.all()
if user != None:
if form.validate(self.request.arguments):
old_dork = Dork.by_title(self.get_argument('title'))
if old_dork:
self.render('user/submit.html', user=user, errors=['A Dork by this title has already been submitted'], success=None, tags=tags)
elif old_tag == None:
self.render('user/submit.html', user=user, errors=['A Dork by this title has already been submitted'], success=None, tags=tags)
else:
self.create_dork(user)
self.render('user/submit.html', user=user, success='Successfully created new Dork', errors=None, tags=tags)
else:
self.render('user/submit.html', user=user, errors=form.errors, success=None, tags=tags)
else:
self.render('public/please_login.html')
except Exception as e:
print e
self.render('public/please_login.html')