Commits

Andriy Kornatskyy committed 02115f8

Started quick start of i18 project template from empty one code base.

Comments (0)

Files changed (29)

demos/quickstart-i18n/MANIFEST.in

+include *.ini
+include Makefile
+include README.rst
+recursive-include content/static/css *.css
+recursive-include content/static/img *.ico *.jpg *.gif *.png
+recursive-include content/static/js *.js
+recursive-include content/templates *.html

demos/quickstart-i18n/Makefile

+.SILENT: env clean release run uwsgi gunicorn qa test nose-cover test-cover benchmark profile gropf
+.PHONY: env clean release run uwsgi gunicorn qa test nose-cover test-cover benchmark profile gropf
+
+VERSION=2.7
+PYPI=http://pypi.python.org/simple
+ENV=env
+
+PYTHON=$(ENV)/bin/python$(VERSION)
+EASY_INSTALL=$(ENV)/bin/easy_install-$(VERSION)
+PYTEST=$(ENV)/bin/py.test-$(VERSION)
+NOSE=$(ENV)/bin/nosetests-$(VERSION)
+
+
+all: clean nose-cover release
+
+env:
+	PYTHON_EXE=/usr/local/bin/python$(VERSION); \
+	if [ ! -x $$PYTHON_EXE ]; then \
+		    PYTHON_EXE=/usr/bin/python$(VERSION); \
+	fi;\
+	virtualenv --python=$$PYTHON_EXE env
+	$(EASY_INSTALL) -i $(PYPI) -O2 coverage nose pytest \
+	        pytest-pep8 pytest-cov flake8
+	# The following packages available for python == 2.4
+	if [ "$$(echo $(VERSION) | sed 's/\.//')" -eq 24 ]; then \
+		$(EASY_INSTALL) -i $(PYPI) -O2 wsgiref; \
+	fi
+	$(PYTHON) setup.py develop -O2 -U -i $(PYPI)
+
+clean:
+	find src/ -type d -name __pycache__ | xargs rm -rf
+	find src/ -name '*.py[co]' -delete
+	find src/ -name '*.mo' -delete
+	find src/ -name '*.cache' -delete
+	rm -rf .cache .coverage src/*.egg-info/
+
+release:
+	rm -rf src/*.egg-info/
+	$(PYTHON) setup.py -q egg_info sdist
+
+run:
+	$(PYTHON) src/app.py
+
+uwsgi:
+	$(ENV)/bin/uwsgi --ini development.ini
+
+gunicorn:
+	export PYTHONPATH=$$PYTHONPATH:./src ; \
+		$(ENV)/bin/gunicorn -b 0.0.0.0:8080 -w 1 app:main
+
+qa:
+	$(ENV)/bin/flake8 --max-complexity 6 src setup.py && \
+		$(ENV)/bin/pep8 src setup.py ; \
+
+test:
+	$(PYTEST) -q -x --pep8 --doctest-modules src/
+
+nose-cover:
+	$(NOSE) --stop --with-doctest --detailed-errors --with-coverage \
+		--cover-package=public
+
+test-cover:
+	$(PYTEST) -q -x --cov-report term-missing src/ \
+		--cov public
+
+benchmark:
+	$(NOSE) -qs -m benchmark src/
+
+profile:
+	$(NOSE) -qs -m benchmark --with-profile \
+		--profile-stats-file=profile.pstats src/public
+
+gropf:
+	gprof2dot.py -f pstats profile.pstats | dot -Tpng -o profile.png

demos/quickstart-i18n/README.rst

Empty file added.

demos/quickstart-i18n/content/static/css/site.css

+/* Reset */
+/*html, body, p, ul ,li, dl, dt, dd, h1, h2, h3, h4, fieldset { margin: 0; padding: 0; }
+html {  overflow-y: scroll; }
+a { outline: 0; }
+a img { border: 0; }
+:focus { outline: none; }*/
+
+/* Common */
+
+/* Forms */
+
+/* Layout */
+
+/* Public */

demos/quickstart-i18n/content/static/img/favicon.ico

