Esempio n. 1
0
def main(global_config, **settings):
    config = Configurator(settings=settings)
    config.include('pyramid_jinja2')
    config.scan()
    config.include('pyramid_sqlalchemy')
    metadata.create_all()
    config.add_static_view(name='deform_static', path='deform:static')
    config.add_static_view(name='static', path='mysite:static')
    config.add_route('home', '/')
    config.add_route('todos_list', '/todos')
    config.add_route('todos_add', '/todos/add')
    config.add_route('todos_view', '/todos/{id}')
    config.add_route('todos_edit', '/todos/{id}/edit')
    config.add_route('todos_delete', '/todos/{id}/delete')
    config.add_route('login', '/login')
    config.add_route('logout', '/logout')

    session_secret = settings['session.secret']
    session_factory = SignedCookieSessionFactory(session_secret)
    config.set_session_factory(session_factory)

    # Security policies
    authn_policy = AuthTktAuthenticationPolicy(settings['auth.secret'],
                                               callback=groupfinder,
                                               hashalg='sha512')
    authz_policy = ACLAuthorizationPolicy()
    config.set_authentication_policy(authn_policy)
    config.set_authorization_policy(authz_policy)

    return config.make_wsgi_app()
Esempio n. 2
0
 def setUp(self):
     self.db_uri = get_test_db_uri()
     self.db_context = sqlalchemy_setup(self.db_uri)
     self.config = testing.setUp()
     self.config.include('yithlibraryserver.password')
     self.config.include('yithlibraryserver.user')
     metadata.create_all()
Esempio n. 3
0
 def setUp(self):
     self.db_uri = get_test_db_uri()
     self.db_context = sqlalchemy_setup(self.db_uri)
     self.config = testing.setUp()
     self.config.include('yithlibraryserver.password')
     self.config.include('yithlibraryserver.user')
     metadata.create_all()
Esempio n. 4
0
def main(global_config, **settings):
    config = Configurator(settings=settings)
    config.include('pyramid_jinja2')
    config.scan()
    config.include('pyramid_sqlalchemy')
    metadata.create_all()
    config.add_static_view(name='deform_static', path='deform:static')
    config.add_static_view(name='static', path='mysite:static')
    config.add_route('home', '/')
    config.add_route('todos_list', '/todos')
    config.add_route('todos_add', '/todos/add')
    config.add_route('todos_view', '/todos/{id}')
    config.add_route('todos_edit', '/todos/{id}/edit')
    config.add_route('todos_delete', '/todos/{id}/delete')

    # obtem secret definido em arquido de configuracao
    session_secret = settings['session.secret']
    # instancia a session_factory do pyeamid
    # atencao session_factory do pyramid nao é para producao
    # os dados nao sao criptografados
    # usa-se em desenvolvimento mas nao em producao
    session_factory = SignedCookieSessionFactory(session_secret)
    config.set_session_factory(session_factory)

    return config.make_wsgi_app()
Esempio n. 5
0
    def setUp(self):
        super(TestCase, self).setUp()

        self.db_context = sqlalchemy_setup(self.db_uri)

        settings = {
            'database_url': self.db_uri,
            'auth_tk_secret': '123456',
            'redis.sessions.secret': '123456',
            'redis.sessions.url': 'redis://127.0.0.1:6379/0',
            'twitter_consumer_key': 'key',
            'twitter_consumer_secret': 'secret',
            'facebook_app_id': 'id',
            'facebook_app_secret': 'secret',
            'google_client_id': 'id',
            'google_client_secret': 'secret',
            'liveconnect_client_id': 'id',
            'liveconnect_client_secret': 'secret',
            'paypal_user': '******',
            'paypal_password': '******',
            'paypal_signature': 'A-IzJhZZjhg29XQ2qnhapuwxIDzyAZQ92FRP5dqBzVesOkzbdUONzmOU',
            'testing': 'True',
            'pyramid_mailer.prefix': 'mail_',
            'mail_default_sender': '*****@*****.**',
            'admin_emails': '[email protected] [email protected]',
            'public_url_root': 'http://localhost:6543/',
            'webassets.debug': 'True',
        }
        app = main({}, **settings)
        self.testapp = TestApp(app)

        metadata.create_all()
