├── examples ├── couchy │ ├── __init__.py │ ├── templates │ │ ├── display.html │ │ ├── not_found.html │ │ ├── layout.html │ │ ├── new.html │ │ └── list.html │ ├── README │ ├── models.py │ ├── application.py │ ├── static │ │ └── style.css │ ├── views.py │ └── utils.py ├── shorty │ ├── __init__.py │ ├── templates │ │ ├── display.html │ │ ├── not_found.html │ │ ├── layout.html │ │ ├── new.html │ │ └── list.html │ ├── models.py │ ├── application.py │ ├── views.py │ ├── static │ │ └── style.css │ └── utils.py ├── contrib │ ├── README │ ├── sessions.py │ └── securecookie.py ├── i18nurls │ ├── __init__.py │ ├── templates │ │ ├── about.html │ │ ├── blog.html │ │ ├── index.html │ │ └── layout.html │ ├── urls.py │ ├── views.py │ └── application.py ├── cupoftee │ ├── shared │ │ ├── up.png │ │ ├── down.png │ │ ├── header.png │ │ ├── logo.png │ │ ├── content.png │ │ ├── favicon.ico │ │ └── style.css │ ├── templates │ │ ├── missingpage.html │ │ ├── layout.html │ │ ├── server.html │ │ ├── search.html │ │ └── serverlist.html │ ├── __init__.py │ ├── utils.py │ ├── db.py │ ├── pages.py │ └── application.py ├── partial │ ├── README │ └── complex_routing.py ├── coolmagic │ ├── public │ │ └── style.css │ ├── templates │ │ ├── static │ │ │ ├── about.html │ │ │ ├── not_found.html │ │ │ └── index.html │ │ └── layout.html │ ├── views │ │ ├── __init__.py │ │ └── static.py │ ├── __init__.py │ ├── helpers.py │ ├── application.py │ └── utils.py ├── shortly │ ├── templates │ │ ├── 404.html │ │ ├── layout.html │ │ ├── new_url.html │ │ └── short_link_details.html │ └── static │ │ └── style.css ├── plnt │ ├── __init__.py │ ├── templates │ │ ├── about.html │ │ ├── layout.html │ │ └── index.html │ ├── views.py │ ├── webapp.py │ ├── database.py │ └── shared │ │ └── style.css ├── simplewiki │ ├── templates │ │ ├── action_show.html │ │ ├── missing_action.html │ │ ├── page_index.html │ │ ├── macros.xml │ │ ├── page_missing.html │ │ ├── recent_changes.html │ │ ├── action_diff.html │ │ ├── action_edit.html │ │ ├── action_revert.html │ │ ├── action_log.html │ │ └── layout.html │ ├── __init__.py │ └── specialpages.py ├── manage-couchy.py ├── manage-cupoftee.py ├── manage-i18nurls.py ├── manage-coolmagic.py ├── manage-shorty.py ├── webpylike │ ├── example.py │ └── webpylike.py ├── manage-webpylike.py ├── manage-simplewiki.py ├── upload.py ├── httpbasicauth.py ├── manage-plnt.py ├── README └── cookieauth.py ├── werkzeug ├── testsuite │ ├── res │ │ └── test.txt │ ├── multipart │ │ ├── ie6-2png1txt │ │ │ ├── text.txt │ │ │ ├── file1.png │ │ │ ├── file2.png │ │ │ └── request.txt │ │ ├── firefox3-2png1txt │ │ │ ├── text.txt │ │ │ ├── file1.png │ │ │ ├── file2.png │ │ │ └── request.txt │ │ ├── opera8-2png1txt │ │ │ ├── text.txt │ │ │ ├── file1.png │ │ │ ├── file2.png │ │ │ └── request.txt │ │ ├── webkit3-2png1txt │ │ │ ├── text.txt │ │ │ ├── file1.png │ │ │ ├── file2.png │ │ │ └── request.txt │ │ ├── firefox3-2pnglongtext │ │ │ ├── text.txt │ │ │ ├── file1.png │ │ │ ├── file2.png │ │ │ └── request.txt │ │ ├── ie7_full_path_request.txt │ │ └── collect.py │ ├── contrib │ │ ├── __init__.py │ │ ├── securecookie.py │ │ ├── sessions.py │ │ └── wrappers.py │ ├── compat.py │ ├── internal.py │ ├── exceptions.py │ └── serving.py ├── debug │ └── shared │ │ ├── less.png │ │ ├── more.png │ │ ├── source.png │ │ ├── ubuntu.ttf │ │ └── console.png └── contrib │ ├── __init__.py │ ├── limiter.py │ └── testtools.py ├── docs ├── logo.pdf ├── _static │ ├── contents.png │ ├── favicon.ico │ ├── header.png │ ├── shortly.png │ ├── werkzeug.png │ ├── background.png │ ├── navigation.png │ ├── codebackground.png │ ├── debug-screenshot.png │ ├── navigation_active.png │ ├── shorty-screenshot.png │ └── werkzeug.js ├── latexindex.rst ├── _themes │ ├── werkzeug │ │ ├── theme.conf │ │ ├── layout.html │ │ └── relations.html │ ├── README │ └── LICENSE ├── contrib │ ├── iterio.rst │ ├── lint.rst │ ├── atom.rst │ ├── profiler.rst │ ├── fixers.rst │ ├── index.rst │ ├── wrappers.rst │ ├── cache.rst │ ├── sessions.rst │ └── securecookie.rst ├── _templates │ ├── sidebarlogo.html │ └── sidebarintro.html ├── index.rst ├── makearchive.py ├── deployment │ ├── index.rst │ ├── cgi.rst │ ├── proxying.rst │ └── mod_wsgi.rst ├── werkzeugext.py ├── middlewares.rst ├── wsgi.rst ├── contents.rst.inc ├── terms.rst ├── utils.rst ├── transition.rst ├── debug.rst ├── make.bat ├── python3.rst ├── levels.rst ├── datastructures.rst ├── local.rst └── werkzeugstyle.sty ├── artwork └── logo.png ├── run-tests.py ├── setup.cfg ├── .gitignore ├── tox.ini ├── .travis.yml ├── MANIFEST.in ├── README.rst ├── Makefile ├── AUTHORS ├── LICENSE └── setup.py /examples/couchy/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/shorty/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /werkzeug/testsuite/res/test.txt: -------------------------------------------------------------------------------- 1 | FOUND 2 | -------------------------------------------------------------------------------- /werkzeug/testsuite/multipart/ie6-2png1txt/text.txt: -------------------------------------------------------------------------------- 1 | ie6 sucks :-/ -------------------------------------------------------------------------------- /werkzeug/testsuite/multipart/firefox3-2png1txt/text.txt: -------------------------------------------------------------------------------- 1 | example text -------------------------------------------------------------------------------- /werkzeug/testsuite/multipart/opera8-2png1txt/text.txt: -------------------------------------------------------------------------------- 1 | blafasel öäü -------------------------------------------------------------------------------- /docs/logo.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simple/werkzeug/master/docs/logo.pdf -------------------------------------------------------------------------------- /artwork/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simple/werkzeug/master/artwork/logo.png -------------------------------------------------------------------------------- /werkzeug/testsuite/multipart/webkit3-2png1txt/text.txt: -------------------------------------------------------------------------------- 1 | this is another text with ümläüts -------------------------------------------------------------------------------- /examples/contrib/README: -------------------------------------------------------------------------------- 1 | This folder includes example applications for werkzeug.contrib 2 | -------------------------------------------------------------------------------- /examples/i18nurls/__init__.py: -------------------------------------------------------------------------------- 1 | from i18nurls.application import Application as make_app 2 | -------------------------------------------------------------------------------- /run-tests.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from werkzeug.testsuite import main 3 | main() 4 | -------------------------------------------------------------------------------- /docs/_static/contents.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simple/werkzeug/master/docs/_static/contents.png -------------------------------------------------------------------------------- /docs/_static/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simple/werkzeug/master/docs/_static/favicon.ico -------------------------------------------------------------------------------- /docs/_static/header.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simple/werkzeug/master/docs/_static/header.png -------------------------------------------------------------------------------- /docs/_static/shortly.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simple/werkzeug/master/docs/_static/shortly.png -------------------------------------------------------------------------------- /docs/_static/werkzeug.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simple/werkzeug/master/docs/_static/werkzeug.png -------------------------------------------------------------------------------- /docs/_static/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simple/werkzeug/master/docs/_static/background.png -------------------------------------------------------------------------------- /docs/_static/navigation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simple/werkzeug/master/docs/_static/navigation.png -------------------------------------------------------------------------------- /werkzeug/debug/shared/less.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simple/werkzeug/master/werkzeug/debug/shared/less.png -------------------------------------------------------------------------------- /werkzeug/debug/shared/more.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simple/werkzeug/master/werkzeug/debug/shared/more.png -------------------------------------------------------------------------------- /werkzeug/testsuite/multipart/firefox3-2pnglongtext/text.txt: -------------------------------------------------------------------------------- 1 | --long text 2 | --with boundary 3 | --lookalikes-- -------------------------------------------------------------------------------- /docs/_static/codebackground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simple/werkzeug/master/docs/_static/codebackground.png -------------------------------------------------------------------------------- /examples/cupoftee/shared/up.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simple/werkzeug/master/examples/cupoftee/shared/up.png -------------------------------------------------------------------------------- /setup.cfg: -------------------------------------------------------------------------------- 1 | [egg_info] 2 | tag_build = dev 3 | tag_date = true 4 | 5 | [aliases] 6 | release = egg_info -RDb '' 7 | -------------------------------------------------------------------------------- /werkzeug/debug/shared/source.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simple/werkzeug/master/werkzeug/debug/shared/source.png -------------------------------------------------------------------------------- /werkzeug/debug/shared/ubuntu.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simple/werkzeug/master/werkzeug/debug/shared/ubuntu.ttf -------------------------------------------------------------------------------- /docs/_static/debug-screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simple/werkzeug/master/docs/_static/debug-screenshot.png -------------------------------------------------------------------------------- /docs/_static/navigation_active.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simple/werkzeug/master/docs/_static/navigation_active.png -------------------------------------------------------------------------------- /docs/_static/shorty-screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simple/werkzeug/master/docs/_static/shorty-screenshot.png -------------------------------------------------------------------------------- /examples/cupoftee/shared/down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simple/werkzeug/master/examples/cupoftee/shared/down.png -------------------------------------------------------------------------------- /examples/cupoftee/shared/header.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simple/werkzeug/master/examples/cupoftee/shared/header.png -------------------------------------------------------------------------------- /examples/cupoftee/shared/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simple/werkzeug/master/examples/cupoftee/shared/logo.png -------------------------------------------------------------------------------- /werkzeug/debug/shared/console.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simple/werkzeug/master/werkzeug/debug/shared/console.png -------------------------------------------------------------------------------- /examples/cupoftee/shared/content.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simple/werkzeug/master/examples/cupoftee/shared/content.png -------------------------------------------------------------------------------- /examples/cupoftee/shared/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simple/werkzeug/master/examples/cupoftee/shared/favicon.ico -------------------------------------------------------------------------------- /docs/latexindex.rst: -------------------------------------------------------------------------------- 1 | :orphan: 2 | 3 | Werkzeug Documentation 4 | ====================== 5 | 6 | .. include:: contents.rst.inc 7 | -------------------------------------------------------------------------------- /docs/_themes/werkzeug/theme.conf: -------------------------------------------------------------------------------- 1 | [theme] 2 | inherit = basic 3 | stylesheet = werkzeug.css 4 | pygments_style = werkzeug_theme_support.WerkzeugStyle 5 | -------------------------------------------------------------------------------- /docs/contrib/iterio.rst: -------------------------------------------------------------------------------- 1 | ======= 2 | Iter IO 3 | ======= 4 | 5 | .. automodule:: werkzeug.contrib.iterio 6 | 7 | .. autoclass:: IterIO 8 | :members: 9 | -------------------------------------------------------------------------------- /werkzeug/testsuite/multipart/ie6-2png1txt/file1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simple/werkzeug/master/werkzeug/testsuite/multipart/ie6-2png1txt/file1.png -------------------------------------------------------------------------------- /werkzeug/testsuite/multipart/ie6-2png1txt/file2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simple/werkzeug/master/werkzeug/testsuite/multipart/ie6-2png1txt/file2.png -------------------------------------------------------------------------------- /werkzeug/testsuite/multipart/ie6-2png1txt/request.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simple/werkzeug/master/werkzeug/testsuite/multipart/ie6-2png1txt/request.txt -------------------------------------------------------------------------------- /werkzeug/testsuite/multipart/ie7_full_path_request.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simple/werkzeug/master/werkzeug/testsuite/multipart/ie7_full_path_request.txt -------------------------------------------------------------------------------- /werkzeug/testsuite/multipart/opera8-2png1txt/file1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simple/werkzeug/master/werkzeug/testsuite/multipart/opera8-2png1txt/file1.png -------------------------------------------------------------------------------- /werkzeug/testsuite/multipart/opera8-2png1txt/file2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simple/werkzeug/master/werkzeug/testsuite/multipart/opera8-2png1txt/file2.png -------------------------------------------------------------------------------- /werkzeug/testsuite/multipart/webkit3-2png1txt/file1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simple/werkzeug/master/werkzeug/testsuite/multipart/webkit3-2png1txt/file1.png -------------------------------------------------------------------------------- /werkzeug/testsuite/multipart/webkit3-2png1txt/file2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simple/werkzeug/master/werkzeug/testsuite/multipart/webkit3-2png1txt/file2.png -------------------------------------------------------------------------------- /werkzeug/testsuite/multipart/firefox3-2png1txt/file1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simple/werkzeug/master/werkzeug/testsuite/multipart/firefox3-2png1txt/file1.png -------------------------------------------------------------------------------- /werkzeug/testsuite/multipart/firefox3-2png1txt/file2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simple/werkzeug/master/werkzeug/testsuite/multipart/firefox3-2png1txt/file2.png -------------------------------------------------------------------------------- /werkzeug/testsuite/multipart/opera8-2png1txt/request.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simple/werkzeug/master/werkzeug/testsuite/multipart/opera8-2png1txt/request.txt -------------------------------------------------------------------------------- /werkzeug/testsuite/multipart/webkit3-2png1txt/request.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simple/werkzeug/master/werkzeug/testsuite/multipart/webkit3-2png1txt/request.txt -------------------------------------------------------------------------------- /werkzeug/testsuite/multipart/firefox3-2png1txt/request.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simple/werkzeug/master/werkzeug/testsuite/multipart/firefox3-2png1txt/request.txt -------------------------------------------------------------------------------- /werkzeug/testsuite/multipart/firefox3-2pnglongtext/file1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simple/werkzeug/master/werkzeug/testsuite/multipart/firefox3-2pnglongtext/file1.png -------------------------------------------------------------------------------- /werkzeug/testsuite/multipart/firefox3-2pnglongtext/file2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simple/werkzeug/master/werkzeug/testsuite/multipart/firefox3-2pnglongtext/file2.png -------------------------------------------------------------------------------- /werkzeug/testsuite/multipart/firefox3-2pnglongtext/request.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simple/werkzeug/master/werkzeug/testsuite/multipart/firefox3-2pnglongtext/request.txt -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | MANIFEST 2 | build 3 | dist 4 | *.egg-info 5 | *.pyc 6 | *.pyo 7 | env 8 | .tox 9 | docs/_build 10 | bench/a 11 | bench/b 12 | .coverage 13 | coverage_out 14 | -------------------------------------------------------------------------------- /docs/_templates/sidebarlogo.html: -------------------------------------------------------------------------------- 1 |
4 | -------------------------------------------------------------------------------- /examples/i18nurls/templates/about.html: -------------------------------------------------------------------------------- 1 |2 | This is just another page. Maybe you want to head over to the 3 | blog. 4 |
5 | -------------------------------------------------------------------------------- /docs/index.rst: -------------------------------------------------------------------------------- 1 | ====================== 2 | Documentation Overview 3 | ====================== 4 | 5 | Welcome to the Werkzeug |version| documentation. 6 | 7 | .. include:: contents.rst.inc 8 | -------------------------------------------------------------------------------- /examples/partial/README: -------------------------------------------------------------------------------- 1 | This directory contains modules that have code but that are 2 | not excutable. For example routing definitions to play around 3 | in the python interactive prompt. 4 | -------------------------------------------------------------------------------- /docs/contrib/lint.rst: -------------------------------------------------------------------------------- 1 | ========================== 2 | Lint Validation Middleware 3 | ========================== 4 | 5 | .. automodule:: werkzeug.contrib.lint 6 | 7 | .. autoclass:: LintMiddleware 8 | -------------------------------------------------------------------------------- /examples/coolmagic/public/style.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | padding: 20px; 4 | font-family: sans-serif; 5 | font-size: 15px; 6 | } 7 | 8 | h1, a { 9 | color: #a00; 10 | } 11 | -------------------------------------------------------------------------------- /examples/i18nurls/templates/blog.html: -------------------------------------------------------------------------------- 1 |Blog <% if mode == 'index' %>Index<% else %>Post $post_id<% endif %>
2 |3 | How about going to the index. 4 |
5 | -------------------------------------------------------------------------------- /docs/contrib/atom.rst: -------------------------------------------------------------------------------- 1 | ================ 2 | Atom Syndication 3 | ================ 4 | 5 | .. automodule:: werkzeug.contrib.atom 6 | 7 | .. autoclass:: AtomFeed 8 | :members: 9 | 10 | .. autoclass:: FeedEntry 11 | -------------------------------------------------------------------------------- /docs/makearchive.py: -------------------------------------------------------------------------------- 1 | import os 2 | import conf 3 | name = "werkzeug-docs-" + conf.version 4 | os.chdir("_build") 5 | os.rename("html", name) 6 | os.system("tar czf %s.tar.gz %s" % (name, name)) 7 | os.rename(name, "html") 8 | -------------------------------------------------------------------------------- /examples/shortly/templates/404.html: -------------------------------------------------------------------------------- 1 | {% extends "layout.html" %} 2 | {% block title %}Page Not Found{% endblock %} 3 | {% block body %} 4 |I am sorry, but no such page was found here. 6 | {% endblock %} 7 | -------------------------------------------------------------------------------- /tox.ini: -------------------------------------------------------------------------------- 1 | [pytest] 2 | python_files= werkzeug/testsuite/*.py 3 | 4 | [tox] 5 | envlist=py26,py27,pypy,py33 6 | 7 | [testenv] 8 | deps= 9 | greenlet 10 | redis 11 | pymemc 12 | commands= 13 | python ./run-tests.py [] 14 | -------------------------------------------------------------------------------- /examples/couchy/templates/display.html: -------------------------------------------------------------------------------- 1 | {% extends 'layout.html' %} 2 | {% block body %} 3 |
5 | The URL {{ url.target|urlize(40, true) }} 6 | was shortened to {{ url.short_url|urlize }}. 7 |
8 | {% endblock %} 9 | -------------------------------------------------------------------------------- /examples/i18nurls/templates/index.html: -------------------------------------------------------------------------------- 1 |Hello in the i18n URL example application.
2 |Because I'm too lazy to translate here is just english content.
3 |5 | The URL {{ url.target|urlize(40, true) }} 6 | was shortened to {{ url.short_url|urlize }}. 7 |
8 | {% endblock %} 9 | -------------------------------------------------------------------------------- /examples/couchy/README: -------------------------------------------------------------------------------- 1 | couchy README 2 | 3 | Requirements : 4 | - werkzeug : http://werkzeug.pocoo.org 5 | - jinja : http://jinja.pocoo.org 6 | - couchdb 0.72 & above : http://www.couchdb.org 7 | - couchdb-python 0.3 & above : http://code.google.com/p/couchdb-python 8 | 9 | -------------------------------------------------------------------------------- /docs/contrib/profiler.rst: -------------------------------------------------------------------------------- 1 | ========================= 2 | WSGI Application Profiler 3 | ========================= 4 | 5 | .. automodule:: werkzeug.contrib.profiler 6 | 7 | .. autoclass:: MergeStream 8 | 9 | .. autoclass:: ProfilerMiddleware 10 | 11 | .. autofunction:: make_action 12 | -------------------------------------------------------------------------------- /examples/couchy/templates/not_found.html: -------------------------------------------------------------------------------- 1 | {% extends 'layout.html' %} 2 | {% block body %} 3 |5 | The page you have requested does not exist on this server. What about 6 | adding a new URL? 7 |
8 | {% endblock %} 9 | -------------------------------------------------------------------------------- /examples/shorty/templates/not_found.html: -------------------------------------------------------------------------------- 1 | {% extends 'layout.html' %} 2 | {% block body %} 3 |5 | The page you have requested does not exist on this server. What about 6 | adding a new URL? 7 |
8 | {% endblock %} 9 | -------------------------------------------------------------------------------- /docs/_static/werkzeug.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | Werkzeug = {}; 3 | 4 | $(function() { 5 | $('#toc h3').click(function() { 6 | $(this).next().slideToggle(); 7 | $(this).parent().toggleClass('toc-collapsed'); 8 | }).next().hide().parent().addClass('toc-collapsed'); 9 | }); 10 | })(); 11 | -------------------------------------------------------------------------------- /docs/_themes/werkzeug/layout.html: -------------------------------------------------------------------------------- 1 | {%- extends "basic/layout.html" %} 2 | {%- block relbar2 %}{% endblock %} 3 | {%- block footer %} 4 | 8 | {%- endblock %} 9 | -------------------------------------------------------------------------------- /examples/plnt/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | plnt 4 | ~~~~ 5 | 6 | Noun. plnt (plant) -- a planet application that sounds like a herb. 7 | 8 | :copyright: (c) 2009 by the Werkzeug Team, see AUTHORS for more details. 9 | :license: BSD. 10 | """ 11 | from plnt.webapp import Plnt 12 | -------------------------------------------------------------------------------- /examples/coolmagic/templates/static/about.html: -------------------------------------------------------------------------------- 1 | {% extends "layout.html" %} 2 | {% set page_title = 'About the Magic' %} 3 | {% block page_body %} 4 |5 | Nothing to see. It's just magic. 6 |
7 |8 | back to the index 9 |
10 | {% endblock %} 11 | -------------------------------------------------------------------------------- /examples/coolmagic/views/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | coolmagic.views 4 | ~~~~~~~~~~~~~~~ 5 | 6 | This module collects and assambles the urls. 7 | 8 | :copyright: (c) 2009 by the Werkzeug Team, see AUTHORS for more details. 9 | :license: BSD, see LICENSE for more details. 10 | """ 11 | -------------------------------------------------------------------------------- /examples/cupoftee/templates/missingpage.html: -------------------------------------------------------------------------------- 1 |3 | The requested page does not exist on this server. If you expect something 4 | here (for example a server) it probably went away after the last update. 5 |
6 |7 | go back to the server list. 8 |
9 | -------------------------------------------------------------------------------- /docs/contrib/fixers.rst: -------------------------------------------------------------------------------- 1 | ====== 2 | Fixers 3 | ====== 4 | 5 | .. automodule:: werkzeug.contrib.fixers 6 | 7 | .. autoclass:: CGIRootFix 8 | 9 | .. autoclass:: PathInfoFromRequestUriFix 10 | 11 | .. autoclass:: ProxyFix 12 | :members: 13 | 14 | .. autoclass:: HeaderRewriterFix 15 | 16 | .. autoclass:: InternetExplorerFix 17 | -------------------------------------------------------------------------------- /examples/coolmagic/templates/static/not_found.html: -------------------------------------------------------------------------------- 1 | {% extends "layout.html" %} 2 | {% set page_title = 'Missing Magic' %} 3 | {% block page_body %} 4 |5 | The requested magic really does not exist. Maybe you want 6 | to look for it on the index. 7 |
8 | {% endblock %} 9 | -------------------------------------------------------------------------------- /examples/coolmagic/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | coolmagic 4 | ~~~~~~~~~ 5 | 6 | Package description goes here. 7 | 8 | :copyright: (c) 2009 by the Werkzeug Team, see AUTHORS for more details. 9 | :license: BSD, see LICENSE for more details. 10 | """ 11 | from coolmagic.application import make_app 12 | -------------------------------------------------------------------------------- /examples/cupoftee/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | cupoftee 4 | ~~~~~~~~ 5 | 6 | Werkzeug powered Teeworlds Server Browser. 7 | 8 | :copyright: (c) 2009 by the Werkzeug Team, see AUTHORS for more details. 9 | :license: BSD, see LICENSE for more details. 10 | """ 11 | from cupoftee.application import make_app 12 | -------------------------------------------------------------------------------- /examples/shortly/templates/layout.html: -------------------------------------------------------------------------------- 1 | 2 |Shortly is a URL shortener written with Werkzeug 7 | {% block body %}{% endblock %} 8 |
5 | Welcome to the magic! This is a bigger example for the 6 | Werkzeug toolkit. And it contains a lot of magic. 7 |
8 |9 | about the implementation or 10 | click here if you want to see a broken view. 12 |
13 | {% endblock %} 14 | -------------------------------------------------------------------------------- /docs/contrib/wrappers.rst: -------------------------------------------------------------------------------- 1 | ============== 2 | Extra Wrappers 3 | ============== 4 | 5 | .. automodule:: werkzeug.contrib.wrappers 6 | 7 | .. autoclass:: JSONRequestMixin 8 | :members: 9 | 10 | .. autoclass:: ProtobufRequestMixin 11 | :members: 12 | 13 | .. autoclass:: RoutingArgsRequestMixin 14 | :members: 15 | 16 | .. autoclass:: ReverseSlashBehaviorRequestMixin 17 | :members: 18 | 19 | .. autoclass:: DynamicCharsetRequestMixin 20 | :members: 21 | 22 | .. autoclass:: DynamicCharsetResponseMixin 23 | :members: 24 | -------------------------------------------------------------------------------- /examples/manage-couchy.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from werkzeug import script 3 | 4 | def make_app(): 5 | from couchy.application import Couchy 6 | return Couchy('http://localhost:5984') 7 | 8 | def make_shell(): 9 | from couchy import models, utils 10 | application = make_app() 11 | return locals() 12 | 13 | action_runserver = script.make_runserver(make_app, use_reloader=True) 14 | action_shell = script.make_shell(make_shell) 15 | action_initdb = lambda: make_app().init_database() 16 | 17 | script.run() 18 | -------------------------------------------------------------------------------- /examples/manage-cupoftee.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """ 3 | Manage Cup Of Tee 4 | ~~~~~~~~~~~~~~~~~ 5 | 6 | Manage the cup of tee application. 7 | 8 | :copyright: (c) 2009 by the Werkzeug Team, see AUTHORS for more details. 9 | :license: BSD, see LICENSE for more details. 10 | """ 11 | from werkzeug import script 12 | 13 | 14 | def make_app(): 15 | from cupoftee import make_app 16 | return make_app('/tmp/cupoftee.db') 17 | action_runserver = script.make_runserver(make_app) 18 | 19 | script.run() 20 | -------------------------------------------------------------------------------- /examples/simplewiki/templates/missing_action.html: -------------------------------------------------------------------------------- 1 | 2 |The requested action does not exist.
10 |Try to access the same URL without parameters.
11 | 12 | 13 | -------------------------------------------------------------------------------- /werkzeug/testsuite/contrib/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | werkzeug.testsuite.contrib 4 | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5 | 6 | Tests the contrib modules. 7 | 8 | :copyright: (c) 2013 by Armin Ronacher. 9 | :license: BSD, see LICENSE for more details. 10 | """ 11 | import unittest 12 | from werkzeug.testsuite import iter_suites 13 | 14 | 15 | def suite(): 16 | suite = unittest.TestSuite() 17 | for other_suite in iter_suites(__name__): 18 | suite.addTest(other_suite) 19 | return suite 20 | -------------------------------------------------------------------------------- /docs/middlewares.rst: -------------------------------------------------------------------------------- 1 | =========== 2 | Middlewares 3 | =========== 4 | 5 | .. module:: werkzeug.wsgi 6 | 7 | Middlewares wrap applications to dispatch between then or provide 8 | additional request handling. Additionally to the middlewares documented 9 | here, there is also the :class:`DebuggedApplication` class that is 10 | implemented as a WSGI middleware. 11 | 12 | .. autoclass:: SharedDataMiddleware 13 | :members: is_allowed 14 | 15 | .. autoclass:: DispatcherMiddleware 16 | 17 | Also there's the … 18 | 19 | .. autofunction:: werkzeug._internal._easteregg 20 | -------------------------------------------------------------------------------- /examples/coolmagic/helpers.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | coolmagic.helpers 4 | ~~~~~~~~~~~~~~~~~ 5 | 6 | The star-import module for all views. 7 | 8 | :copyright: (c) 2009 by the Werkzeug Team, see AUTHORS for more details. 9 | :license: BSD, see LICENSE for more details. 10 | """ 11 | from coolmagic.utils import Response, TemplateResponse, ThreadedRequest, \ 12 | export, url_for, redirect 13 | from werkzeug.utils import escape 14 | 15 | 16 | #: a thread local proxy request object 17 | request = ThreadedRequest() 18 | del ThreadedRequest 19 | -------------------------------------------------------------------------------- /examples/manage-i18nurls.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | """ 4 | Manage i18nurls 5 | ~~~~~~~~~~~~~~~ 6 | 7 | Manage the i18n url example application. 8 | 9 | :copyright: (c) 2009 by the Werkzeug Team, see AUTHORS for more details. 10 | :license: BSD, see LICENSE for more details. 11 | """ 12 | import os 13 | from i18nurls import make_app 14 | from werkzeug import script 15 | 16 | action_runserver = script.make_runserver(make_app) 17 | action_shell = script.make_shell(lambda: {}) 18 | 19 | if __name__ == '__main__': 20 | script.run() 21 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include Makefile CHANGES LICENSE AUTHORS 2 | recursive-include werkzeug/debug/shared * 3 | recursive-include werkzeug/debug/templates * 4 | recursive-include werkzeug/testsuite/res * 5 | recursive-include werkzeug/testsuite/multipart * 6 | recursive-include tests * 7 | recursive-include docs * 8 | recursive-include examples * 9 | recursive-exclude docs *.pyc 10 | recursive-exclude docs *.pyo 11 | recursive-exclude tests *.pyc 12 | recursive-exclude tests *.pyo 13 | recursive-exclude examples *.pyc 14 | recursive-exclude examples *.pyo 15 | recursive-include artwork * 16 | prune docs/_build 17 | -------------------------------------------------------------------------------- /examples/manage-coolmagic.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | """ 4 | Manage Coolmagic 5 | ~~~~~~~~~~~~~~~~ 6 | 7 | Manage the coolmagic example application. 8 | 9 | :copyright: (c) 2009 by the Werkzeug Team, see AUTHORS for more details. 10 | :license: BSD, see LICENSE for more details. 11 | """ 12 | import os 13 | from coolmagic import make_app 14 | from werkzeug import script 15 | 16 | action_runserver = script.make_runserver(make_app, use_reloader=True) 17 | action_shell = script.make_shell(lambda: {}) 18 | 19 | if __name__ == '__main__': 20 | script.run() 21 | -------------------------------------------------------------------------------- /examples/couchy/templates/layout.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 |10 | Request Language: $req.language 11 |
12 | $body 13 |14 |21 | 22 | 23 | -------------------------------------------------------------------------------- /docs/_themes/werkzeug/relations.html: -------------------------------------------------------------------------------- 1 |This page in other languages: 15 |
16 | <% for lng in ['en', 'de', 'fr'] %> 17 |
20 |- $lng
18 | <% endfor %> 19 |
3 | Werkzeug is a WSGI utility library. It can serve as the basis for a 4 | custom framework. 5 |
6 |8 | You can download the documentation in other formats as well: 9 |
10 |6 | Plnt is a small example application written using the 7 | Werkzeug WSGI toolkit, 8 | the Jinja template language, 9 | the SQLAlchemy database abstraction 10 | layer and ORM and last but not least the awesome 11 | feedparser library. 12 |
13 |14 | It's one of the example applications developed to show some of the 15 | features werkzeug provides and could be the base of a real planet 16 | software. 17 |
18 |This is the Plnt Planet Werkzeug Example Application9 |
The page you requested does not exist.
12 |13 | It also could be that there is no such revision of that page. 14 |
15 |16 | Feel free to create such a page. 18 |
19 |20 | Although this page does not exist by now you cannot create it because 21 | the system protected the page name for future use. 22 |
23 | 24 | 25 | -------------------------------------------------------------------------------- /examples/manage-webpylike.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | """ 4 | Manage web.py like application 5 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6 | 7 | A small example application that is built after the web.py tutorial. We 8 | even use regular expression based dispatching. The original code can be 9 | found on the `webpy.org webpage`__ in the tutorial section. 10 | 11 | __ http://webpy.org/tutorial2.en 12 | 13 | :copyright: (c) 2009 by the Werkzeug Team, see AUTHORS for more details. 14 | :license: BSD, see LICENSE for more details. 15 | """ 16 | import os 17 | import sys 18 | sys.path.append(os.path.join(os.path.dirname(__file__), 'webpylike')) 19 | from example import app 20 | from werkzeug import script 21 | 22 | action_runserver = script.make_runserver(lambda: app) 23 | action_shell = script.make_shell(lambda: {}) 24 | 25 | if __name__ == '__main__': 26 | script.run() 27 | -------------------------------------------------------------------------------- /examples/cupoftee/templates/server.html: -------------------------------------------------------------------------------- 1 |3 | Take me back to the server list. 4 |
5 || Date | 14 |Page | 15 |Change Note | 16 |
|---|---|---|
| ${format_datetime(entry.timestamp)} | 20 |${entry.title} | 21 |${entry.change_note} | 22 |
13 | Below you can see the differences between the revision from 14 | ${format_datetime(old_revision.timestamp)} and the 16 | revision from ${format_datetime(new_revision.timestamp)} in unified 18 | diff format. 19 |
20 |${diff}
21 | ${error}
25 |13 | You can now ${new and 'create' or 'modify'} the page contents. To 14 | format your text you can use creole markup. 15 |
16 |${error}
17 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /examples/cupoftee/templates/search.html: -------------------------------------------------------------------------------- 1 |18 | The nickname "$escape(user)" is currently playing on the 19 | following ${len(results) == 1 and 'server' or 'servers'}: 20 |
21 |28 | The nickname "$escape(user)" is currently not playing. 29 |
30 | <% endif %> 31 |32 | You can bookmark this link 33 | to search for "$escape(user)" quickly or return 34 | to the server list. 35 |
36 | <% endif %> 37 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Werkzeug Makefile 3 | # ~~~~~~~~~~~~~~~~~ 4 | # 5 | # Shortcuts for various tasks. 6 | # 7 | # :copyright: (c) 2008 by the Werkzeug Team, see AUTHORS for more details. 8 | # :license: BSD, see LICENSE for more details. 9 | # 10 | 11 | documentation: 12 | @(cd docs; make html) 13 | 14 | release: 15 | python scripts/make-release.py 16 | 17 | test: 18 | python run-tests.py 19 | 20 | tox-test: 21 | tox 22 | 23 | coverage: 24 | @(nosetests $(TEST_OPTIONS) --with-coverage --cover-package=werkzeug --cover-html --cover-html-dir=coverage_out $(TESTS)) 25 | 26 | doctest: 27 | @(cd docs; sphinx-build -b doctest . _build/doctest) 28 | 29 | upload-docs: 30 | $(MAKE) -C docs html dirhtml latex 31 | $(MAKE) -C docs/_build/latex all-pdf 32 | cd docs/_build/; mv html werkzeug-docs; zip -r werkzeug-docs.zip werkzeug-docs; mv werkzeug-docs html 33 | rsync -a docs/_build/dirhtml/ pocoo.org:/var/www/werkzeug.pocoo.org/docs/ 34 | rsync -a docs/_build/latex/Werkzeug.pdf pocoo.org:/var/www/werkzeug.pocoo.org/docs/werkzeug-docs.pdf 35 | rsync -a docs/_build/werkzeug-docs.zip pocoo.org:/var/www/werkzeug.pocoo.org/docs/werkzeug-docs.zip 36 | -------------------------------------------------------------------------------- /examples/shorty/models.py: -------------------------------------------------------------------------------- 1 | from datetime import datetime 2 | from sqlalchemy import Table, Column, String, Boolean, DateTime 3 | from sqlalchemy.orm import mapper 4 | from shorty.utils import session, metadata, url_for, get_random_uid 5 | 6 | url_table = Table('urls', metadata, 7 | Column('uid', String(140), primary_key=True), 8 | Column('target', String(500)), 9 | Column('added', DateTime), 10 | Column('public', Boolean) 11 | ) 12 | 13 | class URL(object): 14 | query = session.query_property() 15 | 16 | def __init__(self, target, public=True, uid=None, added=None): 17 | self.target = target 18 | self.public = public 19 | self.added = added or datetime.utcnow() 20 | if not uid: 21 | while 1: 22 | uid = get_random_uid() 23 | if not URL.query.get(uid): 24 | break 25 | self.uid = uid 26 | session.add(self) 27 | 28 | @property 29 | def short_url(self): 30 | return url_for('link', uid=self.uid, _external=True) 31 | 32 | def __repr__(self): 33 | return '13 | If you want to restore the old revision from 14 | ${format_datetime(old_revision.timestamp)} enter your change 16 | note and click “Revert”. 17 |
18 | 25 |${error}
29 |This is a new session.
' 32 | session['visit_count'] += 1 33 | yield 'You visited this page %d times.
' % session['visit_count'] 34 | 35 | 36 | def make_app(): 37 | return SessionMiddleware(application, MemorySessionStore()) 38 | 39 | 40 | if __name__ == '__main__': 41 | run_simple('localhost', 5000, make_app()) 42 | -------------------------------------------------------------------------------- /examples/couchy/models.py: -------------------------------------------------------------------------------- 1 | from datetime import datetime 2 | from couchdb.schema import Document, TextField, BooleanField, DateTimeField 3 | from couchy.utils import url_for, get_random_uid 4 | 5 | 6 | class URL(Document): 7 | target = TextField() 8 | public = BooleanField() 9 | added = DateTimeField(default=datetime.utcnow()) 10 | shorty_id = TextField(default=None) 11 | db = None 12 | 13 | @classmethod 14 | def load(self, id): 15 | return super(URL, self).load(URL.db, id) 16 | 17 | @classmethod 18 | def query(self, code): 19 | return URL.db.query(code) 20 | 21 | def store(self): 22 | if getattr(self._data, 'id', None) is None: 23 | new_id = self.shorty_id if self.shorty_id else None 24 | while 1: 25 | id = new_id if new_id else get_random_uid() 26 | docid = None 27 | try: 28 | docid = URL.db.resource.put(content=self._data, path='/%s/' % str(id))['id'] 29 | except: 30 | continue 31 | if docid: 32 | break 33 | self._data = URL.db.get(docid) 34 | else: 35 | super(URL, self).store(URL.db) 36 | return self 37 | 38 | @property 39 | def short_url(self): 40 | return url_for('link', uid=self.id, _external=True) 41 | 42 | def __repr__(self): 43 | return '12 | In this list you can see all the revisions of the requested page. 13 |
14 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /examples/shorty/views.py: -------------------------------------------------------------------------------- 1 | from werkzeug.utils import redirect 2 | from werkzeug.exceptions import NotFound 3 | from shorty.utils import session, Pagination, render_template, expose, \ 4 | validate_url, url_for 5 | from shorty.models import URL 6 | 7 | @expose('/') 8 | def new(request): 9 | error = url = '' 10 | if request.method == 'POST': 11 | url = request.form.get('url') 12 | alias = request.form.get('alias') 13 | if not validate_url(url): 14 | error = "I'm sorry but you cannot shorten this URL." 15 | elif alias: 16 | if len(alias) > 140: 17 | error = 'Your alias is too long' 18 | elif '/' in alias: 19 | error = 'Your alias might not include a slash' 20 | elif URL.query.get(alias): 21 | error = 'The alias you have requested exists already' 22 | if not error: 23 | uid = URL(url, 'private' not in request.form, alias).uid 24 | session.commit() 25 | return redirect(url_for('display', uid=uid)) 26 | return render_template('new.html', error=error, url=url) 27 | 28 | @expose('/display/3 | Currently $len(players) players are playing on 4 | $len(servers) servers. 5 | <% if cup.master.last_sync %> 6 | This list was last synced on 7 | $cup.master.last_sync.strftime('%d %B %Y at %H:%M UTC'). 8 | <% else %> 9 | Syncronization with master server in progress. Reload the page in a minute 10 | or two, to see the server list. 11 | <% endif %> 12 |
13 || $self.order_link('name', 'Name') | 17 |$self.order_link('map', 'Map') | 18 |$self.order_link('gametype', 'Gametype') | 19 |$self.order_link('players', 'Players') | 20 |$self.order_link('progression', 'Progression') | 21 |
|---|---|---|---|---|
| $escape(server.name) | 27 |$escape(server.map) | 28 |$server.gametype | 29 |$server.player_count / $server.max_players | 30 |${server.progression >= 0 and '%d%%' % server.progression or '?'} | 31 |
37 | The following map represents the users playing currently. The bigger their name 38 | the higher their score in the current game. Clicking on the name takes you to 39 | the detail page of the server for some more information. 40 |
41 |49 | Find a user by username. The result page contains a link you can bookmark to 50 | find your buddy easily. Because currently there is no central user database 51 | users can appear on multiple servers for too generic usernames (like the 52 | default "nameless tee" user). 53 |
54 | 60 | -------------------------------------------------------------------------------- /examples/manage-plnt.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | """ 4 | Manage plnt 5 | ~~~~~~~~~~~ 6 | 7 | This script manages the plnt application. 8 | 9 | :copyright: (c) 2009 by the Werkzeug Team, see AUTHORS for more details. 10 | :license: BSD, see LICENSE for more details. 11 | """ 12 | import os 13 | from werkzeug import script 14 | 15 | 16 | def make_app(): 17 | """Helper function that creates a plnt app.""" 18 | from plnt import Plnt 19 | database_uri = os.environ.get('PLNT_DATABASE_URI') 20 | app = Plnt(database_uri or 'sqlite:////tmp/plnt.db') 21 | app.bind_to_context() 22 | return app 23 | 24 | 25 | action_runserver = script.make_runserver(make_app, use_reloader=True) 26 | action_shell = script.make_shell(lambda: {'app': make_app()}) 27 | 28 | 29 | def action_initdb(): 30 | """Initialize the database""" 31 | from plnt.database import Blog, session 32 | make_app().init_database() 33 | # and now fill in some python blogs everybody should read (shamelessly 34 | # added my own blog too) 35 | blogs = [ 36 | Blog('Armin Ronacher', 'http://lucumr.pocoo.org/', 37 | 'http://lucumr.pocoo.org/cogitations/feed/'), 38 | Blog('Georg Brandl', 'http://pyside.blogspot.com/', 39 | 'http://pyside.blogspot.com/feeds/posts/default'), 40 | Blog('Ian Bicking', 'http://blog.ianbicking.org/', 41 | 'http://blog.ianbicking.org/feed/'), 42 | Blog('Amir Salihefendic', 'http://amix.dk/', 43 | 'http://feeds.feedburner.com/amixdk'), 44 | Blog('Christopher Lenz', 'http://www.cmlenz.net/blog/', 45 | 'http://www.cmlenz.net/blog/atom.xml'), 46 | Blog('Frederick Lundh', 'http://online.effbot.org/', 47 | 'http://online.effbot.org/rss.xml') 48 | ] 49 | # okay. got tired here. if someone feels that he is missing, drop me 50 | # a line ;-) 51 | for blog in blogs: 52 | session.add(blog) 53 | session.commit() 54 | print 'Initialized database, now run manage-plnt.py sync to get the posts' 55 | 56 | 57 | def action_sync(): 58 | """Sync the blogs in the planet. Call this from a cronjob.""" 59 | from plnt.sync import sync 60 | make_app().bind_to_context() 61 | sync() 62 | 63 | 64 | if __name__ == '__main__': 65 | script.run() 66 | -------------------------------------------------------------------------------- /werkzeug/testsuite/contrib/sessions.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | werkzeug.testsuite.sessions 4 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5 | 6 | Added tests for the sessions. 7 | 8 | :copyright: (c) 2013 by Armin Ronacher. 9 | :license: BSD, see LICENSE for more details. 10 | """ 11 | import unittest 12 | import shutil 13 | from tempfile import mkdtemp, gettempdir 14 | 15 | from werkzeug.testsuite import WerkzeugTestCase 16 | from werkzeug.contrib.sessions import FilesystemSessionStore 17 | 18 | 19 | 20 | class SessionTestCase(WerkzeugTestCase): 21 | 22 | def setup(self): 23 | self.session_folder = mkdtemp() 24 | 25 | def teardown(self): 26 | shutil.rmtree(self.session_folder) 27 | 28 | def test_default_tempdir(self): 29 | store = FilesystemSessionStore() 30 | assert store.path == gettempdir() 31 | 32 | def test_basic_fs_sessions(self): 33 | store = FilesystemSessionStore(self.session_folder) 34 | x = store.new() 35 | assert x.new 36 | assert not x.modified 37 | x['foo'] = [1, 2, 3] 38 | assert x.modified 39 | store.save(x) 40 | 41 | x2 = store.get(x.sid) 42 | assert not x2.new 43 | assert not x2.modified 44 | assert x2 is not x 45 | assert x2 == x 46 | x2['test'] = 3 47 | assert x2.modified 48 | assert not x2.new 49 | store.save(x2) 50 | 51 | x = store.get(x.sid) 52 | store.delete(x) 53 | x2 = store.get(x.sid) 54 | # the session is not new when it was used previously. 55 | assert not x2.new 56 | 57 | def test_renewing_fs_session(self): 58 | store = FilesystemSessionStore(self.session_folder, renew_missing=True) 59 | x = store.new() 60 | store.save(x) 61 | store.delete(x) 62 | x2 = store.get(x.sid) 63 | assert x2.new 64 | 65 | def test_fs_session_lising(self): 66 | store = FilesystemSessionStore(self.session_folder, renew_missing=True) 67 | sessions = set() 68 | for x in range(10): 69 | sess = store.new() 70 | store.save(sess) 71 | sessions.add(sess.sid) 72 | 73 | listed_sessions = set(store.list()) 74 | assert sessions == listed_sessions 75 | 76 | 77 | def suite(): 78 | suite = unittest.TestSuite() 79 | suite.addTest(unittest.makeSuite(SessionTestCase)) 80 | return suite 81 | -------------------------------------------------------------------------------- /examples/couchy/utils.py: -------------------------------------------------------------------------------- 1 | from os import path 2 | from urlparse import urlparse 3 | from random import sample, randrange 4 | from jinja import Environment, FileSystemLoader 5 | from werkzeug.local import Local, LocalManager 6 | from werkzeug.utils import cached_property 7 | from werkzeug.wrappers import Response 8 | from werkzeug.routing import Map, Rule 9 | 10 | TEMPLATE_PATH = path.join(path.dirname(__file__), 'templates') 11 | STATIC_PATH = path.join(path.dirname(__file__), 'static') 12 | ALLOWED_SCHEMES = frozenset(['http', 'https', 'ftp', 'ftps']) 13 | URL_CHARS = 'abcdefghijkmpqrstuvwxyzABCDEFGHIJKLMNPQRST23456789' 14 | 15 | local = Local() 16 | local_manager = LocalManager([local]) 17 | application = local('application') 18 | 19 | url_map = Map([Rule('/static/Invalid credentials' 72 | return Response(''' 73 |
Not logged in. 75 | %s 76 |
''' % error, mimetype='text/html') 83 | 84 | 85 | def index(request): 86 | return Response(''' 87 |Logged in as %s 90 |
Logout
91 | ''' % escape(request.user), mimetype='text/html')
92 |
93 |
94 | @AppRequest.application
95 | def application(request):
96 | if request.args.get('do') == 'logout':
97 | request.logout()
98 | response = redirect('.')
99 | elif request.logged_in:
100 | response = index(request)
101 | else:
102 | response = login_form(request)
103 | request.session.save_cookie(response)
104 | return response
105 |
106 |
107 | if __name__ == '__main__':
108 | run_simple('localhost', 4000, application)
109 |
--------------------------------------------------------------------------------
/werkzeug/testsuite/exceptions.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | werkzeug.testsuite.exceptions
4 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5 |
6 | The tests for the exception classes.
7 |
8 | TODO:
9 |
10 | - This is undertested. HTML is never checked
11 |
12 | :copyright: (c) 2013 by Armin Ronacher.
13 | :license: BSD, see LICENSE for more details.
14 | """
15 | import unittest
16 |
17 | from werkzeug.testsuite import WerkzeugTestCase
18 |
19 | from werkzeug import exceptions
20 | from werkzeug.wrappers import Response
21 | from werkzeug._compat import text_type
22 |
23 |
24 | class ExceptionsTestCase(WerkzeugTestCase):
25 |
26 | def test_proxy_exception(self):
27 | orig_resp = Response('Hello World')
28 | try:
29 | exceptions.abort(orig_resp)
30 | except exceptions.HTTPException as e:
31 | resp = e.get_response({})
32 | else:
33 | self.fail('exception not raised')
34 | self.assert_true(resp is orig_resp)
35 | self.assert_equal(resp.get_data(), b'Hello World')
36 |
37 | def test_aborter(self):
38 | abort = exceptions.abort
39 | self.assert_raises(exceptions.BadRequest, abort, 400)
40 | self.assert_raises(exceptions.Unauthorized, abort, 401)
41 | self.assert_raises(exceptions.Forbidden, abort, 403)
42 | self.assert_raises(exceptions.NotFound, abort, 404)
43 | self.assert_raises(exceptions.MethodNotAllowed, abort, 405, ['GET', 'HEAD'])
44 | self.assert_raises(exceptions.NotAcceptable, abort, 406)
45 | self.assert_raises(exceptions.RequestTimeout, abort, 408)
46 | self.assert_raises(exceptions.Gone, abort, 410)
47 | self.assert_raises(exceptions.LengthRequired, abort, 411)
48 | self.assert_raises(exceptions.PreconditionFailed, abort, 412)
49 | self.assert_raises(exceptions.RequestEntityTooLarge, abort, 413)
50 | self.assert_raises(exceptions.RequestURITooLarge, abort, 414)
51 | self.assert_raises(exceptions.UnsupportedMediaType, abort, 415)
52 | self.assert_raises(exceptions.UnprocessableEntity, abort, 422)
53 | self.assert_raises(exceptions.InternalServerError, abort, 500)
54 | self.assert_raises(exceptions.NotImplemented, abort, 501)
55 | self.assert_raises(exceptions.BadGateway, abort, 502)
56 | self.assert_raises(exceptions.ServiceUnavailable, abort, 503)
57 |
58 | myabort = exceptions.Aborter({1: exceptions.NotFound})
59 | self.assert_raises(LookupError, myabort, 404)
60 | self.assert_raises(exceptions.NotFound, myabort, 1)
61 |
62 | myabort = exceptions.Aborter(extra={1: exceptions.NotFound})
63 | self.assert_raises(exceptions.NotFound, myabort, 404)
64 | self.assert_raises(exceptions.NotFound, myabort, 1)
65 |
66 | def test_exception_repr(self):
67 | exc = exceptions.NotFound()
68 | self.assert_equal(text_type(exc), '404: Not Found')
69 | self.assert_equal(repr(exc), "