Added
New image

demos/quickstart-i18n/content/static/js/core.js

Empty file added.

demos/quickstart-i18n/content/templates/public/home.html

+@extends("shared/master.html")
+
+@def title():
+Home
+@end
+
+@def content():
+<div id="welcome">
+    <h2>Welcome!</h2>
+    <p>
+    Lorem ipsum dolor sit amet, consectetur adipiscing elit.
+    </p>
+</div>
+@end

demos/quickstart-i18n/content/templates/public/http400.html

+@extends("shared/master.html")
+
+@def title():
+Bad Request
+@end
+
+@def content():
+<div id="error">
+    <h2>Oops! Code 400. Sorry, we can't process your request.</h2>
+    <p>
+    The 400 Bad Request error is an HTTP status code that
+    means that the request you sent to the website server (i.e.
+    a request to load a web page) was somehow malformed therefore
+    the server was unable to understand or process the request.
+    </p>
+</div>
+@end

demos/quickstart-i18n/content/templates/public/http403.html

+@extends("shared/master.html")
+
+@def title():
+Access Denied
+@end
+
+@def content():
+<div id="error">
+    <h2>Oops! Code 403. Access is denied.</h2>
+    <p>
+    You do not have permission to view this directory or page
+    using the credentials that you supplied.
+    </p>
+</div>
+@end

demos/quickstart-i18n/content/templates/public/http404.html

+@extends("shared/master.html")
+
+@def title():
+We are sorry, the page you requested cannot be found.
+@end
+
+@def content():
+<div id="error">
+    <h2>Oops! Code 404. Sorry, we can't find that page.</h2>
+    <p>
+    Unfortunately the page you are looking for may have been
+    removed, had its name changed, under construction or is
+    temporarily unavailable. Try checking the web address for
+    typos, please. We apologize for the inconvenience.
+    </p>
+</div>
+@end

demos/quickstart-i18n/content/templates/public/http500.html

+@extends("shared/master.html")
+
+@def title():
+We are sorry, we can not process your request.
+@end
+
+@def content():
+<div id="error">
+    <h2>Oops! Code 500. Sorry, we can not process your request.</h2>
+    <p>
+    The web server encountered an unexpected condition that
+    prevented it from fulfilling the request by the client for
+    access to the requested URL.
+    </p>
+</div>
+@end

demos/quickstart-i18n/content/templates/shared/master.html

+@require(path_for)
+<!DOCTYPE html>
+<html>
+    <head>
+        @def title():
+        @end
+        <title>My Site - @title()</title>
+        <link href="@path_for('static', path='css/site.css')" type="text/css" rel="stylesheet" />
+    </head>
+    <body>
+        <div class="page">
+            <div id="header">
+                <h1><a href="@path_for('default')">My Site</a></h1>
+            </div>
+            <div id="main">
+                <div id="placeholder">
+                    @def content():
+                    @end
+                    @content()\
+                </div>                
+            </div>
+            <div id="footer">Version #__version__</div>
+        </div>
+        #include("shared/snippet/script.html")
+        @def script():
+        @end
+        @script()\
+    </body>
+</html>

demos/quickstart-i18n/content/templates/shared/snippet/script.html

+@require(path_for)
+<script src="@path_for('static', path='js/core.js')"
+ type="text/javascript"></script>

demos/quickstart-i18n/development.ini

+
+[runtime]
+mode = mock
+unhandled = stderr
+
+[cache-profile]
+public-enabled = False
+static-enabled = True
+
+[crypto]
+encryption-key = r0sWsYR3dHUcrPWeTcB7
+ticket-max-age = 1200
+ticket-salt = WmMFjzVbSpWlCKb6cOC4
+validation-key = kTrdyg9ZwcNyE6YKoPJU
+
+[uwsgi]
+wsgi = app:main
+#uwsgi-socket = /tmp/uwsgi-mysite.sock
+http-socket = 0.0.0.0:8080
+uid = www-data
+gid = www-data
+chmod-socket = 777
+umask = 000
+harakiri = 10
+optimize = 2
+master = True
+processes = 1
+chdir = .
+virtualenv = env
+pythonpath = src
+disable-logging = True
+#logto = /dev/null
+no-default-app = False
+auto-procname = True
+procname-prefix = MySite-
+limit-as = 70
+buffer-size = 2048
+post-buffering = 1024
+limit-post = 1024
+thread-stacksize = 64
+idle = 300
+python-auto-reload = 5
+lazy = True
+static-map = /static=content/static
+static-map = /favicon.ico=content/static/img/favicon.ico

