示例#1
0
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,
    }
示例#2
0
文件: utils.py 项目: aldeka/Bookie
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}
示例#3
0
文件: api.py 项目: cambot/Bookie
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())
    }
示例#4
0
文件: api.py 项目: xuanhan863/Bookie
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())
    }