本文整理汇总了Python中models.Tag.gql方法的典型用法代码示例。如果您正苦于以下问题:Python Tag.gql方法的具体用法?Python Tag.gql怎么用?Python Tag.gql使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Tag
的用法示例。
在下文中一共展示了Tag.gql方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: save_item
# 需要导入模块: from models import Tag [as 别名]
# 或者: from models.Tag import gql [as 别名]
def save_item(request, *args, **kwargs):
result = {}
logging.info('item_id: %s', request.get('item_id'))
if request.get('item_id'):
link = Link.get(request.get('item_id'))
else:
link = Link()
link.created = datetime.datetime.now()
link.created_day = datetime.date.today().day
link.created_month = datetime.date.today().month
link.created_year = datetime.date.today().year
link.owner = users.get_current_user().user_id()
link.link = request.get('link')
link.description = request.get('description')
link.is_actual = request.get('is_actual') == '1'
link.put()
_update_search_index(link, request.get('tags'))
#saving tags
for tag in LinkTag.all().filter('link = ', link):
tag.delete()
if request.get('tags'):
tags = request.get('tags').split(',')
for tag_name in tags:
tag_name = tag_name.strip()
if len(tag_name):
tag = Tag.gql('where name=:1',tag_name).get()
if tag == None:
tag = Tag(name=tag_name).put()
LinkTag(link=link, tag=tag, is_actual=link.is_actual, owner=link.owner).put()
result['ok'] = 1
return webapp2.Response(json.dumps(result), content_type='application/json')
示例2: show_list_by_tag
# 需要导入模块: from models import Tag [as 别名]
# 或者: from models.Tag import gql [as 别名]
def show_list_by_tag(request, *args, **kwargs):
tag = Tag.gql('where name=:1',kwargs['tag'].decode('utf-8')).get()
if tag == None:
return _404()
params = {}
params['page'] = request.get('page')
params['tag'] = tag
return _get_list_and_render(params, 'список ссылок по тэгу')
示例3: index
# 需要导入模块: from models import Tag [as 别名]
# 或者: from models.Tag import gql [as 别名]
def index(request):
tags=memcache.get('tags::1')
if tags is None:
tags=Tag.gql("WHERE depth = :1", 1)
memcache.set('tags::1', tags)
if request.user.is_anonymous():
marked_tags=None
else:
marked_tags=request.user.get_tags()
return render_to_response('tasteofhome/index.html', {'tags': tags, 'marked_tags': marked_tags})
示例4: tag
# 需要导入模块: from models import Tag [as 别名]
# 或者: from models.Tag import gql [as 别名]
def tag(request, key):
tag=memcache.get(key)
if tag is None:
tag=db.get(key)
memcache.set(key, tag)
tags=memcache.get(key+'::children')
if tags is None:
tags=Tag.gql("WHERE ANCESTOR IS :1 AND depth = :2", tag, tag.depth+1)
memcache.set(key+'::children', tags)
if request.user.is_anonymous():
marked_tags=None
else:
marked_tags=request.user.get_tags()
return render_to_response('tasteofhome/tag.html', {'tag': tag, 'tags': tags, 'marked_tags': marked_tags})
示例5: forum_category_page
# 需要导入模块: from models import Tag [as 别名]
# 或者: from models.Tag import gql [as 别名]
def forum_category_page(request, tag, page):
discussions=Course.gql("WHERE ANCESTOR IS :1", tag)
tags=Tag.gql("WHERE depth = :1", 100)
return render_to_response('tasteofhome/forum_category.html', {'discussions': discussions, 'category':tag, 'categories': forum_categories()})
示例6: forum_discussion
# 需要导入模块: from models import Tag [as 别名]
# 或者: from models.Tag import gql [as 别名]
def forum_discussion(request, course):
discussion=course
tags=Tag.gql("WHERE depth = :1", 100)
form=MessageForm()
return render_to_response('tasteofhome/discussion.html', {'discussion': discussion, 'form':form, 'categories': forum_categories()})
示例7: forum_categories
# 需要导入模块: from models import Tag [as 别名]
# 或者: from models.Tag import gql [as 别名]
def forum_categories():
categories=memcache.get('forum::categories')
if categories is None:
categories=Tag.gql("WHERE depth = :1", 100)
memcache.set('forum::categories', categories)
return categories