demos/quickstart-i18n/setup.cfg

+[egg_info]
+tag_build=
+tag_date=0
+tag_svn_revision=0
+
+[bdist_egg]
+exclude-source-files=0
+
+[pytest]
+pep8ignore =

demos/quickstart-i18n/setup.py

+#!/usr/bin/env python
+
+import os
+
+#try:
+from setuptools import setup
+#except:
+#    from distutils.core import setup  # noqa
+
+README = open(os.path.join(os.path.dirname(__file__), 'README.rst')).read()
+
+install_requires = [
+    'wheezy.core>=0.1.101',
+    'wheezy.caching>=0.1.83',
+    'wheezy.html>=0.1.125',
+    'wheezy.http>=0.1.262',
+    'wheezy.routing>=0.1.145',
+    'wheezy.security>=0.1.46',
+    'wheezy.template>=0.1.132',
+    'wheezy.validation>=0.1.84',
+    'wheezy.web>=0.1.340',
+]
+
+install_optional = [
+    'pylibmc>=1.2.3',
+    #'PIL>=1.1.7',
+    'lxml>=2.3.6',
+    'pycrypto>=2.6',
+]
+
+install_requires += install_optional
+
+try:
+    import uuid  # noqa
+except ImportError:
+    install_requires.append('uuid')
+
+dependency_links = [
+    # pylibmc
+    'https://bitbucket.org/akorn/wheezy.caching/downloads',
+    # PIL
+    #'https://bitbucket.org/akorn/wheezy.captcha/downloads',
+    # lxml
+    'https://bitbucket.org/akorn/wheezy.http/downloads',
+    # pycrypto
+    'https://bitbucket.org/akorn/wheezy.security/downloads'
+]
+
+setup(
+    name='mysite',
+    version='0.1',
+    description='MySite Project',
+    long_description=README,
+    url='https://scm.dev.local/svn/mysite/trunk',
+
+    author='MySite Team',
+    author_email='mysite at dev.local',
+
+    license='COMMERCIAL',
+    classifiers=[
+        'Development Status :: 4 - Beta',
+        'Environment :: Web Environment',
+        'Intended Audience :: Developers',
+        'Natural Language :: English',
+        'Operating System :: OS Independent',
+        'Programming Language :: Python :: 2.7',
+        'Programming Language :: Python :: Implementation :: CPython',
+        'Programming Language :: Python :: Implementation :: PyPy',
+        'Topic :: Internet :: WWW/HTTP',
+        'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
+        'Topic :: Internet :: WWW/HTTP :: WSGI',
+        'Topic :: Internet :: WWW/HTTP :: WSGI :: Application',
+        'Topic :: Software Development :: Libraries :: Python Modules'
+    ],
+    packages=[
+        'public',
+    ],
+    package_dir={'': 'src'},
+
+    zip_safe=False,
+    install_requires=install_requires,
+    dependency_links=dependency_links,
+    extras_require={
+    },
+
+    platforms='any'
+)

demos/quickstart-i18n/src/app.py

+"""
+"""
+
+from wheezy.http import WSGIApplication
+from wheezy.http.middleware import http_cache_middleware_factory
+from wheezy.web.middleware import bootstrap_defaults
+from wheezy.web.middleware import http_error_middleware_factory
+from wheezy.web.middleware import path_routing_middleware_factory
+
+from config import options
+from urls import all_urls
+
+
+main = WSGIApplication(
+    middleware=[
+        bootstrap_defaults(url_mapping=all_urls),
+        http_cache_middleware_factory,
+        http_error_middleware_factory,
+        path_routing_middleware_factory
+    ],
+    options=options)
+
+
+if __name__ == '__main__':
+    from wsgiref.simple_server import make_server
+    try:
+        print('Visit http://localhost:8080/')
+        make_server('', 8080, main).serve_forever()
+    except KeyboardInterrupt:
+        pass
+    print('\nThanks!')

