def upgrade(migrate_engine): folder = os.path.dirname(__file__) session = Session.create_session(connection_string=migrate_engine.url) provider = ReportLayoutProvider(session) try: files = os.path.join(folder, '002', 'report_layout', '*.yml') for path in glob(files): name = str(os.path.basename(path).split('.')[0]) text = open(path).read() provider.add(ReportLayout(name=name, content=text, last_modified=now()), commit=False) provider.commit() except Exception: provider.rollback() raise
def report_layout_add(): data = request_data() provider = ReportLayoutProvider(_write_session) layout = ReportLayout(name=data['name'], content='', last_modified=now()) provider.add(layout)