#-*- coding:utf-8 -*-

from __future__ import division
from __future__ import absolute_import
from __future__ import with_statement
from __future__ import print_function
from __future__ import unicode_literals

from logbook import Logger, NestedSetup
from flask import Flask
from flaskext.genshi import Genshi
from flaskext.zodb import ZODB, PersistentMapping


logger = Logger(__name__)
genshi = Genshi()
db = ZODB()


@db.init
def set_defaults(root):
    if 'languages' not in root:
        root['languages'] = PersistentMapping({'eng': 'English',
                                               'jbo': 'Lojban'})


def create_app(config=None):

    app = Flask(__name__)

    app.config.from_object('stutuz.configs')
    if config is not None:
        app.config.from_object(config)
    app.config.from_envvar('STUTUZ_CONFIG', silent=True)

    handlers = app.config.get('LOGBOOK_HANDLERS')
    with NestedSetup(handlers):
        for extension in genshi, db:
            extension.init_app(app)

        for middleware in app.config.get('MIDDLEWARES', ()):
            app.wsgi_app = middleware(app.wsgi_app)

        return app

@@ -354,16 +354,49 @@
 apping%0A%0A
+from stutuz.models import Users%0A%0A
 %0Alogger 
@@ -641,16 +641,76 @@
 jban'%7D)%0A
+    if 'users' not in root:%0A        root%5B'users'%5D = Users()%0A
 %0A%0Adef cr

Make a default empty users list