demos/quickstart-i18n/src/config.py

+"""
+"""
+
+import logging
+import sys
+
+try:  # pragma: nocover
+    from ConfigParser import ConfigParser
+    config = ConfigParser()
+except ImportError:  # pragma: nocover
+    from configparser import ConfigParser
+    config = ConfigParser(strict=False)
+
+from wheezy.caching import MemoryCache
+from wheezy.core.collections import defaultdict
+from wheezy.html.ext.template import WhitespaceExtension
+from wheezy.html.ext.template import WidgetExtension
+from wheezy.html.utils import format_value
+from wheezy.html.utils import html_escape
+from wheezy.security.crypto import Ticket
+from wheezy.security.crypto.comp import aes128
+from wheezy.security.crypto.comp import ripemd160
+from wheezy.security.crypto.comp import sha1
+from wheezy.security.crypto.comp import sha256
+from wheezy.template.engine import Engine
+from wheezy.template.ext.core import CoreExtension
+from wheezy.template.loader import FileLoader
+from wheezy.template.loader import PreprocessLoader
+from wheezy.web.templates import WheezyTemplate
+from public import __version__
+from tracing import ERROR_REPORT_FORMAT
+from tracing import error_report_extra_provider
+
+
+config.read('development.ini')
+
+mode = config.get('runtime', 'mode')
+if mode == 'mock':
+    cache = MemoryCache()
+else:
+    raise NotImplementedError(mode)
+
+options = {}
+
+# HTTPCacheMiddleware
+options.update({
+    'http_cache': cache
+})
+
+# HTTPErrorMiddleware
+if config.get('runtime', 'unhandled') == 'stderr':
+    handler = logging.StreamHandler(sys.stderr)
+else:
+    raise NotImplementedError(mode)
+handler.setFormatter(logging.Formatter(ERROR_REPORT_FORMAT))
+handler.setLevel(logging.ERROR)
+unhandled_logger = logging.getLogger('unhandled')
+unhandled_logger.setLevel(logging.ERROR)
+unhandled_logger.addHandler(handler)
+options.update({
+    'http_errors': defaultdict(lambda: 'http500', {
+        # HTTP status code: route name
+        400: 'http400',
+        403: 'http403',
+        404: 'http404',
+        500: 'http500',
+    }),
+    'http_errors_logger': unhandled_logger,
+    'http_errors_extra_provider': error_report_extra_provider
+})
+
+# Template Engine
+searchpath = ['content/templates']
+engine = Engine(
+    loader=FileLoader(searchpath),
+    extensions=[
+        CoreExtension(token_start='#')
+    ]
+)
+engine.global_vars.update({
+    '__version__': __version__
+})
+engine = Engine(
+    loader=PreprocessLoader(engine),
+    extensions=[
+        CoreExtension(),
+        WidgetExtension(),
+        WhitespaceExtension(),
+    ])
+engine.global_vars.update({
+    'format_value': format_value,
+    'h': html_escape
+})
+options.update({
+    'render_template': WheezyTemplate(engine)
+})
+
+# Security
+options.update({
+    'ticket': Ticket(
+        max_age=config.getint('crypto', 'ticket-max-age'),
+        salt=config.get('crypto', 'ticket-salt'),
+        cypher=aes128,
+        digestmod=ripemd160 or sha256 or sha1,
+        options={
+            'CRYPTO_ENCRYPTION_KEY': config.get('crypto', 'encryption-key'),
+            'CRYPTO_VALIDATION_KEY': config.get('crypto', 'validation-key')
+        }),
+
+    'AUTH_COOKIE': '_a',
+    'AUTH_COOKIE_DOMAIN': None,
+    'AUTH_COOKIE_PATH': '',
+    'AUTH_COOKIE_SECURE': False,
+
+    'XSRF_NAME': '_x',
+    'RESUBMISSION_NAME': '_c'
+})

