summaryrefslogtreecommitdiff
path: root/docs/quick_tour/package/hello_world
diff options
context:
space:
mode:
authorSteve Piercy <web@stevepiercy.com>2016-12-25 02:17:19 -0800
committerSteve Piercy <web@stevepiercy.com>2016-12-25 02:17:19 -0800
commit54d9ddcd335d45662ca2ec2839574085318e8704 (patch)
treec037abd5eb3d2f4c849b975c641e8575c01bd650 /docs/quick_tour/package/hello_world
parent2cd1eab15a3777cbc81c2d365f21a98c29c9ed86 (diff)
downloadpyramid-54d9ddcd335d45662ca2ec2839574085318e8704.tar.gz
pyramid-54d9ddcd335d45662ca2ec2839574085318e8704.tar.bz2
pyramid-54d9ddcd335d45662ca2ec2839574085318e8704.zip
quick_tour - Configuration with ``.ini`` files section cookiecutter updates
- src files - update numbered list for new listen configuration for waitress - fix reference to app, not server - reorder numbered list to align with configuration order
Diffstat (limited to 'docs/quick_tour/package/hello_world')
-rw-r--r--docs/quick_tour/package/hello_world/__init__.py24
-rw-r--r--docs/quick_tour/package/hello_world/locale/de/LC_MESSAGES/hello_world.mobin460 -> 0 bytes
-rw-r--r--docs/quick_tour/package/hello_world/locale/de/LC_MESSAGES/hello_world.po21
-rw-r--r--docs/quick_tour/package/hello_world/locale/fr/LC_MESSAGES/hello_world.mobin461 -> 0 bytes
-rw-r--r--docs/quick_tour/package/hello_world/locale/fr/LC_MESSAGES/hello_world.po21
-rw-r--r--docs/quick_tour/package/hello_world/locale/hello_world.pot21
-rw-r--r--docs/quick_tour/package/hello_world/resources.py8
-rw-r--r--docs/quick_tour/package/hello_world/static/favicon.icobin1406 -> 0 bytes
-rw-r--r--docs/quick_tour/package/hello_world/static/theme.css9
-rw-r--r--docs/quick_tour/package/hello_world/templates/layout.jinja264
-rw-r--r--docs/quick_tour/package/hello_world/templates/mytemplate.jinja280
-rw-r--r--docs/quick_tour/package/hello_world/tests.py27
-rw-r--r--docs/quick_tour/package/hello_world/views.py14
13 files changed, 102 insertions, 187 deletions
diff --git a/docs/quick_tour/package/hello_world/__init__.py b/docs/quick_tour/package/hello_world/__init__.py
index 97f93d5a8..49dde36d4 100644
--- a/docs/quick_tour/package/hello_world/__init__.py
+++ b/docs/quick_tour/package/hello_world/__init__.py
@@ -1,26 +1,12 @@
from pyramid.config import Configurator
-from hello_world.resources import get_root
-from pyramid.session import SignedCookieSessionFactory
def main(global_config, **settings):
- """ This function returns a WSGI application.
-
- It is usually called by the PasteDeploy framework during
- ``paster serve``.
+ """ This function returns a Pyramid WSGI application.
"""
- settings = dict(settings)
- settings.setdefault('jinja2.i18n.domain', 'hello_world')
-
- my_session_factory = SignedCookieSessionFactory('itsaseekreet')
- config = Configurator(root_factory=get_root, settings=settings,
- session_factory=my_session_factory)
- config.add_translation_dirs('locale/')
+ config = Configurator(settings=settings)
config.include('pyramid_jinja2')
-
- config.add_static_view('static', 'static')
- config.add_view('hello_world.views.my_view',
- context='hello_world.resources.MyResource',
- renderer="templates/mytemplate.jinja2")
-
+ config.add_static_view('static', 'static', cache_max_age=3600)
+ config.add_route('home', '/')
+ config.scan()
return config.make_wsgi_app()
diff --git a/docs/quick_tour/package/hello_world/locale/de/LC_MESSAGES/hello_world.mo b/docs/quick_tour/package/hello_world/locale/de/LC_MESSAGES/hello_world.mo
deleted file mode 100644
index 40bf0c271..000000000
--- a/docs/quick_tour/package/hello_world/locale/de/LC_MESSAGES/hello_world.mo
+++ /dev/null
Binary files differ
diff --git a/docs/quick_tour/package/hello_world/locale/de/LC_MESSAGES/hello_world.po b/docs/quick_tour/package/hello_world/locale/de/LC_MESSAGES/hello_world.po
deleted file mode 100644
index 0df243dba..000000000
--- a/docs/quick_tour/package/hello_world/locale/de/LC_MESSAGES/hello_world.po
+++ /dev/null
@@ -1,21 +0,0 @@
-# Translations template for PROJECT.
-# Copyright (C) 2011 ORGANIZATION
-# This file is distributed under the same license as the PROJECT project.
-# FIRST AUTHOR <EMAIL@ADDRESS>, 2011.
-#
-#, fuzzy
-msgid ""
-msgstr ""
-"Project-Id-Version: PROJECT VERSION\n"
-"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
-"POT-Creation-Date: 2011-05-12 09:14-0330\n"
-"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
-"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
-"Language-Team: LANGUAGE <LL@li.org>\n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=utf-8\n"
-"Content-Transfer-Encoding: 8bit\n"
-"Generated-By: Babel 0.9.6\n"
-
-msgid "Hello!"
-msgstr "Hallo!"
diff --git a/docs/quick_tour/package/hello_world/locale/fr/LC_MESSAGES/hello_world.mo b/docs/quick_tour/package/hello_world/locale/fr/LC_MESSAGES/hello_world.mo
deleted file mode 100644
index 4fc438bfe..000000000
--- a/docs/quick_tour/package/hello_world/locale/fr/LC_MESSAGES/hello_world.mo
+++ /dev/null
Binary files differ
diff --git a/docs/quick_tour/package/hello_world/locale/fr/LC_MESSAGES/hello_world.po b/docs/quick_tour/package/hello_world/locale/fr/LC_MESSAGES/hello_world.po
deleted file mode 100644
index dc0aae5d7..000000000
--- a/docs/quick_tour/package/hello_world/locale/fr/LC_MESSAGES/hello_world.po
+++ /dev/null
@@ -1,21 +0,0 @@
-# Translations template for PROJECT.
-# Copyright (C) 2011 ORGANIZATION
-# This file is distributed under the same license as the PROJECT project.
-# FIRST AUTHOR <EMAIL@ADDRESS>, 2011.
-#
-#, fuzzy
-msgid ""
-msgstr ""
-"Project-Id-Version: PROJECT VERSION\n"
-"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
-"POT-Creation-Date: 2011-05-12 09:14-0330\n"
-"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
-"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
-"Language-Team: LANGUAGE <LL@li.org>\n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=utf-8\n"
-"Content-Transfer-Encoding: 8bit\n"
-"Generated-By: Babel 0.9.6\n"
-
-msgid "Hello!"
-msgstr "Bonjour!"
diff --git a/docs/quick_tour/package/hello_world/locale/hello_world.pot b/docs/quick_tour/package/hello_world/locale/hello_world.pot
deleted file mode 100644
index 9c9460cb2..000000000
--- a/docs/quick_tour/package/hello_world/locale/hello_world.pot
+++ /dev/null
@@ -1,21 +0,0 @@
-# Translations template for PROJECT.
-# Copyright (C) 2011 ORGANIZATION
-# This file is distributed under the same license as the PROJECT project.
-# FIRST AUTHOR <EMAIL@ADDRESS>, 2011.
-#
-#, fuzzy
-msgid ""
-msgstr ""
-"Project-Id-Version: PROJECT VERSION\n"
-"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
-"POT-Creation-Date: 2011-05-12 09:14-0330\n"
-"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
-"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
-"Language-Team: LANGUAGE <LL@li.org>\n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=utf-8\n"
-"Content-Transfer-Encoding: 8bit\n"
-"Generated-By: Babel 0.9.6\n"
-
-msgid "Hello!"
-msgstr ""
diff --git a/docs/quick_tour/package/hello_world/resources.py b/docs/quick_tour/package/hello_world/resources.py
deleted file mode 100644
index e89c2f363..000000000
--- a/docs/quick_tour/package/hello_world/resources.py
+++ /dev/null
@@ -1,8 +0,0 @@
-class MyResource(object):
- pass
-
-root = MyResource()
-
-
-def get_root(request):
- return root
diff --git a/docs/quick_tour/package/hello_world/static/favicon.ico b/docs/quick_tour/package/hello_world/static/favicon.ico
deleted file mode 100644
index 71f837c9e..000000000
--- a/docs/quick_tour/package/hello_world/static/favicon.ico
+++ /dev/null
Binary files differ
diff --git a/docs/quick_tour/package/hello_world/static/theme.css b/docs/quick_tour/package/hello_world/static/theme.css
index e3cf3f290..0f4b1a4d4 100644
--- a/docs/quick_tour/package/hello_world/static/theme.css
+++ b/docs/quick_tour/package/hello_world/static/theme.css
@@ -72,10 +72,12 @@ p {
color: #f2b7bd;
font-weight: 400;
}
-.starter-template .links ul li a {
- color: #ffffff;
+.starter-template .links ul li a, a {
+ color: #f2b7bd;
+ text-decoration: underline;
}
-.starter-template .links ul li a:hover {
+.starter-template .links ul li a:hover, a:hover {
+ color: #ffffff;
text-decoration: underline;
}
.starter-template .links ul li .icon-muted {
@@ -150,4 +152,3 @@ p {
margin-top: 20px;
}
}
-
diff --git a/docs/quick_tour/package/hello_world/templates/layout.jinja2 b/docs/quick_tour/package/hello_world/templates/layout.jinja2
new file mode 100644
index 000000000..916127267
--- /dev/null
+++ b/docs/quick_tour/package/hello_world/templates/layout.jinja2
@@ -0,0 +1,64 @@
+<!DOCTYPE html>
+<html lang="{{request.locale_name}}">
+ <head>
+ <meta charset="utf-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <meta name="description" content="pyramid web application">
+ <meta name="author" content="Pylons Project">
+ <link rel="shortcut icon" href="{{request.static_url('hello_world:static/pyramid-16x16.png')}}">
+
+ <title>Cookiecutter Starter project for the Pyramid Web Framework</title>
+
+ <!-- Bootstrap core CSS -->
+ <link href="//oss.maxcdn.com/libs/twitter-bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet">
+
+ <!-- Custom styles for this scaffold -->
+ <link href="{{request.static_url('hello_world:static/theme.css')}}" rel="stylesheet">
+
+ <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
+ <!--[if lt IE 9]>
+ <script src="//oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
+ <script src="//oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
+ <![endif]-->
+ </head>
+
+ <body>
+
+ <div class="starter-template">
+ <div class="container">
+ <div class="row">
+ <div class="col-md-2">
+ <img class="logo img-responsive" src="{{request.static_url('hello_world:static/pyramid.png') }}" alt="pyramid web framework">
+ </div>
+ <div class="col-md-10">
+ {% block content %}
+ <p>No content</p>
+ {% endblock content %}
+ </div>
+ </div>
+ <div class="row">
+ <div class="links">
+ <ul>
+ <li><i class="glyphicon glyphicon-cog icon-muted"></i><a href="https://github.com/Pylons/pyramid">Github Project</a></li>
+ <li><i class="glyphicon glyphicon-globe icon-muted"></i><a href="https://webchat.freenode.net/?channels=pyramid">IRC Channel</a></li>
+ <li><i class="glyphicon glyphicon-home icon-muted"></i><a href="http://pylonsproject.org">Pylons Project</a></li>
+ </ul>
+ </div>
+ </div>
+ <div class="row">
+ <div class="copyright">
+ Copyright &copy; Pylons Project
+ </div>
+ </div>
+ </div>
+ </div>
+
+
+ <!-- Bootstrap core JavaScript
+ ================================================== -->
+ <!-- Placed at the end of the document so the pages load faster -->
+ <script src="//oss.maxcdn.com/libs/jquery/1.10.2/jquery.min.js"></script>
+ <script src="//oss.maxcdn.com/libs/twitter-bootstrap/3.0.3/js/bootstrap.min.js"></script>
+ </body>
+</html>
diff --git a/docs/quick_tour/package/hello_world/templates/mytemplate.jinja2 b/docs/quick_tour/package/hello_world/templates/mytemplate.jinja2
index a6089aebc..cf2d7f996 100644
--- a/docs/quick_tour/package/hello_world/templates/mytemplate.jinja2
+++ b/docs/quick_tour/package/hello_world/templates/mytemplate.jinja2
@@ -1,72 +1,8 @@
-<!DOCTYPE html>
-<html lang="{{request.locale_name}}">
- <head>
- <meta charset="utf-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <meta name="description" content="pyramid web application">
- <meta name="author" content="Pylons Project">
- <link rel="shortcut icon" href="{{request.static_url('hello_world:static/pyramid-16x16.png')}}">
-
- <title>Starter Scaffold for Pyramid Jinja2</title>
-
- <!-- Bootstrap core CSS -->
- <link href="//oss.maxcdn.com/libs/twitter-bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet">
-
- <!-- Custom styles for this scaffold -->
- <link href="{{request.static_url('hello_world:static/theme.css')}}" rel="stylesheet">
-
- <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
- <!--[if lt IE 9]>
- <script src="//oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
- <script src="//oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
- <![endif]-->
- </head>
-
- <body>
-
- <div class="starter-template">
- <div class="container">
- <div class="row">
- <div class="col-md-2">
- <img class="logo img-responsive" src="{{request.static_url('hello_world:static/pyramid.png')}}" alt="pyramid web framework">
- </div>
- <div class="col-md-10">
- <div class="content">
- <h1>
- <span class="font-semi-bold">Pyramid</span>
- <span class="smaller">Jinja2 scaffold</span>
- </h1>
- <p class="lead">
- {% trans %}Hello{% endtrans %} to <span class="font-normal">{{project}}</span>, an&nbsp;application generated&nbsp;by<br>the <span class="font-normal">Pyramid Web Framework 1.6</span>.</p>
- <p>Counter: {{ request.session.counter }}</p>
- </div>
- </div>
- </div>
- <div class="row">
- <div class="links">
- <ul>
- <li class="current-version">Generated by v1.6</li>
- <li><i class="glyphicon glyphicon-bookmark icon-muted"></i><a href="http://docs.pylonsproject.org/projects/pyramid/en/1.6-branch/">Docs</a></li>
- <li><i class="glyphicon glyphicon-cog icon-muted"></i><a href="https://github.com/Pylons/pyramid">Github Project</a></li>
- <li><i class="glyphicon glyphicon-globe icon-muted"></i><a href="irc://irc.freenode.net#pyramid">IRC Channel</a></li>
- <li><i class="glyphicon glyphicon-home icon-muted"></i><a href="http://pylonsproject.org">Pylons Project</a></li>
- </ul>
- </div>
- </div>
- <div class="row">
- <div class="copyright">
- Copyright &copy; Pylons Project
- </div>
- </div>
- </div>
- </div>
-
-
- <!-- Bootstrap core JavaScript
- ================================================== -->
- <!-- Placed at the end of the document so the pages load faster -->
- <script src="//oss.maxcdn.com/libs/jquery/1.10.2/jquery.min.js"></script>
- <script src="//oss.maxcdn.com/libs/twitter-bootstrap/3.0.3/js/bootstrap.min.js"></script>
- </body>
-</html>
+{% extends "layout.jinja2" %}
+
+{% block content %}
+<div class="content">
+ <h1><span class="font-semi-bold">Pyramid</span> <span class="smaller">Starter project</span></h1>
+ <p class="lead">Welcome to <span class="font-normal">hello_world</span>, a&nbsp;Pyramid application generated&nbsp;by<br><span class="font-normal">Cookiecutter</span>.</p>
+</div>
+{% endblock content %}
diff --git a/docs/quick_tour/package/hello_world/tests.py b/docs/quick_tour/package/hello_world/tests.py
index ccec14f70..ee9745685 100644
--- a/docs/quick_tour/package/hello_world/tests.py
+++ b/docs/quick_tour/package/hello_world/tests.py
@@ -1,20 +1,29 @@
import unittest
-from pyramid import testing
-from pyramid.i18n import TranslationStringFactory
-_ = TranslationStringFactory('hello_world')
+from pyramid import testing
class ViewTests(unittest.TestCase):
-
def setUp(self):
- testing.setUp()
-
+ self.config = testing.setUp()
+
def tearDown(self):
testing.tearDown()
def test_my_view(self):
- from hello_world.views import my_view
+ from .views import my_view
request = testing.DummyRequest()
- response = my_view(request)
- self.assertEqual(response['project'], 'hello_world')
+ info = my_view(request)
+ self.assertEqual(info['project'], 'hello_world')
+
+
+class FunctionalTests(unittest.TestCase):
+ def setUp(self):
+ from hello_world import main
+ app = main({})
+ from webtest import TestApp
+ self.testapp = TestApp(app)
+
+ def test_root(self):
+ res = self.testapp.get('/', status=200)
+ self.assertTrue(b'Pyramid' in res.body)
diff --git a/docs/quick_tour/package/hello_world/views.py b/docs/quick_tour/package/hello_world/views.py
index 9f7953c8e..67f78dad7 100644
--- a/docs/quick_tour/package/hello_world/views.py
+++ b/docs/quick_tour/package/hello_world/views.py
@@ -1,16 +1,6 @@
-from pyramid.i18n import TranslationStringFactory
-
-import logging
-log = logging.getLogger(__name__)
-
-_ = TranslationStringFactory('hello_world')
+from pyramid.view import view_config
+@view_config(route_name='home', renderer='templates/mytemplate.jinja2')
def my_view(request):
- log.debug('Some Message')
- session = request.session
- if 'counter' in session:
- session['counter'] += 1
- else:
- session['counter'] = 0
return {'project': 'hello_world'}