Esempio n. 6
0
    def setUp(self):
        super(TestCase, self).setUp()

        self.db_context = sqlalchemy_setup(self.db_uri)

        settings = {
            "database_url": self.db_uri,
            "auth_tk_secret": "123456",
            "redis.sessions.secret": "123456",
            "redis.sessions.url": "redis://127.0.0.1:6379/0",
            "twitter_consumer_key": "key",
            "twitter_consumer_secret": "secret",
            "facebook_app_id": "id",
            "facebook_app_secret": "secret",
            "google_client_id": "id",
            "google_client_secret": "secret",
            "liveconnect_client_id": "id",
            "liveconnect_client_secret": "secret",
            "paypal_user": "******",
            "paypal_password": "******",
            "paypal_signature": "A-IzJhZZjhg29XQ2qnhapuwxIDzyAZQ92FRP5dqBzVesOkzbdUONzmOU",
            "testing": "True",
            "pyramid_mailer.prefix": "mail_",
            "mail_default_sender": "*****@*****.**",
            "admin_emails": "[email protected] [email protected]",
            "public_url_root": "http://localhost:6543/",
            "webassets.debug": "True",
        }
        app = main({}, **settings)
        self.testapp = TestApp(app)

        metadata.create_all()
Esempio n. 7
0
    def setUp(self):
        super(TestCase, self).setUp()

        self.db_context = sqlalchemy_setup(self.db_uri)

        settings = {
            'database_url': self.db_uri,
            'auth_tk_secret': '123456',
            'redis.sessions.secret': '123456',
            'redis.sessions.url': 'redis://127.0.0.1:6379/0',
            'twitter_consumer_key': 'key',
            'twitter_consumer_secret': 'secret',
            'facebook_app_id': 'id',
            'facebook_app_secret': 'secret',
            'google_client_id': 'id',
            'google_client_secret': 'secret',
            'liveconnect_client_id': 'id',
            'liveconnect_client_secret': 'secret',
            'paypal_user': '******',
            'paypal_password': '******',
            'paypal_signature':
            'A-IzJhZZjhg29XQ2qnhapuwxIDzyAZQ92FRP5dqBzVesOkzbdUONzmOU',
            'testing': 'True',
            'pyramid_mailer.prefix': 'mail_',
            'mail_default_sender': '*****@*****.**',
            'admin_emails': '[email protected] [email protected]',
            'public_url_root': 'http://localhost:6543/',
            'webassets.debug': 'True',
        }
        app = main({}, **settings)
        self.testapp = TestApp(app)

        metadata.create_all()
Esempio n. 8
0
    def setUp(self):
        fd, self.conf_file_path = tempfile.mkstemp()
        os.write(fd, CONFIG.encode('ascii'))
        if self.use_db:
            self.db_uri = get_test_db_uri()
            self.db_context = sqlalchemy_setup(self.db_uri)

            metadata.create_all()
Esempio n. 9
0
    def setUp(self):
        self.db_uri = get_test_db_uri()
        self.db_context = sqlalchemy_setup(self.db_uri)

        self.config = testing.setUp()
        self.config.include('pyramid_mailer.testing')
        self.config.include('pyramid_chameleon')
        self.config.include('yithlibraryserver.user')

        metadata.create_all()
    def setUp(self):
        self.db_uri = get_test_db_uri()
        self.db_context = sqlalchemy_setup(self.db_uri)

        self.config = testing.setUp()
        self.config.include('pyramid_mailer.testing')
        self.config.include('pyramid_chameleon')
        self.config.include('yithlibraryserver.user')

        metadata.create_all()
Esempio n. 11
0
 def setUp(self):
     self.engine = create_engine(self.db_uri)
     if self.engine.dialect.name == 'sqlite':
         self.engine.execute('PRAGMA foreign_keys = ON')
     init_sqlalchemy(self.engine)
     if self.create_tables:
         metadata.create_all()
     super(DatabaseTestCase, self).setUp()
     self._sqlalchemy_patcher = mock.patch('pyramid_sqlalchemy.includeme')
     self._sqlalchemy_patcher.start()
