def __init__(self, configFile="/var/lib/databank/production.ini"):
     Config = ConfigParser.ConfigParser()
     Config.read("/var/lib/databank/production.ini")
     db_conn = Config.get("app:main", "sqlalchemy.url")
     self.root_dir = Config.get("app:main", "granary.store")
     engine = sa.create_engine(db_conn)
     model.init_model(engine)
def load_environment(global_conf, app_conf):
    """Configure the Pylons environment via the ``pylons.config``
    object
    """
    # Pylons paths
    root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    paths = dict(root=root,
                 controllers=os.path.join(root, 'controllers'),
                 static_files=os.path.join(root, 'public'),
                 templates=[os.path.join(root, 'templates')])

    engine = engine_from_config(app_conf, 'sqlalchemy.')
    init_model(engine)

    # Initialize config with the basic options
    config.init_app(global_conf, app_conf, package='rdfdatabank', paths=paths)

    config['routes.map'] = make_map()
    config['pylons.app_globals'] = app_globals.Globals()
    config['pylons.h'] = rdfdatabank.lib.helpers
    config [ 'pylons.response_options' ][ 'charset' ] = 'utf-8'
    config['pylons.strict_tmpl_context'] = False

    # Create the Mako TemplateLookup, with the default auto-escaping
    config['pylons.app_globals'].mako_lookup = TemplateLookup(
        directories=paths['templates'],
        error_handler=handle_mako_error,
        module_directory=os.path.join(app_conf['cache_dir'], 'templates'),
        input_encoding='utf-8', default_filters=['escape'],
        imports=['from webhelpers.html import escape'])
 def __init__(self, config_file='/var/lib/databank/production.ini'):
     if not os.path.exists(config_file):
         print "Config file not found"
         sys.exit()
     c = ConfigParser.ConfigParser()
     c.read(config_file)
     if not 'app:main' in c.sections():
         print "Section app:main not found in config file"
         sys.exit()
     engine = sa.create_engine(c.get('app:main', 'sqlalchemy.url'))
     init_model(engine)
     return
import sys, os

if __name__ == "__main__":
    #Initialize sqlalchemy
    f = '/var/lib/databank/production.ini' 
    if not os.path.exists(f):
        print "Config file not found"
        sys.exit()
    c = ConfigParser.ConfigParser()
    c.read(f)
    if not 'app:main' in c.sections():
        print "Section app:main not found in config file"
        sys.exit()

    engine = sa.create_engine(c.get('app:main', 'sqlalchemy.url'))
    init_model(engine)

    #add user
    username = sys.argv[1]
    password = sys.argv[2]
    email = sys.argv[3]
    user_details = {
        'username':u'%s'%username,
        'password':u"%s"%password,
        'name':u'Databank Administrator',
        'email':u"%s"%email
    }
    add_user(user_details)
    #Add user membership
    groups = []
    groups.append(('*', 'administrator'))