本文整理汇总了Python中bookie.models.BmarkMgr.find方法的典型用法代码示例。如果您正苦于以下问题:Python BmarkMgr.find方法的具体用法?Python BmarkMgr.find怎么用?Python BmarkMgr.find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bookie.models.BmarkMgr
的用法示例。
在下文中一共展示了BmarkMgr.find方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: bmark_popular
# 需要导入模块: from bookie.models import BmarkMgr [as 别名]
# 或者: from bookie.models.BmarkMgr import find [as 别名]
def bmark_popular(request):
"""Get a list of the most popular bmarks for the api call"""
rdict = request.matchdict
params = request.params
# check if we have a page count submitted
page = int(params.get('page', '0'))
count = int(params.get('count', RESULTS_MAX))
with_content = True if 'with_content' in params and params['with_content'] != "false" else False
username = request.user.username
# thou shalt not have more then the HARD MAX
# @todo move this to the .ini as a setting
if count > HARD_MAX:
count = HARD_MAX
# do we have any tags to filter upon
tags = rdict.get('tags', None)
if isinstance(tags, str):
tags = [tags]
# if we don't have tags, we might have them sent by a non-js browser as a
# string in a query string
if not tags and 'tag_filter' in params:
tags = params.get('tag_filter').split()
popular_list = BmarkMgr.find(limit=count,
order_by=Bmark.clicks.desc(),
page=page,
tags=tags,
username=username,
with_content=with_content,
with_tags=True,
)
result_set = []
for res in popular_list:
return_obj = dict(res)
return_obj['tags'] = [dict(tag[1]) for tag in res.tags.items()]
# the hashed object is there as well, we need to pull the url and
# clicks from it as total_clicks
return_obj['url'] = res.hashed.url
return_obj['total_clicks'] = res.hashed.clicks
if with_content:
return_obj['readable'] = dict(res.hashed.readable)
result_set.append(return_obj)
return {
'bmarks': result_set,
'max_count': RESULTS_MAX,
'count': len(popular_list),
'page': page,
'tag_filter': tags,
}
示例2: bmark_list
# 需要导入模块: from bookie.models import BmarkMgr [as 别名]
# 或者: from bookie.models.BmarkMgr import find [as 别名]
def bmark_list(request):
"""Display the list of bookmarks for this tag"""
rdict = request.matchdict
params = request.params
# check if we have a page count submitted
tags = rdict.get('tags')
username = rdict.get("username", None)
page = int(params.get('page', 0))
# verify the tag exists before we go on
# 404 if the tag isn't found
exists = TagMgr.find(tags=tags)
if not exists:
raise HTTPNotFound()
bmarks = BmarkMgr.find(tags=tags,
limit=RESULTS_MAX,
page=page,
username=username)
return {
'tags': tags,
'bmark_list': bmarks,
'max_count': RESULTS_MAX,
'count': len(bmarks),
'page': page,
'username': username,
}
示例3: bmark_list
# 需要导入模块: from bookie.models import BmarkMgr [as 别名]
# 或者: from bookie.models.BmarkMgr import find [as 别名]
def bmark_list(request):
"""Display the list of bookmarks for this tag"""
route_name = request.matched_route.name
rdict = request.matchdict
params = request.params
# check if we have a page count submitted
tags = rdict.get('tags')
page = int(params.get('page', 0))
# verify the tag exists before we go on
# 404 if the tag isn't found
exists = TagMgr.find(tags=tags)
if not exists:
raise HTTPNotFound()
bmarks = BmarkMgr.find(tags=tags,
limit=RESULTS_MAX,
page=page,)
if 'ajax' in route_name:
html = render('bookie:templates/tag/bmarks.mako',
{
'tags': tags,
'bmark_list': bmarks,
'max_count': RESULTS_MAX,
'count': len(bmarks),
'page': page,
'allow_edit': access.edit_enabled(request.registry.settings),
},
request=request)
return {
'success': True,
'message': "",
'payload': {
'html': html,
}
}
else:
return {'tags': tags,
'bmark_list': bmarks,
'max_count': RESULTS_MAX,
'count': len(bmarks),
'page': page,
'allow_edit': access.edit_enabled(request.registry.settings),
}
示例4: recent
# 需要导入模块: from bookie.models import BmarkMgr [as 别名]
# 或者: from bookie.models.BmarkMgr import find [as 别名]
def recent(request):
"""Most recent list of bookmarks capped at MAX"""
rdict = request.matchdict
params = request.params
LOG.debug('in recent!')
# check if we have a page count submitted
page = int(params.get('page', '0'))
# do we have any tags to filter upon
tags = rdict.get('tags', None)
if isinstance(tags, str):
tags = [tags]
# check for auth related stuff
# are we looking for a specific user
username = rdict.get('username', None)
# if we don't have tags, we might have them sent by a non-js browser as a
# string in a query string
if not tags and 'tag_filter' in params:
tags = params.get('tag_filter').split()
recent_list = BmarkMgr.find(limit=RESULTS_MAX,
order_by=Bmark.stored.desc(),
tags=tags,
page=page,
username=username)
ret = {
'bmarks': recent_list,
'max_count': RESULTS_MAX,
'count': len(recent_list),
'page': page,
'tags': tags,
'username': username,
}
return ret
示例5: popular
# 需要导入模块: from bookie.models import BmarkMgr [as 别名]
# 或者: from bookie.models.BmarkMgr import find [as 别名]
def popular(request):
"""Most popular list of bookmarks capped at MAX"""
rdict = request.matchdict
params = request.params
# check if we have a page count submitted
tags = rdict.get('tags', None)
page = int(params.get('page', '0'))
recent_list = BmarkMgr.find(limit=RESULTS_MAX,
order_by=Bmark.stored.desc(),
tags=tags,
page=page)
return {
'bmarks': recent_list,
'max_count': RESULTS_MAX,
'count': len(recent_list),
'page': page,
'allow_edit': access.edit_enabled(request.registry.settings),
}
rdict = request.matchdict
# check if we have a page count submitted
page = int(rdict.get('page', '0'))
popular_list = BmarkMgr.popular(limit=RESULTS_MAX,
with_tags=True,
page=page)
return {
'bmarks': popular_list,
'max_count': RESULTS_MAX,
'count': len(popular_list),
'page': page,
'allow_edit': access.edit_enabled(request.registry.settings),
}
示例6: recent
# 需要导入模块: from bookie.models import BmarkMgr [as 别名]
# 或者: from bookie.models.BmarkMgr import find [as 别名]
def recent(request):
"""Most recent list of bookmarks capped at MAX"""
rdict = request.matchdict
params = request.params
# check if we have a page count submitted
page = int(params.get('page', '0'))
# do we have any tags to filter upon
tags = rdict.get('tags', None)
if isinstance(tags, str):
tags = [tags]
# if we don't have tags, we might have them sent by a non-js browser as a
# string in a query string
if not tags and 'tag_filter' in params:
tags = params.get('tag_filter').split()
LOG.debug('tags')
LOG.debug(tags)
recent_list = BmarkMgr.find(limit=RESULTS_MAX,
order_by=Bmark.stored.desc(),
tags=tags,
page=page)
ret = {
'bmarks': recent_list,
'max_count': RESULTS_MAX,
'count': len(recent_list),
'page': page,
'tags': tags,
'allow_edit': access.edit_enabled(request.registry.settings),
}
return ret
示例7: bmark_recent
# 需要导入模块: from bookie.models import BmarkMgr [as 别名]
# 或者: from bookie.models.BmarkMgr import find [as 别名]
def bmark_recent(request):
"""Get a list of the bmarks for the api call"""
rdict = request.matchdict
params = request.params
# check if we have a page count submitted
page = int(params.get('page', '0'))
count = int(params.get('count', RESULTS_MAX))
with_content = _check_with_content(params)
# we only want to do the username if the username is in the url
username = rdict.get('username', None)
# thou shalt not have more then the HARD MAX
# @todo move this to the .ini as a setting
if count > HARD_MAX:
count = HARD_MAX
# do we have any tags to filter upon
tags = rdict.get('tags', None)
if isinstance(tags, str):
tags = [tags]
# if we don't have tags, we might have them sent by a non-js browser as a
# string in a query string
if not tags and 'tag_filter' in params:
tags = params.get('tag_filter').split()
# @todo fix this!
# if we allow showing of content the query hangs and fails on the
# postgres side. Need to check the query and figure out what's up.
# see bug #142
with_content = False
recent_list = BmarkMgr.find(limit=count,
order_by=Bmark.stored.desc(),
page=page,
tags=tags,
username=username,
with_content=with_content,
with_tags=True,
)
result_set = []
for res in recent_list:
return_obj = dict(res)
return_obj['tags'] = [dict(tag[1]) for tag in res.tags.items()]
# we should have the hashed information, we need the url and clicks as
# total clicks to send back
return_obj['url'] = res.hashed.url
return_obj['total_clicks'] = res.hashed.clicks
if with_content:
return_obj['readable'] = dict(res.readable) if res.readable else {}
result_set.append(return_obj)
return {
'bmarks': result_set,
'max_count': RESULTS_MAX,
'count': len(recent_list),
'page': page,
'tag_filter': tags,
}