Ejemplo n.º 1
0
def bootstrap():
    """Example function for loading bootstrap data into the database

    You can adapt this to your needs to e.g. accept more options or to
    run more functions for bootstrapping other parts of your application.
    By default this runs the function 'rmidb2.model.bootstrap_model', which
    creates all database tables and optionally adds a user.

    The following line in your project's 'setup.py' file takes care of
    installing a command line script when you install your application via
    easy_install which will run this function:

        'bootstrap-rmidb2 = rmidb2.command:bootstrap',

    """

    optparser = optparse.OptionParser(usage="%prog [options] [config-file]",
        description="Load bootstrap data into the database defined in "
        "config-file.", version="rmidb2 %s" % version)
    optparser.add_option('-C', '--clean', dest="clean", action="store_true",
        help="Purge all data in the database before loading the bootrap data.")
    optparser.add_option('-u', '--user', dest="user", metavar="USERNAME",
        help="Create a default user USERNAME (prompts for password).")
    options, args = optparser.parse_args()
    user = getattr(options, 'user', None)
    if user:
        options.user = user.decode(sys.getfilesystemencoding())
    _read_config(args)
    from rmidb2.model import bootstrap_model
    bootstrap_model(options.clean, options.user)
Ejemplo n.º 2
0
import sys

import turbogears
from rmidb2 import model
turbogears.update_config(configfile="dev.cfg", 
                         modulename="rmidb2.config")
model.bootstrap_model()
model.create_default_users()