コード例 #1
0
ファイル: __init__.py プロジェクト: nolifelover/pumbaa
def main(global_config, **settings):
    authn_policy = AuthTktAuthenticationPolicy(settings.get('pumbaa.secret'), callback=group_finder)
    authz_policy = ACLAuthorizationPolicy()
    pumbaa_session_factory = session_factory_from_settings(settings)
    
    config = Configurator(settings=settings, 
                          root_factory='pumbaa.acl.RootFactory',
                          authentication_policy=authn_policy, 
                          authorization_policy=authz_policy,
                          session_factory = pumbaa_session_factory)

    models.initial(settings)
    
    config.include('velruse.providers.facebook')
    config.add_facebook_login_from_settings(prefix='velruse.facebook.')
    config.include('velruse.providers.google_oauth2')
    config.add_google_oauth2_login_from_settings(prefix='velruse.google.')
    config.include('velruse.providers.twitter')
    config.add_twitter_login_from_settings(prefix='velruse.twitter.')
    
    add_routes(config)
    config.scan('pumbaa.views')
    
    from .request_factory import RequestWithUserAttribute
    config.set_request_factory(RequestWithUserAttribute)

    return config.make_wsgi_app()
コード例 #2
0
ファイル: __init__.py プロジェクト: yashmit178/pumbaa
def main(global_config, **settings):
    authn_policy = AuthTktAuthenticationPolicy(settings.get('pumbaa.secret'),
                                               callback=group_finder,
                                               hashalg='sha512')
    authz_policy = ACLAuthorizationPolicy()
    pumbaa_session_factory = session_factory_from_settings(settings)

    config = Configurator(settings=settings,
                          root_factory='pumbaa.acl.RootFactory',
                          authentication_policy=authn_policy,
                          authorization_policy=authz_policy,
                          session_factory=pumbaa_session_factory)

    models.initial(settings)

    config.include('velruse.providers.facebook')
    config.add_facebook_login_from_settings(prefix='velruse.facebook.')
    config.include('velruse.providers.google_oauth2')
    config.add_google_oauth2_login_from_settings(prefix='velruse.google.')
    config.include('velruse.providers.twitter')
    config.add_twitter_login_from_settings(prefix='velruse.twitter.')

    add_routes(config)
    config.scan('pumbaa.views')

    from .request_factory import RequestWithUserAttribute
    config.set_request_factory(RequestWithUserAttribute)

    return config.make_wsgi_app()
コード例 #3
0
    def setUp(self):
        self.config = testing.setUp()

        cfg = configparser.ConfigParser()
        cfg.read('../../test.ini')
        settings = dict(cfg.items('app:main'))

        from pumbaa import models
        models.initial(settings)
コード例 #4
0
ファイル: welcome_page_test.py プロジェクト: sdayu/pumbaa
    def setUp(self):
        self.config = testing.setUp()
        
        cfg = configparser.ConfigParser()
        cfg.read('../../test.ini')
        settings = dict(cfg.items('app:main'))

        from pumbaa import models
        models.initial(settings)
コード例 #5
0
ファイル: profile_page_test.py プロジェクト: sdayu/pumbaa
    def setUp(self):
        self.config = testing.setUp()
        
        cfg = configparser.ConfigParser()
        cfg.read('../../test.ini')
        settings = dict(cfg.items('app:main'))

        from pumbaa import models
        models.initial(settings)

        from pumbaa.models import users
        #create user
        self.user = users.User()
        self.user.username = "******"
        self.user.password = "******"
        self.user.email = "*****@*****.**"
        self.user.display_name = "korn naja"
        self.user.last_name = "naja"
        self.user.first_name = "korn"
        self.user.save()
コード例 #6
0
    def setUp(self):
        self.config = testing.setUp()

        cfg = configparser.ConfigParser()
        cfg.read('../../test.ini')
        settings = dict(cfg.items('app:main'))

        from pumbaa import models
        models.initial(settings)

        from pumbaa.models import users
        #create user
        self.user = users.User()
        self.user.username = "******"
        self.user.password = "******"
        self.user.email = "*****@*****.**"
        self.user.display_name = "korn naja"
        self.user.last_name = "naja"
        self.user.first_name = "korn"
        self.user.save()
コード例 #7
0
def main(argv=sys.argv):
    if len(argv) < 2:
        usage(argv)
    config_uri = argv[1]
    options = parse_vars(argv[2:])
    setup_logging(config_uri)
    settings = get_appsettings(config_uri, options=options)

    models.initial(settings)

    role_names = [
        'admin', 'lecturer', 'staff', 'moderator', 'member', 'anonymous'
    ]

    for rname in role_names:
        role = models.Role.objects(name=rname).first()
        if not role:
            role = models.Role(name=rname)
            role.save()
            print('add role:', rname)

    adminuser = '******'
    adminpass = '******'

    admin = models.User.objects(username=adminuser).first()
    sm = crypto.SecretManager(settings.get('pumbaa.secret'))
    if admin is None:
        admin = models.User(username=adminuser)
        admin.first_name = 'Administrator'
        admin.last_name = 'CoE'
        admin.display_name = 'Administrator'
        admin.status = 'activate'
        admin.email = '*****@*****.**'
        admin.password = sm.get_hash_password(adminpass)
        admin.roles.append(models.Role.objects(name='admin').first())
        admin.save()

        print('add admin user:', adminuser)
コード例 #8
0
ファイル: initializedb.py プロジェクト: nolifelover/pumbaa
def main(argv=sys.argv):
    if len(argv) < 2:
        usage(argv)
    config_uri = argv[1]
    options = parse_vars(argv[2:])
    setup_logging(config_uri)
    settings = get_appsettings(config_uri, options=options)

    models.initial(settings)
    
    role_names = ['admin', 'lecturer', 'staff', 'moderator', 'member', 'anonymous']
    
    for rname in role_names:
        role = models.Role.objects(name=rname).first()
        if not role:
            role = models.Role(name=rname)
            role.save()
            print('add role:', rname)
            
    adminuser = '******'
    adminpass = '******'
    
    admin = models.User.objects(username=adminuser).first()
    sm = crypto.SecretManager(settings.get('pumbaa.secret'))
    if admin is None:
        admin = models.User(username=adminuser)
        admin.first_name = 'Administrator'
        admin.last_name = 'CoE'
        admin.display_name = 'Administrator'
        admin.status = 'activate'
        admin.email = '*****@*****.**'
        admin.password = sm.get_hash_password(adminpass)
        admin.roles.append(models.Role.objects(name='admin').first())
        admin.save()
        
        print('add admin user:', adminuser)