Beispiel #1
0
def syncdb():
    from pymongo import MongoClient
    db = MongoClient(host=settings.MONGO_DB['host'],
                     port=settings.MONGO_DB['port']
                     )[settings.MONGO_DB['db_name']]

    models = import_models()
    for k, model in models.items():
        if hasattr(model, 'NEED_SYNC'):
            collection = model.MONGO_COLLECTION
            # db.drop_collection(collection)
            for index in model.INDEXES:
                i_name = index.pop('name')
                db[collection].create_index(i_name, **index)
            if settings.AUTH_USER_COLLECTION == collection:
                su = raw_input("Superuser doesn't exist. Do you"
                               " want to create it? (y/n)\n")
                if str(su) == "y":
                    create_superuser(db[collection])
Beispiel #2
0
def syncdb():
    from pymongo import MongoClient
    db = MongoClient(
        host=settings.MONGO_DB['host'],
        port=settings.MONGO_DB['port'])[settings.MONGO_DB['db_name']]

    models = import_models()
    for k, model in models.items():
        if hasattr(model, 'NEED_SYNC'):
            collection = model.MONGO_COLLECTION
            # db.drop_collection(collection)
            for index in model.INDEXES:
                i_name = index.pop('name')
                db[collection].create_index(i_name, **index)
            if settings.AUTH_USER_COLLECTION == collection:
                su = raw_input("Superuser doesn't exist. Do you"
                               " want to create it? (y/n)\n")
                if str(su) == "y":
                    create_superuser(db[collection])
Beispiel #3
0
    def __init__(self, *args, **kwargs):
        # Init jiaja2 environment
        self.jinja_env = settings.JINJA_ENV
        # Register filters for jinja2
        self.jinja_env.filters.update(filters.register_filters())
        self.jinja_env.tests.update({})
        self.jinja_env.globals['settings'] = settings.APP_SETTINGS
        handlers = route.get_routes()

        # Register mongo db
        self.db = connect_mongo(settings.MONGO_DB, **kwargs)

        # compress css and js
        self.assets = lambda x: settings.ASSETS[x].urls()[0]

        # registr admin list
        self.admin_apps = get_admin_apps()

        # registr models
        self.models = import_models()

        tornado.web.Application.__init__(
            self, handlers, *args, **dict(settings.APP_SETTINGS, **kwargs))
Beispiel #4
0
    def __init__(self, *args, **kwargs):
        # Init jiaja2 environment
        self.jinja_env = settings.JINJA_ENV
        # Register filters for jinja2
        self.jinja_env.filters.update(filters.register_filters())
        self.jinja_env.tests.update({})
        self.jinja_env.globals['settings'] = settings.APP_SETTINGS
        handlers = route.get_routes()

        # Register mongo db
        self.db = connect_mongo(settings.MONGO_DB, **kwargs)

        # compress css and js
        self.assets = lambda x: settings.ASSETS[x].urls()[0]

        # registr admin list
        self.admin_apps = get_admin_apps()

        # registr models
        self.models = import_models()

        tornado.web.Application.__init__(
            self, handlers, *args, **dict(settings.APP_SETTINGS, **kwargs))