示例#1
0
def _adduser(username, password, app=None):
    # using main_app if an app is not passed
    app = app or main_app

    # put the app in debug for logging purpose
    app.debug = True

    admin = User(username)
    admin.password = password
    try:
        admin.save(app)
        if not app.config['TESTING']:
            app.logger.info('User %s created' % username)
    except:
        if not app.config['TESTING']:
            app.logger.info('Unable to create the user %s' % username)

    # Deactivate the debug mode
    app.debug = False
示例#2
0
    def create_user(self, username, password, context_app=None):

        app = context_app or self.app
        user = User(username)
        user.password = password
        user.save(app)