From d4bd291fd5ca51bbbeec487f2011476706a5952f Mon Sep 17 00:00:00 2001 From: Paul Everitt Date: Fri, 9 Aug 2013 11:37:48 -0400 Subject: Lots of updates, move more code out of code-blocks into working package code. About to tackle cool Pyramid stuff. --- .../quick_glance/package/development.ini | 13 +++++++++---- .../quick_glance/package/hello_world/__init__.py | 13 ++++++++++++- .../package/hello_world/templates/mytemplate.jinja2 | 5 ++++- .../quick_glance/package/hello_world/tests.py | 1 - .../quick_glance/package/hello_world/views.py | 18 +++++++++++++++++- docs/getting_started/quick_glance/package/setup.py | 2 ++ 6 files changed, 44 insertions(+), 8 deletions(-) (limited to 'docs/getting_started/quick_glance/package') 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 @@

{% trans %}Hello!{% endtrans %}

-

Request performed with {{ request.locale_name }} locale.

+ +

Counter: {{ request.session.counter }}

+ +

Request performed with {{ request.locale_name }} locale.

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', -- cgit v1.2.3