def _create_api(self, opts, args): """Create an API, as requested by the command.""" options = {} options['documentroot'] = opts.docroot options['configfile'] = opts.cfgfile options['logfile'] = opts.logfile options = init_options(options) init_logger(options) init_codecs(options) api = API() if 'options' in self.require_api: api.options = options if 'logger' in self.require_api: api.logger = logging.getLogger('draco2.site') if 'config' in self.require_api: api.config = Config._create(api) if 'loader' in self.require_api: api.loader = Loader._create(api) if 'events' in self.require_api: api.events = EventManager._create(api) if 'database' in self.require_api: api.database = DatabaseManager._create(api) if opts.dsn: api.database._set_dsn(dsn) if 'models' in self.require_api: api.models = ModelManager._create(api) return api
# together with this file for the exact licensing terms. # # Draco2 is copyright (c) 1999-2007 by the Draco2 authors. See the file # "AUTHORS" for a complete overview. # # $Revision: 1187 $ import os import string import random from draco2.core.config import Config from draco2.core.api import API from draco2.database import DatabaseManager api = API() api.config = Config() api.config.add_file(os.environ['TESTCONFIG']) database = DatabaseManager._create(api) class DatabaseTest(object): """Base class for database tests.""" def setup_method(self, method): self.database = database self.dialect = self.database.dialect() self.dbapi = self.database.dbapi() self.connection = self.database.connection() self.cursor = self.connection.cursor()