本文整理汇总了Python中bookie.models.BmarkMgr.get_recent_bmark方法的典型用法代码示例。如果您正苦于以下问题:Python BmarkMgr.get_recent_bmark方法的具体用法?Python BmarkMgr.get_recent_bmark怎么用?Python BmarkMgr.get_recent_bmark使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bookie.models.BmarkMgr
的用法示例。
在下文中一共展示了BmarkMgr.get_recent_bmark方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: bmark_get
# 需要导入模块: from bookie.models import BmarkMgr [as 别名]
# 或者: from bookie.models.BmarkMgr import get_recent_bmark [as 别名]
def bmark_get(request):
"""Return a bookmark requested via hash_id
We need to return a nested object with parts
bmark
- readable
"""
rdict = request.matchdict
params = request.params
hash_id = rdict.get('hash_id', None)
username = request.user.username
# the hash id will always be there or the route won't match
bookmark = BmarkMgr.get_by_hash(hash_id,
username=username)
last_bmark = {}
if 'last_bmark' in params and params['last_bmark'] != "false":
last = BmarkMgr.get_recent_bmark(username=username)
if last is not None:
last_bmark = {'last': dict(last)}
if bookmark is None:
request.response.status_int = 404
ret = {'error': "Bookmark for hash id {0} not found".format(hash_id)}
ret.update(last_bmark)
return ret
else:
return_obj = dict(bookmark)
if 'with_content' in params and params['with_content'] != 'false':
if bookmark.readable:
return_obj['readable'] = dict(bookmark.readable)
return_obj['tags'] = [dict(tag[1]) for tag in bookmark.tags.items()]
ret = {'bmark': return_obj}
ret.update(last_bmark)
return ret