Exemple #1
0
def configured_engine ():
    """Build a configured SQLAlchemy engine."""
    try:
        uri = config.get("main", "database")
    except ConfigParser.Error:
        engine = None
    else:
        try:
            engine = create_engine(uri)
        except (ImportError, ArgumentError), ex:
            warnings.warn(
                "invalid database: %s (%s)" % (uri, ex), UserWarning)
            engine = None
Exemple #2
0
def configured_upstream ():
    """Import the configured upstream module."""
    try:
        module_name = config.get("upstream", "module")
    except ConfigParser.Error:
        module = None
    else:
        try:
            module = __import__(module_name, locals(), globals(), [
                "user_in", "user_out",
                "project_in", "project_out",
                "resource_in", "resource_out",
                "project_member", "project_manager"])
        except ImportError:
            warnings.warn(
                "invalid upstream module: %s" % (module_name), UserWarning)
            module = None
    return module