Exemplo n.º 1
0
    def setUp(self):
        from pylons.configuration import Configurator
        from pylonshq.models import initialize_sql

        self.session = initialize_sql("sqlite://")
        self.config = Configurator()
        self.config.begin()
Exemplo n.º 2
0
class MyHandlerTests(unittest.TestCase):
    def setUp(self):
        from pylons.configuration import Configurator
        from pylonshq.models import initialize_sql

        self.session = initialize_sql("sqlite://")
        self.config = Configurator()
        self.config.begin()

    def tearDown(self):
        self.config.end()

    def _makeOne(self, request):
        from pylonshq.handlers import MyHandler

        return MyHandler(request)

    def test_index(self):
        request = DummyRequest()
        handler = self._makeOne(request)
        info = handler.index()
        self.assertEqual(info["project"], "pylonshq")
        self.assertEqual(info["root"].name, "root")
Exemplo n.º 3
0
def main(global_config, **settings):
    """ This function returns a Pylons WSGI application.
    """
    from paste.deploy.converters import asbool
    from pylons.configuration import Configurator
    from pylonshq.models import initialize_sql
    db_string = settings.get('db_string')
    if db_string is None:
        raise ValueError("No 'db_string' value in application "
                         "configuration.")
    initialize_sql(db_string, asbool(settings.get('db_echo')))
    config = Configurator(settings=settings)
    config.begin()
    config.add_cache()
    config.add_sessions()
    config.add_static_view(
        'static',
        'pylonshq:static/'
        )
    config.add_handler(
        'main',
        '/{action}',
        'pylonshq.handlers:MyHandler',
        )
    config.add_handler(
        'home',
        '/',
        'pylonshq.handlers:MyHandler',
        action='index'
        )
    config.end()
    return config.make_wsgi_app()