summaryrefslogtreecommitdiff
path: root/docs/getting_started/quick_glance/package
diff options
context:
space:
mode:
authorPaul Everitt <paul@agendaless.com>2013-08-09 11:37:48 -0400
committerPaul Everitt <paul@agendaless.com>2013-08-09 11:37:48 -0400
commitd4bd291fd5ca51bbbeec487f2011476706a5952f (patch)
tree77052c5204e0045f59b740ff9d1ae253394524da /docs/getting_started/quick_glance/package
parent65d1719fc5ce4ed4e87c45b1e4279c30930b274e (diff)
downloadpyramid-d4bd291fd5ca51bbbeec487f2011476706a5952f.tar.gz
pyramid-d4bd291fd5ca51bbbeec487f2011476706a5952f.tar.bz2
pyramid-d4bd291fd5ca51bbbeec487f2011476706a5952f.zip
Lots of updates, move more code out of code-blocks into working package code. About to tackle cool Pyramid stuff.
Diffstat (limited to 'docs/getting_started/quick_glance/package')
-rw-r--r--docs/getting_started/quick_glance/package/development.ini13
-rw-r--r--docs/getting_started/quick_glance/package/hello_world/__init__.py13
-rw-r--r--docs/getting_started/quick_glance/package/hello_world/templates/mytemplate.jinja25
-rw-r--r--docs/getting_started/quick_glance/package/hello_world/tests.py1
-rw-r--r--docs/getting_started/quick_glance/package/hello_world/views.py18
-rw-r--r--docs/getting_started/quick_glance/package/setup.py2
6 files changed, 44 insertions, 8 deletions
diff --git a/docs/getting_started/quick_glance/package/development.ini b/docs/getting_started/quick_glance/package/development.ini
index 9aa5f40cf..a751ff903 100644
--- a/docs/getting_started/quick_glance/package/development.ini
+++ b/docs/getting_started/quick_glance/package/development.ini
@@ -1,5 +1,7 @@
+# Start Includes
[app:hello_world]
pyramid.includes = pyramid_debugtoolbar
+# End Includes
use = egg:hello_world
reload_templates = true
debug_authorization = false
@@ -22,9 +24,16 @@ port = 6543
# Begin logging configuration
+# Start Sphinx Include
[loggers]
keys = root, hello_world
+[logger_hello_world]
+level = DEBUG
+handlers =
+qualname = hello_world
+# End Sphinx Include
+
[handlers]
keys = console
@@ -35,10 +44,6 @@ keys = generic
level = INFO
handlers = console
-[logger_hello_world]
-level = DEBUG
-handlers =
-qualname = hello_world
[handler_console]
class = StreamHandler
diff --git a/docs/getting_started/quick_glance/package/hello_world/__init__.py b/docs/getting_started/quick_glance/package/hello_world/__init__.py
index 9b5753c26..6e66bf40a 100644
--- a/docs/getting_started/quick_glance/package/hello_world/__init__.py
+++ b/docs/getting_started/quick_glance/package/hello_world/__init__.py
@@ -1,5 +1,9 @@
from pyramid.config import Configurator
from pyramid_jinja2 import renderer_factory
+# Start Sphinx Include 1
+from pyramid.session import UnencryptedCookieSessionFactoryConfig
+# End Sphinx Include 1
+
from hello_world.models import get_root
def main(global_config, **settings):
@@ -11,9 +15,16 @@ def main(global_config, **settings):
settings = dict(settings)
settings.setdefault('jinja2.i18n.domain', 'hello_world')
- config = Configurator(root_factory=get_root, settings=settings)
+ # Start Sphinx Include 2
+ my_session_factory = UnencryptedCookieSessionFactoryConfig('itsaseekreet')
+ config = Configurator(root_factory=get_root, settings=settings,
+ session_factory=my_session_factory)
+ # End Sphinx Include 2
config.add_translation_dirs('locale/')
+ # Start Include
config.include('pyramid_jinja2')
+ # End Include
+
config.add_static_view('static', 'static')
config.add_view('hello_world.views.my_view',
diff --git a/docs/getting_started/quick_glance/package/hello_world/templates/mytemplate.jinja2 b/docs/getting_started/quick_glance/package/hello_world/templates/mytemplate.jinja2
index 998edfe12..25a28ed7a 100644
--- a/docs/getting_started/quick_glance/package/hello_world/templates/mytemplate.jinja2
+++ b/docs/getting_started/quick_glance/package/hello_world/templates/mytemplate.jinja2
@@ -35,7 +35,10 @@
<div id="bottom">
<div class="locale">
<h2>{% trans %}Hello!{% endtrans %}</h2>
- <p>Request performed with <span class="locale-name">{{ request.locale_name }}</span> locale.</p>
+ <!-- Start Sphinx Include 1 -->
+ <p>Counter: {{ request.session.counter }}</p>
+ <!-- End Sphinx Include 1 -->
+ <p>Request performed with <span class="locale-name">{{ request.locale_name }}</span> locale.</p>
</div>
<div class="bottom">
<div id="left" class="align-right">
diff --git a/docs/getting_started/quick_glance/package/hello_world/tests.py b/docs/getting_started/quick_glance/package/hello_world/tests.py
index a81c29eb0..ccec14f70 100644
--- a/docs/getting_started/quick_glance/package/hello_world/tests.py
+++ b/docs/getting_started/quick_glance/package/hello_world/tests.py
@@ -18,4 +18,3 @@ class ViewTests(unittest.TestCase):
request = testing.DummyRequest()
response = my_view(request)
self.assertEqual(response['project'], 'hello_world')
-
diff --git a/docs/getting_started/quick_glance/package/hello_world/views.py b/docs/getting_started/quick_glance/package/hello_world/views.py
index c271d45dd..109c260ad 100644
--- a/docs/getting_started/quick_glance/package/hello_world/views.py
+++ b/docs/getting_started/quick_glance/package/hello_world/views.py
@@ -1,6 +1,22 @@
+# Start Logging 1
+import logging
+log = logging.getLogger(__name__)
+# End Logging 1
+
from pyramid.i18n import TranslationStringFactory
_ = TranslationStringFactory('hello_world')
+
def my_view(request):
- return {'project':'hello_world'}
+ # Start Logging 2
+ log.debug('Some Message')
+ # End Logging 2
+ # Start Sphinx Include 1
+ session = request.session
+ if 'counter' in session:
+ session['counter'] += 1
+ else:
+ session['counter'] = 0
+ # End Sphinx Include 1
+ return {'project': 'hello_world'}
diff --git a/docs/getting_started/quick_glance/package/setup.py b/docs/getting_started/quick_glance/package/setup.py
index 6269accf1..f118ed5fb 100644
--- a/docs/getting_started/quick_glance/package/setup.py
+++ b/docs/getting_started/quick_glance/package/setup.py
@@ -6,7 +6,9 @@ here = os.path.abspath(os.path.dirname(__file__))
README = open(os.path.join(here, 'README.txt')).read()
CHANGES = open(os.path.join(here, 'CHANGES.txt')).read()
+# Start Requires
requires = ['pyramid>=1.0.2', 'pyramid_jinja2', 'pyramid_debugtoolbar']
+# End Requires
setup(name='hello_world',
version='0.0',