Beispiel #1
0
    def configure(self, config_):
        if config_.get('ckanext.xloader.ignore_hash') in [
                'True', 'TRUE', '1', True, 1
        ]:
            self.ignore_hash = True
        else:
            self.ignore_hash = False

        for config_option in ('ckan.site_url', ):
            if not config_.get(config_option):
                raise Exception(
                    'Config option `{0}` must be set to use ckanext-xloader.'.
                    format(config_option))

        if p.toolkit.check_ckan_version(max_version='2.7.99'):
            # populate_full_text_trigger() needs to be defined, and this was
            # introduced in CKAN 2.8 when you installed datastore e.g.:
            #     paster datastore set-permissions
            # However before CKAN 2.8 we need to check the user has defined
            # this function manually.
            connection = get_write_engine().connect()
            if not fulltext_function_exists(connection):
                raise Exception('populate_full_text_trigger is not defined. '
                                'See ckanext-xloader\'s README.rst for more '
                                'details.')
Beispiel #2
0
def add_full_text_trigger_function():
    engine = get_write_engine()
    Session = orm.scoped_session(orm.sessionmaker(bind=engine))
    c = Session.connection()
    with open(os.path.join(__location__, '..', '..', '..', 'full_text_function.sql'), 'r') as full_text_sql:
        c.execute(sqlalchemy.text(full_text_sql.read()))
    Session.commit()
    Session.remove()
Beispiel #3
0
    def configure(self, config):
        self.config = config

        xloader_formats = config.get('ckanext.xloader.formats', '').lower()
        self.xloader_formats = xloader_formats.lower().split(
        ) or DEFAULT_FORMATS

        for config_option in ('ckan.site_url', ):
            if not config.get(config_option):
                raise Exception(
                    'Config option `{0}` must be set to use ckanext-xloader.'.
                    format(config_option))

        connection = get_write_engine().connect()
        if not fulltext_function_exists(connection):
            raise Exception('populate_full_text_trigger is not defined. See '
                            'ckanext-xloader\'s README.rst for more details.')
    def configure(self, config_):
        if config_.get('ckanext.xloader.ignore_hash') in [
                'True', 'TRUE', '1', True, 1
        ]:
            self.ignore_hash = True
        else:
            self.ignore_hash = False

        for config_option in ('ckan.site_url', ):
            if not config_.get(config_option):
                raise Exception(
                    'Config option `{0}` must be set to use ckanext-xloader.'.
                    format(config_option))

        connection = get_write_engine().connect()
        if not fulltext_function_exists(connection):
            raise Exception('populate_full_text_trigger is not defined. See '
                            'ckanext-xloader\'s README.rst for more details.')
Beispiel #5
0
def reset_datastore_db():
    engine = get_write_engine()
    Session = orm.scoped_session(orm.sessionmaker(bind=engine))
    datastore_helpers.clear_db(Session)
def Session():
    engine = get_write_engine()
    Session = orm.scoped_session(orm.sessionmaker(bind=engine))
    yield Session
    Session.close()
Beispiel #7
0
 def get_datastore_engine_and_connection(cls):
     if '_datastore' not in dir(cls):
         engine = get_write_engine()
         conn = engine.connect()
         cls._datastore = (engine, conn)
     return cls._datastore
Beispiel #8
0
 def setup(self):
     engine = get_write_engine()
     self.Session = orm.scoped_session(orm.sessionmaker(bind=engine))
     helpers.reset_db()
     util.reset_datastore_db()
     util.add_full_text_trigger_function()
 def setup(self):
     engine = get_write_engine()
     self.Session = orm.scoped_session(orm.sessionmaker(bind=engine))
     helpers.reset_db()
     util.reset_datastore_db()