demos/quickstart-i18n/src/factory.py

+"""
+"""
+
+
+class Factory(object):
+
+    def __init__(self, context, session_name='ro'):
+        self.context = context
+        self.session = sessions[session_name]()
+        self.repository = RepositoryFactory(self.session)
+
+    def __enter__(self):
+        self.session.__enter__()
+        return self
+
+    def __exit__(self, exc_type, exc_value, traceback):
+        self.session.__exit__(exc_value, exc_value, traceback)
+
+
+class RepositoryFactory(object):
+
+    def __init__(self, session):
+        self.session = session
+
+
+# region: configuration details
+
+from config import mode
+
+if mode == 'mock':
+    from wheezy.core.db import NullSession
+    sessions = {'ro': NullSession, 'rw': NullSession}
+else:
+    raise NotImplementedError(mode)
+del mode

demos/quickstart-i18n/src/public/__init__.py

+
+"""
+"""
+
+__version_info__ = (0, 1, 0, 0)
+__version__ = '.'.join(map(str, __version_info__))

demos/quickstart-i18n/src/public/web/__init__.py

Empty file added.

demos/quickstart-i18n/src/public/web/profile.py

+"""
+"""
+
+from datetime import timedelta
+
+from wheezy.http import CacheProfile
+
+from config import config
+
+
+static_cache_profile = CacheProfile(
+    'public',
+    duration=timedelta(minutes=15),
+    vary_environ=['HTTP_ACCEPT_ENCODING'],
+    namespace='static',
+    enabled=config.getboolean('cache-profile', 'static-enabled'))
+public_cache_profile = CacheProfile(
+    'server',
+    duration=timedelta(minutes=15),
+    vary_environ=['HTTP_ACCEPT_ENCODING'],
+    vary_cookies=['_a'],
+    no_store=True,
+    enabled=config.getboolean('cache-profile', 'public-enabled'))

demos/quickstart-i18n/src/public/web/tests/__init__.py

Empty file added.

demos/quickstart-i18n/src/public/web/tests/benchmark_views.py

+
+""" ``benchmark_views`` module.
+"""
+
+from wheezy.core.benchmark import Benchmark
+
+from public.web.tests.test_views import PublicTestCase
+from public.web.tests.test_views import ErrorTestCase
+
+
+class PublicBenchmarkTestCase(PublicTestCase, ErrorTestCase):
+
+    def runTest(self):
+        """ Perform bachmark and print results.
+        """
+        b = Benchmark((
+            self.test_root,
+            self.test_home,
+            self.test_error_400,
+            self.test_error_403,
+            self.test_error_404,
+        ), 1000)
+        b.report('public', baselines={
+            'test_root': 1.0,
+            'test_home': 1.0,
+            'test_error_400': 1.0,
+            'test_error_403': 1.0,
+            'test_error_404': 1.0,
+        })
+
+
+class StaticFilesBenchmarkTestCase(PublicTestCase, ErrorTestCase):
+
+    def runTest(self):
+        """ Perform bachmark and print results.
+        """
+        b = Benchmark((
+            self.test_static_files,
+            self.test_static_file_not_found,
+            self.test_static_file_forbidden
+        ), 1000)
+        b.report('static', baselines={
+            'test_static_files': 1.00,
+            'test_static_file_not_found': 1.0,
+            'test_static_file_forbidden': 1.0,
+        })

demos/quickstart-i18n/src/public/web/tests/test_views.py

