Ejemplo n.º 1
0
 def get_user(self, username):
     user = self.db_session.query(User).filter_by(username=username).first()
     if user is None:
         if 'userfinder' in self.req.registry['settings']:
             finder = self.req.registry['settings']['userfinder']
             if finder(username):
                 return create_user(username, session=self.db_session)
     return user
Ejemplo n.º 2
0
def add():
    arguments = addparser.parse_args()
    if not arguments.config or not arguments.username:
        addparser.print_usage()
    else:
        config_uri = arguments.config
        setup_logging(config_uri)
        settings = get_appsettings(config_uri)
        engine = engine_from_config(settings, 'sqlalchemy.')
        DBSession.configure(bind=engine)
        with transaction.manager:
            username = arguments.username
            user = create_user(username)
            print 'barcode url:', get_barcode_image(username, user.secret,
                settings['appname'])
            print 'secret:', user.secret
Ejemplo n.º 3
0
def add():
    arguments = addparser.parse_args()
    if not arguments.config or not arguments.username:
        addparser.print_usage()
    else:
        config_uri = arguments.config
        setup_logging(config_uri)
        try:
            settings = get_appsettings(config_uri, 'factored')
        except LookupError:
            settings = get_appsettings(config_uri, 'main')
        engine = engine_from_config(settings, 'sqlalchemy.')
        DBSession.configure(bind=engine)
        session = DBSession()
        username = arguments.username
        user = create_user(username, session)
        print 'barcode url:', get_barcode_image(username, user.secret,
                                                settings['appname'])
        print 'secret:', user.secret
        session.commit()
        session.close()
Ejemplo n.º 4
0
def add():
    arguments = addparser.parse_args()
    if not arguments.config or not arguments.username:
        addparser.print_usage()
    else:
        config_uri = arguments.config
        setup_logging(config_uri)
        try:
            settings = get_appsettings(config_uri, 'factored')
        except LookupError:
            settings = get_appsettings(config_uri, 'main')
        engine = engine_from_config(settings, 'sqlalchemy.')
        DBSession.configure(bind=engine)
        session = DBSession()
        username = arguments.username
        user = create_user(username, session)
        print('barcode url:',
              get_barcode_image(username, user.secret, settings['appname']))
        print('secret:', user.secret)
        session.commit()
        session.close()