From b1b92284f496800a4dfd2cea72cb9be07ba8661c Mon Sep 17 00:00:00 2001 From: Paul Everitt Date: Fri, 13 Sep 2013 16:52:14 -0400 Subject: First cut at import of quick tutorial. --- .../quick_tutorial/templating/tutorial/__init__.py | 9 +++++ docs/quick_tutorial/templating/tutorial/home.pt | 9 +++++ docs/quick_tutorial/templating/tutorial/tests.py | 44 ++++++++++++++++++++++ docs/quick_tutorial/templating/tutorial/views.py | 13 +++++++ 4 files changed, 75 insertions(+) create mode 100644 docs/quick_tutorial/templating/tutorial/__init__.py create mode 100644 docs/quick_tutorial/templating/tutorial/home.pt create mode 100644 docs/quick_tutorial/templating/tutorial/tests.py create mode 100644 docs/quick_tutorial/templating/tutorial/views.py (limited to 'docs/quick_tutorial/templating/tutorial') diff --git a/docs/quick_tutorial/templating/tutorial/__init__.py b/docs/quick_tutorial/templating/tutorial/__init__.py new file mode 100644 index 000000000..013d4538f --- /dev/null +++ b/docs/quick_tutorial/templating/tutorial/__init__.py @@ -0,0 +1,9 @@ +from pyramid.config import Configurator + + +def main(global_config, **settings): + config = Configurator(settings=settings) + config.add_route('home', '/') + config.add_route('hello', '/howdy') + config.scan('.views') + return config.make_wsgi_app() \ No newline at end of file diff --git a/docs/quick_tutorial/templating/tutorial/home.pt b/docs/quick_tutorial/templating/tutorial/home.pt new file mode 100644 index 000000000..a0cc08e7a --- /dev/null +++ b/docs/quick_tutorial/templating/tutorial/home.pt @@ -0,0 +1,9 @@ + + + + Quick Tour: ${name} + + +

Hi ${name}

+ + \ No newline at end of file diff --git a/docs/quick_tutorial/templating/tutorial/tests.py b/docs/quick_tutorial/templating/tutorial/tests.py new file mode 100644 index 000000000..d06a62982 --- /dev/null +++ b/docs/quick_tutorial/templating/tutorial/tests.py @@ -0,0 +1,44 @@ +import unittest + +from pyramid import testing + + +class TutorialViewTests(unittest.TestCase): + def setUp(self): + self.config = testing.setUp() + + def tearDown(self): + testing.tearDown() + + def test_home(self): + from .views import home + + request = testing.DummyRequest() + response = home(request) + # Our view now returns data + self.assertEqual('Home View', response['name']) + + def test_hello(self): + from .views import hello + + request = testing.DummyRequest() + response = hello(request) + # Our view now returns data + self.assertEqual('Hello View', response['name']) + + +class TutorialFunctionalTests(unittest.TestCase): + def setUp(self): + from tutorial import main + app = main({}) + from webtest import TestApp + + self.testapp = TestApp(app) + + def test_home(self): + res = self.testapp.get('/', status=200) + self.assertIn(b'

Hi Home View', res.body) + + def test_hello(self): + res = self.testapp.get('/howdy', status=200) + self.assertIn(b'

Hi Hello View', res.body) diff --git a/docs/quick_tutorial/templating/tutorial/views.py b/docs/quick_tutorial/templating/tutorial/views.py new file mode 100644 index 000000000..979d69c43 --- /dev/null +++ b/docs/quick_tutorial/templating/tutorial/views.py @@ -0,0 +1,13 @@ +from pyramid.view import view_config + + +# First view, available at http://localhost:6543/ +@view_config(route_name='home', renderer='home.pt') +def home(request): + return {'name': 'Home View'} + + +# /howdy +@view_config(route_name='hello', renderer='home.pt') +def hello(request): + return {'name': 'Hello View'} -- cgit v1.2.3 From 34e974e360184baef873da55f31379697e367f32 Mon Sep 17 00:00:00 2001 From: Paul Everitt Date: Wed, 25 Sep 2013 12:08:33 -0400 Subject: Get pyramid_chameleon added to the quick tutorial, plus some other fixes for Python 3. --- docs/quick_tutorial/templating/tutorial/__init__.py | 1 + 1 file changed, 1 insertion(+) (limited to 'docs/quick_tutorial/templating/tutorial') diff --git a/docs/quick_tutorial/templating/tutorial/__init__.py b/docs/quick_tutorial/templating/tutorial/__init__.py index 013d4538f..c3e1c9eef 100644 --- a/docs/quick_tutorial/templating/tutorial/__init__.py +++ b/docs/quick_tutorial/templating/tutorial/__init__.py @@ -3,6 +3,7 @@ from pyramid.config import Configurator def main(global_config, **settings): config = Configurator(settings=settings) + config.include('pyramid_chameleon') config.add_route('home', '/') config.add_route('hello', '/howdy') config.scan('.views') -- cgit v1.2.3 From 0c78388845bd4a020b924c7689f88168531427a7 Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Thu, 21 May 2015 00:24:47 -0700 Subject: - correct title tag - grammar --- docs/quick_tutorial/templating/tutorial/home.pt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'docs/quick_tutorial/templating/tutorial') diff --git a/docs/quick_tutorial/templating/tutorial/home.pt b/docs/quick_tutorial/templating/tutorial/home.pt index a0cc08e7a..fd4ef8764 100644 --- a/docs/quick_tutorial/templating/tutorial/home.pt +++ b/docs/quick_tutorial/templating/tutorial/home.pt @@ -1,9 +1,9 @@ - Quick Tour: ${name} + Quick Tutorial: ${name}

Hi ${name}

- \ No newline at end of file + -- cgit v1.2.3