Esempio n. 1
0
 def __init__(self, request):
     super(MainDBAdminView, self).__init__(request)
     settings = request.registry.settings
     annex_directory = settings['default.gitannex.annex_path']
     self.siteimagepath = settings['default.siteimages.directory']
     self.annex_directory = annex_directory
     self.dburl = settings['sqlalchemy.url']
     self.session = request.db
     self.mgr = MainDBAdminManager(self.session, self.dburl,
                                   self.annex_directory,
                                   self.siteimagepath)
Esempio n. 2
0
class MainDBAdminView(BaseResource):
    def __init__(self, request):
        super(MainDBAdminView, self).__init__(request)
        settings = request.registry.settings
        annex_directory = settings['default.gitannex.annex_path']
        self.siteimagepath = settings['default.siteimages.directory']
        self.annex_directory = annex_directory
        self.dburl = settings['sqlalchemy.url']
        self.session = request.db
        self.mgr = MainDBAdminManager(self.session, self.dburl,
                                      self.annex_directory,
                                      self.siteimagepath)
        

    def post(self):
        data = self.request.json
        action = data['action']
        if action == 'populate_database':
            database = data['database']
            if database == 'gitannex':
                self.mgr.populate_annexdb()
        elif action == 'setup_repos':
            return self.setup_repos()
        return self.get()

    def delete(self):
        data = self.request.json
        db = data['database']
        if db == 'gitannex':
            data = self.mgr.delete_annex_db()
        elif db == 'siteimages':
            data = self.mgr.delete_siteimages()
        return self.get()

    def get(self, inspector=None):
        data = dict()
        data = self.mgr.get_all_info(inspector=inspector)
        return data