本文整理汇总了Python中models.Tag.get_by_name方法的典型用法代码示例。如果您正苦于以下问题:Python Tag.get_by_name方法的具体用法?Python Tag.get_by_name怎么用?Python Tag.get_by_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Tag
的用法示例。
在下文中一共展示了Tag.get_by_name方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from models import Tag [as 别名]
# 或者: from models.Tag import get_by_name [as 别名]
def get(self, tag_name):
page = int(self.request.get('page', 1))
offset = (page - 1) * self.LIST_PER_PAGE
tag = Tag.get_by_name(tag_name)
self.list = Tag.get_article_list(tag=tag, limit=self.LIST_PER_PAGE, offset=offset) if tag else None
self.count = tag.count if tag else 0
return Action.Result.DEFAULT
示例2: get
# 需要导入模块: from models import Tag [as 别名]
# 或者: from models.Tag import get_by_name [as 别名]
def get(self, tag_name):
t = Tag.get_by_name(tag_name)
if t == None:
# TODO: error page?
return
# Gather all the recipes for all the QIs for this ingredient
recipes = uniq([Recipe.get(key) for key in t.tagged],
lambda x: x.title)
buckets,keys = bucketize(recipes, lambda x: x.title)
templatevalues = RequestContext(self.request, {
'tag' : t,
'recipes' : recipes,
'buckets' : buckets,
'keys' : keys
})
path = os.path.join(os.path.dirname(__file__), 'recipes_by_tag.html')
self.response.out.write(template.render(path, templatevalues))
示例3: get_item_from_rank
# 需要导入模块: from models import Tag [as 别名]
# 或者: from models.Tag import get_by_name [as 别名]
def get_item_from_rank():
resp = Resp()
rank_id = request.args.get("rank_id", None)
tag_name = request.args.get("tag_name", None)
item_ids_from_rank = ItemRank.query.with_entities("item_id").filter_by(
rank_id=rank_id
).all()
if tag_name:
tag = Tag.get_by_name(tag_name).first()
if tag:
item_ids_from_tag = ItemTag.query.with_entities("item_id").filter_by(
tag_id=tag.id
).all()
else:
item_ids_from_tag = []
item_ids = list(set(item_ids_from_rank) & set(item_ids_from_tag))
result = []
for item_id in item_ids:
item = Item.get_by_id(item_id)
result.append(item)
resp.data = result
return resp