本文整理汇总了Python中models.Tag.all方法的典型用法代码示例。如果您正苦于以下问题:Python Tag.all方法的具体用法?Python Tag.all怎么用?Python Tag.all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Tag
的用法示例。
在下文中一共展示了Tag.all方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from models import Tag [as 别名]
# 或者: from models.Tag import all [as 别名]
def post(self, *args, **kwargs):
''' This is used to create new tags '''
form = Form(name="Please enter a tag name")
tags = Tag.all()
if form.validate(self.request.arguments):
self.create_tag()
tags = Tag.all()
self.render("admin/manage_tags.html", tags=tags)
else:
self.render("admin/manage_tags.html", tags=tags, errors=form.errors)
示例2: show_tags_list
# 需要导入模块: from models import Tag [as 别名]
# 或者: from models.Tag import all [as 别名]
def show_tags_list(request, *args, **kwargs):
params = {}
tags = Tag.all().order('name').fetch(1000)
for tag in tags:
tag.num_links = LinkTag.all().filter('tag = ', tag).filter('is_actual = ', True).filter('owner = ', users.get_current_user().user_id()).count()
min_count = 1
max_count = 1
min_size = 10
max_size = 20
for tag in tags:
if min_count > tag.num_links:
min_count = tag.num_links
if max_count < tag.num_links:
max_count = tag.num_links
for tag in tags:
tag.size = _get_size(min_size, max_size, tag.num_links-(min_count-1), max_count+1)
params['tags'] = tags
params['page_title'] = 'список тэгов'
params['menu_items'] = get_menu_items()
params['user'] = users.get_current_user().nickname()
return _render_to_response(params, 'tags');
示例3: GET
# 需要导入模块: from models import Tag [as 别名]
# 或者: from models.Tag import all [as 别名]
def GET(self):
user = users.get_current_user()
if user:
greeting = ("Welcome, %s! (<a href=\"%s\">sign out</a>)" % (user.nickname(), users.create_logout_url("/")))
query = Tag.all()
query.filter('author=',user)
results = query.fetch(10)
query = Tag.all()
query.filter('author',user)
r = query.run()
tags = c = [ c.name for c in r ]
return render.dashboard(greeting,tags, form_add_tag, form_add_note)
else:
greeting = ("<a href=\"%s\">Sign in or register</a>." % users.create_login_url("/"))
return render.index(greeting)
示例4: edit_item
# 需要导入模块: from models import Tag [as 别名]
# 或者: from models.Tag import all [as 别名]
def edit_item(request, *args, **kwargs):
params = {}
params['item_id'] = request.get('item_id')
if params['item_id']:
link = Link.get(params['item_id'])
link.tags = []
for tag in LinkTag.all().filter('link = ', link).fetch(10):
link.tags.append(tag.tag.name)
params['link'] = link
params['tags'] = Tag.all()
return _render_to_response(params,'edit')
示例5: search_links
# 需要导入模块: from models import Tag [as 别名]
# 或者: from models.Tag import all [as 别名]
def search_links(request, *args, **kwargs):
params = {}
params['page'] = request.get('page')
if request.get('make_search'):
params['make_search'] = 1
params['query'] = {}
query_string = []
query_string.append('owner = %s' % users.get_current_user().user_id())
if request.get('text'):
query_string.append('(link:"%s" OR description:"%s")' % (request.get('text'), request.get('text')))
params['query']['text'] = request.get('text')
if request.get('created'):
params['query']['created'] = request.get('created')
if request.get('created') == '1day':
query_string.append('created > %s' % datetime.date.today())
if request.get('created') == '1week':
query_string.append('created > %s' % (datetime.date.today() - datetime.timedelta(days=7)))
if request.get('created') == '1month':
query_string.append('created > %s' % (datetime.date.today() - datetime.timedelta(days=30)))
if request.get('created') == 'period':
pass
if request.get('show_not_actual'):
params['query']['show_not_actual'] = request.get('show_not_actual')
else:
query_string.append('is_actual = 1')
if request.get('tag'):
params['query']['tag'] = request.get('tag')
query_string.append('tags:"%s"' % request.get('tag'))
search_index = search.Index(name='links')
#print search_index
#print query_string
results = search_index.search(search.Query(
query_string = ' AND '.join(query_string),
options=search.QueryOptions(
limit=20,
#sort_options=search.SortOptions(
# expressions=[
# search.SortExpression(expression='created', direction=SortExpression.DESCENDING, #default_value='')],
# limit=1000),
ids_only=True)))
#for i,res in enumerate(results):
# print i, res
params['keys'] = []
for res in results:
params['keys'].append(db.Key(res.doc_id))
else:
params['skip_get_list'] = 1
params['tags'] = Tag.all()
return _get_list_and_render(params, 'поиск', 'search')
示例6: get
# 需要导入模块: from models import Tag [as 别名]
# 或者: from models.Tag import all [as 别名]
def get(self, *args, **kwargs):
''' This will let you delete a given tag from the system '''
tags = Tag.all()
try:
uuid = self.get_argument('tag')
if uuid != None:
tag = Tag.by_uuid(uuid)
if tag != None:
self.dbsession.delete(tag)
tags = Tag.all()
self.render("admin/manage_tags.html", success="Successfuly deleted tag from the system", tags=tags)
else:
self.render("admin/manage_tags.html", errors="Please Select a Tag", tags=tags)
else:
self.render("admin/manage_tags.html", errors="Please Select a Tag", tags=tags)
except Exception as e:
self.render("admin/manage_tags.html", errors="Invalid Tag Selected", tags=tags)
示例7: render
# 需要导入模块: from models import Tag [as 别名]
# 或者: from models.Tag import all [as 别名]
def render(self, context):
output = ['']
tags = Tag.all()
#tags = tags.filter('valid=', True)
for tag in tags:
if tag.entrycount >= 1:
output.append(tag)
context['all_tags'] = output
return ''
示例8: get
# 需要导入模块: from models import Tag [as 别名]
# 或者: from models.Tag import all [as 别名]
def get(self):
q = Tag.all()
tags = [t for t in q]
buckets,keys = bucketize(tags, lambda t: t.tag)
templatevalues = RequestContext(self.request, {
'tags' : tags,
'buckets' : buckets,
'keys' : keys,
})
path = os.path.join(os.path.dirname(__file__), 'tags_by_name.html')
self.response.out.write(template.render(path, templatevalues))
示例9: get
# 需要导入模块: from models import Tag [as 别名]
# 或者: from models.Tag import all [as 别名]
def get(self,tagname):
result = Tag.all().filter('tag', tagname).filter('valid', True)
tag = result.fetch(limit=1)
if len(tag) > 0:
tagname = tag[0].tag
if users.is_current_user_admin():
websites = WebSite.all().filter('tags', tagname).order('-created')
else:
websites = WebSite.all().filter('tags', tagname).filter('is_public', True).order('-created')
self.render('tag.html', tag=tagname, websites=websites)
else:
self.render('base.html', message='No Such Tag')
示例10: get
# 需要导入模块: from models import Tag [as 别名]
# 或者: from models.Tag import all [as 别名]
def get(self, *args, **kwargs):
try:
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'])
if user != None:
tags = Tag.all()
self.render('user/submit.html', user=user, errors=None, success=None, tags=tags)
else:
self.render('public/please_login.html')
except:
self.render('public/please_login.html')
示例11: sitemap
# 需要导入模块: from models import Tag [as 别名]
# 或者: from models.Tag import all [as 别名]
def sitemap(request):
str = """<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="/static/xsl/sitemap.xsl"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>http://www.niubi.de/</loc>
<changefreq>weekly</changefreq>
<priority>0.9</priority>
</url>
"""
posts = Post.all().filter("is_published", True)
for post in posts:
str += (
"""<url>
<loc>http://www.niubi.de/post/%s/</loc>
<changefreq>weekly</changefreq>
<priority>0.8</priority>
</url>
"""
% post.key().id()
)
categories = Category.all().order("-post_count")
for category in categories:
str += (
"""<url>
<loc>http://www.niubi.de/category/%s/</loc>
<changefreq>monthly</changefreq>
<priority>0.8</priority>
</url>
"""
% category.key().id()
)
tags = Tag.all().order("-post_count")
for tag in tags:
str += (
"""<url>
<loc>http://www.niubi.de/tag/%s/</loc>
<changefreq>weekly</changefreq>
<priority>0.8</priority>
</url>
"""
% tag.name
)
str += """<url>
<loc>http://www.niubi.de/about/</loc>
<changefreq>yearly</changefreq>
<priority>0.8</priority>
</url>"""
str += "</urlset>"
return HttpResponse(str, content_type="text/xml")
示例12: get
# 需要导入模块: from models import Tag [as 别名]
# 或者: from models.Tag import all [as 别名]
def get(self, slug):
# we want a canonical url with the trailing slash
# so if it's missing we need to throw a 301, adding the slash in
# the process
if slug[-1] != "/":
self.redirect("%s/" % slug, True)
return
output = get_cache(slug)
if output is None:
try:
item = Page.gql("WHERE internal_url=:1", slug)[0]
except IndexError:
self.error(404)
output = self.render("404.html", {"title": "Page not found"})
self.response.out.write(output)
return
# get a list of related items based on taggings
# remember to filter out the article we're on
related = []
for tag in item.tags:
related += (Tag.all().filter('name =', tag).filter('title !=', item.title))
# we also need to deduplicate the list as sometimes items
# will share tags
seen = []
deduped = []
for related_item in related:
if not related_item.url in seen:
deduped.append(related_item)
seen.append(related_item.url)
context = {
"item": item,
"related": deduped,
"title": item.title,
}
output = self.render("item.html", context)
memcache.add(slug, output, 3600)
self.response.out.write(output)
示例13: post
# 需要导入模块: from models import Tag [as 别名]
# 或者: from models.Tag import all [as 别名]
def post(self):
user = users.get_current_user()
url = self.request.get('url_text')
tags = self.request.get('url_tag').split(",")
usable_tags = []
for tag_name in tags:
if len(tag_name) is 0:
continue
tag = Tag(name = tag_name)
tags_query = Tag.all()
tags_query.filter('name =', tag_name)
if len(tags_query.fetch(1)) is not 0:
continue
tag.put()
usable_tags.append(tag.key())
book_mark = Bookmark(user = user, url = url, tags = usable_tags)
book_mark.put()
json_data = simplejson.dumps({'result':True, 'link': url, 'tags': tags})
self.response.out.write(json_data)
示例14: post
# 需要导入模块: from models import Tag [as 别名]
# 或者: from models.Tag import all [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')
示例15: getAllTags
# 需要导入模块: from models import Tag [as 别名]
# 或者: from models.Tag import all [as 别名]
def getAllTags():
return Tag.all().order('-useCount')