Esempio n. 12
0
    def setUp(self):
        self.db_uri = get_test_db_uri()
        self.db_context = sqlalchemy_setup(self.db_uri)

        self.config = testing.setUp()
        self.config.include('yithlibraryserver')
        self.config.include('yithlibraryserver.user')

        metadata.create_all()

        self.request = testing.DummyRequest()
        self.request.session = {}
Esempio n. 13
0
def main(global_config, **settings):
    # Settings

    config = Configurator(settings=settings)

    config.include('.routes')
    config.include('.models')
    config.scan()
    config.include('pyramid_sqlalchemy')
    metadata.create_all()

    return config.make_wsgi_app()
    def setUp(self):
        self.db_uri = get_test_db_uri()
        self.db_context = sqlalchemy_setup(self.db_uri)

        self.config = testing.setUp()
        self.config.include('yithlibraryserver')
        self.config.include('yithlibraryserver.user')

        metadata.create_all()

        self.request = testing.DummyRequest()
        self.request.session = {}
Esempio n. 15
0
def main(global_config, **settings):
    config = Configurator(settings=settings)
    config.include('pyramid_sqlalchemy')
    config.add_route('todos', '/api/todos')
    config.add_route('todo', '/api/todos/{id}', factory='.models.todo_factory')
    config.scan()
    metadata.create_all()

    # Statically serve app directory at the "/" URL
    config.add_static_view(name='/', path='mysite:app')
    config.add_route('app_html', '/')

    return config.make_wsgi_app()
Esempio n. 16
0
def main(global_config, **settings):
    config = Configurator(settings=settings)
    config.include('pyramid_jinja2')
    config.scan()
    config.include('pyramid_sqlalchemy')
    metadata.create_all()
    config.add_static_view(name='deform_static', path='deform:static')
    config.add_static_view(name='static', path='mysite:static')
    config.add_route('home', '/')
    config.add_route('todos_list', '/todos')
    config.add_route('todos_add', '/todos/add')
    config.add_route('todos_view', '/todos/{id}')
    config.add_route('todos_edit', '/todos/{id}/edit')
    config.add_route('todos_delete', '/todos/{id}/delete')
    return config.make_wsgi_app()