+
+""" ``test_views`` module.
+"""
+
+import unittest
+
+try:
+    import json
+except ImportError:  # pragma: nocover
+    json = None  # noqa
+
+
+from wheezy.http.functional import WSGIClient
+
+from app import main
+
+
+class PublicTestCase(unittest.TestCase):
+
+    def setUp(self):
+        self.client = WSGIClient(main)
+
+    def tearDown(self):
+        del self.client
+        self.client = None
+
+    def test_root(self):
+        """ Ensure root page is rendered.
+        """
+        assert 200 == self.client.get('/')
+        assert '- Home</title>' in self.client.content
+
+    def test_home(self):
+        """ Ensure home page is rendered.
+        """
+        assert 200 == self.client.get('/home')
+        assert '- Home</title>' in self.client.content
+
+    def test_static_files(self):
+        """ Ensure static content is served.
+        """
+        for static_file in [
+            '/favicon.ico',
+            '/static/css/site.css',
+            '/static/js/core.js',
+        ]:
+            assert 200 == self.client.get(static_file)
+
+    def test_static_file_not_found(self):
+        """ Ensure 404 status code for non existing
+            static content.
+        """
+        assert 302 == self.client.get('/static/css/unknown.css')
+        assert '404' in self.client.headers['Location'][0]
+
+    def test_static_file_forbidden(self):
+        """ Ensure 403 status code for forbidden
+            static content.
+        """
+        assert 302 == self.client.get('/static/../templates/')
+        assert '403' in self.client.headers['Location'][0]
+
+
+class ErrorTestCase(unittest.TestCase):
+
+    def setUp(self):
+        self.client = WSGIClient(main)
+
+    def tearDown(self):
+        del self.client
+        self.client = None
+
+    def test_error_400(self):
+        """ Ensure bad request page is rendered.
+        """
+        assert 400 == self.client.get('/error/400')
+        assert 'Code 400' in self.client.content
+
+    def test_error_403(self):
+        """ Ensure forbidden page is rendered.
+        """
+        assert 403 == self.client.get('/error/403')
+        assert 'Code 403' in self.client.content
+
+    def test_error_404(self):
+        """ Ensure not found page is rendered.
+        """
+        assert 404 == self.client.get('/error/404')
+        assert 'Code 404' in self.client.content
+
+    def test_route_not_found(self):
+        """ Ensure not found page is rendered.
+        """
+        self.client.get('/test-not-found')
+        assert 404 == self.client.follow()
+        assert 'Code 404' in self.client.content
+
+    def test_error_500(self):
+        """ Ensure internal error page is rendered.
+        """
+        assert 500 == self.client.get('/error/500')
+        assert 'Code 500' in self.client.content

demos/quickstart-i18n/src/public/web/urls.py

+"""
+"""
+
+from wheezy.routing import url
+
+from public.web.views import WelcomeHandler
+from public.web.views import http400
+from public.web.views import http403
+from public.web.views import http404
+from public.web.views import http500
+from public.web.views import static_file
+
+
+public_urls = [
+    url('home', WelcomeHandler, name='home')
+]
+
+error_urls = [
+    url('400', http400, name='http400'),
+    url('403', http403, name='http403'),
+    url('404', http404, name='http404'),
+    url('500', http500, name='http500'),
+]
+
+static_urls = [
+    url('static/{path:any}', static_file, name='static'),
+    url('favicon.ico', static_file, {'path': 'img/favicon.ico'})
+]

demos/quickstart-i18n/src/public/web/views.py

+"""
+"""
+
+from datetime import timedelta
+
+from wheezy.http import response_cache
+from wheezy.http.transforms import gzip_transform
+from wheezy.http.transforms import response_transforms
+from wheezy.web.handlers import BaseHandler
+from wheezy.web.handlers import file_handler
+from wheezy.web.handlers import template_handler
+
+from public.web.profile import public_cache_profile
+from public.web.profile import static_cache_profile
+
+
+class WelcomeHandler(BaseHandler):
+
+    @response_cache(public_cache_profile)
+    @response_transforms(gzip_transform())
+    def get(self):
+        return self.render_response('public/home.html')
+
+
+wraps_handler = lambda p: lambda h: response_cache(p)(
+    response_transforms(gzip_transform(compress_level=9))(h))
+
+#w = wraps_handler(public_cache_profile)
+#home = w(template_handler('public/home.html'))
+
+# cached by nginx
+http400 = template_handler('public/http400.html', status_code=400)
+http403 = template_handler('public/http403.html', status_code=403)
+http404 = template_handler('public/http404.html', status_code=404)
+http500 = template_handler('public/http500.html', status_code=500)
+
+w = wraps_handler(static_cache_profile)
+static_file = w(file_handler(root='content/static/', age=timedelta(hours=1)))

