No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

admin.py 976B

1234567891011121314151617181920212223242526272829
  1. #-*- coding: utf-8 -*-
  2. import sys
  3. import os, os.path
  4. from plugins.mongodb_datasource.migration_handler import MongoDbMigrationHandler
  5. sys.path.append(os.path.dirname(os.getcwd()+'/..'))
  6. from lodel.settings.settings import Settings as settings
  7. settings('globconf.d')
  8. from lodel.settings import Settings
  9. def generate_dyncode(model_file, translator):
  10. from lodel.editorial_model.model import EditorialModel
  11. from lodel.leapi import lefactory
  12. model = EditorialModel.load(translator, filename = model_file)
  13. dyncode = lefactory.dyncode_from_em(model)
  14. return dyncode
  15. def refresh_dyncode(model_file, translator, output_filename):
  16. dyncode = generate_dyncode(model_file, translator)
  17. with open(output_filename, 'w+') as out_fd:
  18. out_fd.write(dyncode)
  19. out_fd.close()
  20. def init_db(conn_args):
  21. migration_handler = MongoDbMigrationHandler(conn_args=conn_args)
  22. migration_handler._install_collections()
  23. migration_handler.database.close()