def export(request): """Handle exporting a user's bookmarks to file""" rdict = request.matchdict username = rdict.get('username') if request.user is not None: current_user = request.user.username else: current_user = None bmark_list = Bmark.query.join(Bmark.tags).\ options( contains_eager(Bmark.tags) ).\ join(Bmark.hashed).\ options( contains_eager(Bmark.hashed) ).\ filter(Bmark.username == username).all() BmarkLog.export(username, current_user) request.response_content_type = 'text/html' headers = [('Content-Disposition', 'attachment; filename="bookie_export.html"')] setattr(request, 'response_headerlist', headers) return { 'bmark_list': bmark_list, }
def export(request): """Handle exporting a user's bookmarks to file""" rdict = request.matchdict username = rdict.get("username") if request.user is not None: current_user = request.user.username else: current_user = None bmark_list = ( Bmark.query.join(Bmark.tags) .options(contains_eager(Bmark.tags)) .join(Bmark.hashed) .options(contains_eager(Bmark.hashed)) .filter(Bmark.username == username) .all() ) BmarkLog.export(username, current_user) request.response_content_type = "text/html" headers = [("Content-Disposition", 'attachment; filename="bookie_export.html"')] setattr(request, "response_headerlist", headers) return {"bmark_list": bmark_list}
def bmark_export(request): """Export via the api call to json dump """ username = request.user.username bmark_list = BmarkMgr.user_dump(username) # log that the user exported this BmarkLog.export(username, username) def build_bmark(bmark): d = dict(bmark) d['hashed'] = dict(bmark.hashed) return d return { 'bmarks': [build_bmark(bmark) for bmark in bmark_list], 'count': len(bmark_list), 'date': str(datetime.now()) }
def bmark_export(request): """Export via the api call to json dump """ username = request.user.username bmark_list = BmarkMgr.user_dump(username) # log that the user exported this BmarkLog.export(username, username) def build_bmark(bmark): d = dict(bmark) d['hashed'] = dict(bmark.hashed) return d return { 'bmarks': [build_bmark(bmark) for bmark in bmark_list], 'count': len(bmark_list), 'date': str(datetime.utcnow()) }