demos/quickstart-i18n/src/tracing.py

+
+"""
+"""
+
+import os
+import platform
+import socket
+import sys
+
+from datetime import timedelta
+from time import time
+
+
+start_time = time()
+
+
+def error_report_extra_provider(request):
+    ts = os.times()
+    e = request.environ
+    if 'CONTENT_LENGTH' in e and e['CONTENT_LENGTH']:
+        form = filter_names(request.form, ignore=(
+            'password',
+            'confirm_password'
+        ))
+    else:
+        form = {}
+    return {
+        'HTTP_ACCEPT_LANGUAGE': e['HTTP_ACCEPT_LANGUAGE'],
+        'HTTP_REFERER': e.get('HTTP_REFERER', '?'),
+        'HTTP_USER_AGENT': e['HTTP_USER_AGENT'],
+        'PATH_INFO': e['PATH_INFO'],
+        'REMOTE_ADDR': e['REMOTE_ADDR'],
+        'REQUEST_METHOD': e['REQUEST_METHOD'],
+        'executable': sys.executable,
+        'hostname': socket.gethostname(),
+        'http_cookies': request.cookies,
+        'http_form': form,
+        'machine': platform.machine(),
+        'modules': modules_info(),
+        'process_uptime': timedelta(seconds=time() - start_time),
+        'python_compiler': platform.python_compiler(),
+        'python_version': platform.python_version(),
+        'release': platform.release(),
+        'route_args': dict(e['route_args']),
+        'stime': timedelta(seconds=ts[1]),
+        'system': platform.system(),
+        'utime': timedelta(seconds=ts[0]),
+        'uwsgi.version': e.get('uwsgi.version', '?'),
+    }
+
+
+def filter_names(d, ignore):
+    return dict((name, d[name]) for name in d if name not in ignore)
+
+
+def modules_info():
+    def predicate(m):
+        return (hasattr(m, '__version__')
+                and not (m.__name__.startswith('_') or '._' in m.__name__))
+    return sorted([(m.__name__, m.__version__) for m in sys.modules.values()
+                   if predicate(m)])
+
+
+ERROR_REPORT_FORMAT = """
+%(message)s
+
+Environ Variables
+-----------------
+PATH_INFO: %(PATH_INFO)s
+REQUEST_METHOD: %(REQUEST_METHOD)s
+REMOTE_ADDR: %(REMOTE_ADDR)s
+HTTP_REFERER: %(HTTP_REFERER)s
+HTTP_ACCEPT_LANGUAGE: %(HTTP_ACCEPT_LANGUAGE)s
+HTTP_USER_AGENT: %(HTTP_USER_AGENT)s
+
+HTTP Request
+------------
+Route: %(route_args)s
+Cookies: %(http_cookies)s
+Form: %(http_form)s
+
+Hosting Process
+---------------
+Process Id: %(process)d
+Up Time: %(process_uptime)s
+User Time: %(utime)s
+System Time: %(stime)s
+
+Machine Platform
+----------------
+Host: %(hostname)s
+OS: %(system)s %(release)s %(machine)s
+Python Version: %(python_version)s [%(python_compiler)s]
+uWSGI Version: %(uwsgi.version)s
+Executable: %(executable)s
+Timestamp: %(asctime)s
+
+Loaded Modules
+--------------
+%(modules)s
+
+
+"""

demos/quickstart-i18n/src/urls.py

+"""
+"""
+
+from wheezy.routing import url
+
+from public.web.urls import error_urls
+from public.web.urls import public_urls
+from public.web.urls import static_urls
+from public.web.views import WelcomeHandler
+
+
+all_urls = [
+    url('', WelcomeHandler, name='default')
+]
+all_urls += public_urls
+all_urls += [('error/', error_urls)]
+all_urls += static_urls