Example #1
0
def upload_all(request):
    def category_init_func(row):
        c = Category(row['name'])
        c.id = row['id']
        return c
    def post_init_func(row):
        # this is lessons learned that relation needs an object not a string
        c = DBSession.query(Category).filter_by(name=row['category']).first()
        p = Post(row['title'], row['body'], c, row['pub_date'])
        return p
    request.save_book_to_database(field_name='file', session=DBSession,
                                  tables=[Category, Post],
                                  initializers=[category_init_func, post_init_func])
    return excel.make_response_from_tables(DBSession, [Category, Post], "xls")
Example #2
0
def upload_all(request):
    def category_init_func(row):
        c = Category(row['name'])
        c.id = row['id']
        return c

    def post_init_func(row):
        # this is lessons learned that relation needs an object not a string
        c = DBSession.query(Category).filter_by(name=row['category']).first()
        p = Post(row['title'], row['body'], c, row['pub_date'])
        return p

    request.save_book_to_database(
        field_name='file',
        session=DBSession,
        tables=[Category, Post],
        initializers=[category_init_func, post_init_func])
    return excel.make_response_from_tables(DBSession, [Category, Post], "xls")
Example #3
0
def doexport(request):
    return excel.make_response_from_tables(DBSession, [Category, Post], "xls")
def doexport(request):
    return excel.make_response_from_tables(DBSession, [Category, Post], "xls")