Esempio n. 17
0
def main(global_config, **settings):
    config = Configurator(settings=settings, root_factory=RootFactory)

    # adiciona metodos cross origin resource sharing (CORS)
    config.add_directive('add_cors_preflight_handler',
                         add_cors_preflight_handler)
    config.add_route_predicate('cors_preflight', CorsPreflightPredicate)
    config.add_subscriber(add_cors_to_response, 'pyramid.events.NewResponse')
    config.add_cors_preflight_handler()

    # inclui dependencias
    config.include('pyramid_jinja2')
    config.include('pyramid_chameleon')
    config.include('pyramid_sqlalchemy')

    # escaneia views
    config.scan()

    # cria metadados de persistencia
    metadata.create_all()

    # adiciona rodas estaticas
    # config.add_static_view(name='static', path='zapizza.site:static')

    # todo: levar rotas para dentro de seus módulos

    # registro
    config.add_route('signup', '/signup')
    config.add_route('confirm', '/confirm')

    # login/logout
    config.add_route('login', '/login')
    config.add_route('logout', '/logout')
    config.add_route('authenticated', '/authenticated')

    # esqueci a senha
    config.add_route('pass_forgot', '/forgot')
    config.add_route('pass_reset', '/reset')

    # /user
    config.add_route('users_profile',
                     '/user/{username}/profile',
                     factory='.users.models.user_factory')

    # /tamanhos
    config.add_route('tamanhos',
                     '/tamanhos',
                     factory='.pizzas.tamanhos.models.tamanho_factory')
    config.add_route('tamanhos_edit',
                     '/tamanhos/{hashid}',
                     factory='.pizzas.tamanhos.models.tamanho_factory')
    config.add_route('tamanhos_enable',
                     '/tamanhos/{hashid}/enable',
                     factory='.pizzas.tamanhos.models.tamanho_factory')

    # /sabores
    config.add_route('sabores',
                     '/sabores',
                     factory='.pizzas.sabores.models.sabor_factory')
    config.add_route('sabores_edit',
                     '/sabores/{hashid}',
                     factory='.pizzas.sabores.models.sabor_factory')
    config.add_route('sabores_enable',
                     '/sabores/{hashid}/enable',
                     factory='.pizzas.sabores.models.sabor_factory')

    # /bordas
    config.add_route('bordas',
                     '/bordas',
                     factory='.pizzas.bordas.models.borda_factory')
    config.add_route('bordas_edit',
                     '/bordas/{hashid}',
                     factory='.pizzas.bordas.models.borda_factory')
    config.add_route('bordas_enable',
                     '/bordas/{hashid}/enable',
                     factory='.pizzas.bordas.models.borda_factory')

    # /adicionais
    config.add_route('adicionais',
                     '/adicionais',
                     factory='.adicionais.models.adicional_factory')
    config.add_route('adicionais_edit',
                     '/adicionais/{hashid}',
                     factory='.adicionais.models.adicional_factory')
    config.add_route('adicionais_enable',
                     '/adicionais/{hashid}/enable',
                     factory='.adicionais.models.adicional_factory')

    # /clientes
    config.add_route('clientes',
                     '/clientes',
                     factory='.clientes.models.cliente_factory')
    config.add_route('clientes_edit',
                     '/clientes/{hashid}',
                     factory='.clientes.models.cliente_factory')
    config.add_route('clientes_enable',
                     '/clientes/{hashid}/enable',
                     factory='.clientes.models.cliente_factory')

    # /clientes/enderecos
    config.add_route('enderecos',
                     '/clientes/{cliHashid}/enderecos',
                     factory='.clientes.enderecos.models.endereco_factory')
    config.add_route('enderecos_edit',
                     '/clientes/{cliHashid}/enderecos/{endHashid}',
                     factory='.clientes.enderecos.models.endereco_factory')

    # /clientes/telefones
    config.add_route('telefones',
                     '/clientes/{cliHashid}/telefones',
                     factory='.clientes.telefones.models.telefone_factory')
    config.add_route('telefones_edit',
                     '/clientes/{cliHashid}/telefones/{telHashid}',
                     factory='.clientes.telefones.models.telefone_factory')

    # /pedidos
    config.add_route('pedidos',
                     '/pedidos',
                     factory='.pedidos.models.pedido_factory')
    config.add_route('pedidos_edit',
                     '/pedidos/{hashid}',
                     factory='.pedidos.models.pedido_factory')
    config.add_route('pedidos_enable',
                     '/pedidos/{hashid}/enable',
                     factory='.pedidos.models.pedido_factory')

    # Factory da sessao
    session_secret = settings['session.secret']
    session_factory = SignedCookieSessionFactory(session_secret)
    config.set_session_factory(session_factory)

    # Politicas de segurança
    authn_policy = AuthTktAuthenticationPolicy(settings['auth.secret'],
                                               callback=groupfinder,
                                               hashalg='sha512')
    authz_policy = ACLAuthorizationPolicy()
    config.set_authentication_policy(authn_policy)
    config.set_authorization_policy(authz_policy)

    # Objeto User disponivel como um atributo de Request
    config.add_request_method(get_user, 'user', reify=True)

    # cria aplicacao
    return config.make_wsgi_app()
Esempio n. 18
0
def add_missing_entities(environment):  # pragma: no cover
    engine = environment['sql-engine']
    metadata.create_all(engine)
Esempio n. 19
0
 def flush(self, auth=None):
     """Remove **every** object from this storage.
     """
     metadata.drop_all()
     metadata.create_all()
Esempio n. 20
0
 def test_already_in_desired_situation(self):
     from pyramid_sqlalchemy import metadata
     import s4u.image.model
     s4u.image.model  # Hello PyFlakes
     metadata.create_all(self.engine)
     self.add_url_column({'sql-engine': self.engine, 'alembic': None})
Esempio n. 21
0
 def flush(self, auth=None):
     """Remove **every** object from this storage.
     """
     metadata.drop_all()
     metadata.create_all()