├── .gitignore ├── .hgignore ├── .hgtags ├── .travis.yml ├── CHANGELOG ├── LICENSE ├── MANIFEST.in ├── README.rst ├── UPGRADING ├── ez_setup.py ├── pylons ├── __init__.py ├── commands.py ├── configuration.py ├── controllers │ ├── __init__.py │ ├── core.py │ ├── jsonrpc.py │ ├── util.py │ └── xmlrpc.py ├── decorators │ ├── __init__.py │ ├── cache.py │ ├── rest.py │ ├── secure.py │ └── util.py ├── docs │ ├── en │ │ ├── .gitignore │ │ ├── Makefile │ │ ├── _oldstatic │ │ │ ├── Pylons_Stack-Chainsaw-OSX.png │ │ │ ├── akhet.css │ │ │ ├── akhet.png │ │ │ ├── akhet_rev.png │ │ │ ├── akhetcats.jpg │ │ │ ├── akhettransaqua.png │ │ │ ├── at.png │ │ │ ├── babel_logo.png │ │ │ ├── background.png │ │ │ ├── default.css │ │ │ ├── doctraceback.gif │ │ │ ├── doctraceback.png │ │ │ ├── hellotemplate.png │ │ │ ├── helloworld.png │ │ │ ├── pygments.css │ │ │ ├── pylon1.jpg │ │ │ ├── pylon2.jpg │ │ │ ├── pylon3.jpg │ │ │ ├── pylon4.jpg │ │ │ ├── pylons_as_onion.ai │ │ │ ├── pylons_as_onion.png │ │ │ └── pylons_as_onion.svg │ │ ├── _oldtemplates │ │ │ ├── genindex.html │ │ │ ├── layout.html │ │ │ ├── modindex.html │ │ │ └── page.html │ │ ├── _static │ │ │ ├── Pylons_Stack-Chainsaw-OSX.png │ │ │ ├── akhet.png │ │ │ ├── akhet_rev.png │ │ │ ├── akhetcats.jpg │ │ │ ├── akhettransaqua.png │ │ │ ├── at.png │ │ │ ├── babel_logo.png │ │ │ ├── background.png │ │ │ ├── doctraceback.gif │ │ │ ├── doctraceback.png │ │ │ ├── hellotemplate.png │ │ │ ├── helloworld.png │ │ │ ├── pylon1.jpg │ │ │ ├── pylon2.jpg │ │ │ ├── pylon3.jpg │ │ │ ├── pylon4.jpg │ │ │ └── pylons_as_onion.png │ │ ├── advanced_models.rst │ │ ├── advanced_pylons │ │ │ ├── creating_paste_templates.rst │ │ │ ├── entry_points_and_plugins.rst │ │ │ ├── index.rst │ │ │ ├── paster.rst │ │ │ └── paster_commands.rst │ │ ├── caching.rst │ │ ├── concepts.rst │ │ ├── conf.py │ │ ├── configuration.rst │ │ ├── controllers.rst │ │ ├── debugging.rst │ │ ├── deployment.rst │ │ ├── events.rst │ │ ├── execution.rst │ │ ├── forms.rst │ │ ├── gettingstarted.rst │ │ ├── glossary.rst │ │ ├── helpers.rst │ │ ├── i18n.rst │ │ ├── index.rst │ │ ├── jython.rst │ │ ├── logging.rst │ │ ├── models.rst │ │ ├── modules │ │ │ ├── commands.rst │ │ │ ├── configuration.rst │ │ │ ├── controllers.rst │ │ │ ├── controllers_core.rst │ │ │ ├── controllers_util.rst │ │ │ ├── controllers_xmlrpc.rst │ │ │ ├── decorators.rst │ │ │ ├── decorators_cache.rst │ │ │ ├── decorators_rest.rst │ │ │ ├── decorators_secure.rst │ │ │ ├── error.rst │ │ │ ├── i18n_translation.rst │ │ │ ├── index.rst │ │ │ ├── log.rst │ │ │ ├── middleware.rst │ │ │ ├── templating.rst │ │ │ ├── test.rst │ │ │ ├── util.rst │ │ │ └── wsgiapp.rst │ │ ├── objects.inv │ │ ├── python23_install.rst │ │ ├── security_policy_for_bugs.rst │ │ ├── sessions.rst │ │ ├── testing.rst │ │ ├── thirdparty │ │ │ ├── formencode_api.rst │ │ │ ├── index.rst │ │ │ ├── weberror.rst │ │ │ ├── webob.rst │ │ │ └── webtest.rst │ │ ├── tutorials │ │ │ ├── index.rst │ │ │ ├── quickwiki_tutorial.rst │ │ │ └── understanding_unicode.rst │ │ ├── upgrading.rst │ │ ├── views.rst │ │ ├── windowsnotes.rst │ │ └── wsgi_support.rst │ └── uploader.py ├── error.py ├── i18n │ ├── __init__.py │ └── translation.py ├── log.py ├── media │ ├── img │ │ ├── bar-bg.png │ │ ├── bg.jpg │ │ ├── bg.png │ │ ├── favicon.ico │ │ ├── hatch-yellow.png │ │ ├── header.png │ │ ├── highlight.png │ │ ├── logo.gif │ │ ├── main-nav-bg-on.png │ │ ├── main-nav-bg.png │ │ ├── plus.jpg │ │ ├── pylons-logo.gif │ │ ├── pylons-powered-02.png │ │ ├── tab-brown.png │ │ ├── tab-traceback.png │ │ ├── tab-white.png │ │ ├── tab-yellow-highlight.png │ │ ├── tab-yellow.png │ │ └── warning.gif │ ├── javascripts │ │ └── traceback.js │ └── style │ │ ├── black.css │ │ ├── itraceback.css │ │ └── orange.css ├── middleware.py ├── templates │ ├── __init__.py │ ├── controller.py_tmpl │ ├── default_project │ │ ├── +package+ │ │ │ ├── __init__.py_tmpl │ │ │ ├── config │ │ │ │ ├── __init__.py_tmpl │ │ │ │ ├── deployment.ini_tmpl_tmpl │ │ │ │ ├── environment.py_tmpl │ │ │ │ ├── middleware.py_tmpl │ │ │ │ └── routing.py_tmpl │ │ │ ├── controllers │ │ │ │ ├── __init__.py_tmpl │ │ │ │ └── error.py_tmpl │ │ │ ├── lib │ │ │ │ ├── __init__.py_tmpl │ │ │ │ ├── app_globals.py_tmpl │ │ │ │ ├── base.py_tmpl │ │ │ │ └── helpers.py_tmpl │ │ │ ├── model │ │ │ │ ├── __init__.py_tmpl │ │ │ │ └── meta.py_tmpl │ │ │ ├── public │ │ │ │ ├── bg.png │ │ │ │ ├── favicon.ico │ │ │ │ ├── index.html_tmpl │ │ │ │ └── pylons-logo.gif │ │ │ ├── templates │ │ │ │ ├── .distutils_placeholder │ │ │ │ └── __init__.py_tmpl │ │ │ ├── tests │ │ │ │ ├── __init__.py_tmpl │ │ │ │ ├── functional │ │ │ │ │ └── __init__.py_tmpl │ │ │ │ └── test_models.py_tmpl │ │ │ └── websetup.py_tmpl │ │ ├── MANIFEST.in_tmpl │ │ ├── README.txt_tmpl │ │ ├── development.ini_tmpl │ │ ├── ez_setup.py │ │ ├── setup.cfg_tmpl │ │ ├── setup.py_tmpl │ │ └── test.ini_tmpl │ ├── minimal_project │ │ ├── +package+ │ │ │ ├── __init__.py_tmpl │ │ │ ├── config │ │ │ │ └── deployment.ini_tmpl_tmpl │ │ │ ├── controllers │ │ │ │ └── __init__.py_tmpl │ │ │ ├── helpers.py_tmpl │ │ │ ├── public │ │ │ │ ├── bg.png │ │ │ │ ├── favicon.ico │ │ │ │ ├── index.html_tmpl │ │ │ │ └── pylons-logo.gif │ │ │ ├── routing.py_tmpl │ │ │ ├── templates │ │ │ │ ├── .distutils_placeholder │ │ │ │ └── __init__.py_tmpl │ │ │ ├── tests │ │ │ │ └── __init__.py_tmpl │ │ │ └── wsgiapp.py_tmpl │ │ ├── MANIFEST.in_tmpl │ │ ├── README.txt_tmpl │ │ ├── development.ini_tmpl │ │ ├── ez_setup.py │ │ ├── setup.cfg_tmpl │ │ ├── setup.py_tmpl │ │ └── test.ini_tmpl │ ├── restcontroller.py_tmpl │ ├── test_controller.py_tmpl │ └── test_restcontroller.py_tmpl ├── templating.py ├── test.py ├── testutil.py ├── url.py ├── util.py └── wsgiapp.py ├── rtd.txt ├── scripts ├── gen-go-pylons.py ├── go-pylons.py └── pylintrc ├── setup.cfg ├── setup.py ├── test_files ├── __init__.py ├── event_file.py └── sample_controllers │ ├── __init__.py │ ├── controllers │ ├── __init__.py │ ├── goodbye.py │ ├── hello.py │ └── i18nc.py │ ├── i18n │ ├── es │ │ └── LC_MESSAGES │ │ │ ├── sample_controllers.mo │ │ │ └── sample_controllers.po │ ├── fr │ │ └── LC_MESSAGES │ │ │ ├── sample_controllers.mo │ │ │ └── sample_controllers.po │ └── ja │ │ └── LC_MESSAGES │ │ ├── sample_controllers.mo │ │ └── sample_controllers.po │ └── templates │ ├── hello.html │ └── time.html └── tests ├── __init__.py ├── conftest.py ├── test_units ├── __init__.py ├── test_basic_app.py ├── test_controller.py ├── test_decorator_authenticate_form.py ├── test_decorator_cache.py ├── test_decorator_https.py ├── test_decorator_jsonify.py ├── test_decorator_validate.py ├── test_helpers.py ├── test_i18n.py ├── test_jsonrpc.py ├── test_middleware.py ├── test_templating.py └── test_xmlrpc.py └── test_webapps ├── __init__.py ├── filestotest ├── app_globals.py ├── base_with_xmlrpc.py ├── cache_controller.py ├── controller_sample.py ├── controller_sqlatest.py ├── controller_xmlrpc.py ├── development.ini ├── development_sqlatesting.ini ├── environment_def_engine.py ├── environment_def_sqlamodel.py ├── functional_controller_cache_decorator.py ├── functional_controller_xmlrpc.py ├── functional_sample_controller_i18n.py ├── functional_sample_controller_jinja2.py ├── functional_sample_controller_mako.py ├── functional_sample_controller_sample1.py ├── functional_sample_controller_sample2.py ├── functional_sample_controller_sample3.py ├── functional_sample_controller_sample4.py ├── functional_sample_controller_sqlatesting.py ├── helpers_sample.py ├── messages.ja.mo ├── messages.ja.po ├── messages.pot ├── middleware_mako.py ├── model__init__.py ├── rest_routing.py ├── test_mako.html ├── test_sqlalchemy.html ├── testgenshi.html ├── testjinja2.html ├── tests__init__.py └── websetup.py └── test_make_project.py /.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | *.egg-info 3 | *.egg 4 | tests/test_units/cache/ 5 | tests/test_units/session/ 6 | -------------------------------------------------------------------------------- /.hgignore: -------------------------------------------------------------------------------- 1 | 2 | # Automatically generated by `hgimportsvn` 3 | syntax:glob 4 | *.DS_Store 5 | .svn 6 | .coverage 7 | *.pyc 8 | *.egg-info 9 | *.egg 10 | ez_setup 11 | pylons/docs/*/_build 12 | container_file 13 | container_dbm* 14 | *~ 15 | build/ 16 | dist/ 17 | docs/html/docs 18 | output/ProjectName 19 | tests/html_coverage 20 | syntax: glob 21 | -------------------------------------------------------------------------------- /.hgtags: -------------------------------------------------------------------------------- 1 | b7002f68d541940f32fa5d5fecb83483008fd489 v0.9.6 2 | 88112f696d4aba81405753713ca06070a92ebcf9 v0.9.5 3 | 1bc21f0b2820a39801278b322aab939da893ed4d v0.9.4.1 4 | a8e89fafa6d836c5ec9de712db4afd68acd02b30 v0.9.4 5 | 896da05e4c2679f39756194d65c3e87eb92bc2f1 v0.9.3 6 | a71e37726e2909c358a6fb699f26a314643d1c89 v0.9.2 7 | 37614170faa944723382bf885023085bc3ece616 v0.9.1 8 | f650ccf099785af6be11d3e91f66e4dc5178dc1b v0.9 9 | 0da35cd7624a67c43948c00f60b35eb9202e2b8d v0.8.2 10 | 0fa5a7b12de0795c95a425e89d802f09e8e709ab v0.8.1 11 | 1880858f1fb30fbf4b1717ac49d172712dfc5b9d v0.8 12 | 9e6916dca073e83deb25ed401a928e834bc0d262 v0.9.6rc2 13 | f2b68bd9f177d08f8caf7e5d33629190d097fbc0 v0.9.6rc1 14 | f04d465aa10861b96c1050a4c6347c4aa12247c1 v0.9.6rc3 15 | a7749485525a8aade8dbe089abae9a539af24682 v0.9.7beta1 16 | 46c5edc17b643e07158dc4c6b5e14a7d839fe066 v0.9.7beta1 17 | 9cb761f0f0476dad15b370765919ae96a968fea4 v0.9.7beta2 18 | 3819db8d2307f8f5725b2a27c6a34e8f5738d687 v0.9.7beta3 19 | e546c53613c2c0647ab94ee0d376a5bc8e28dcb4 v0.9.7beta5 20 | ca3cbefec25e0e9ec7b579123cf97ed98934ccd8 v0.9.7rc1 21 | a6f56791a83a53db7a7484fb8bd8821ffba740c4 v0.9.7rc2 22 | 7ceef102aff2cce44634132d21638358b4129197 v0.9.7rc3 23 | 4a94734906711e56f9d34a34527f4b8a6e9811a8 v0.9.7rc4 24 | fa5aad0d57deb99f8a25596e9c7d601b1ced1d5d v0.9.7rc5 25 | e7a19deba3f66b4e6dfc050f070295a0a622308a v0.9.7rc6 26 | 2154554f4ffb458555023afd6e810ce88e58e64b v0.9.7 27 | 165565778a3c518d6b5c383095fffdf6e154fa78 v0.10b1 28 | 25eb46de0380e20799c419557a86c61f144101a2 v1.0b1 29 | cd08f0df626b89f3e6ee9df71539e009d9be1ba9 v0.10rc1 30 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: python 2 | python: 3 | - "2.6" 4 | - "2.7" 5 | install: 6 | - python setup.py develop 7 | script: 8 | - python setup.py test 9 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2005-2015 Ben Bangert, James Gardner, Philip Jenvey 2 | and contributors. 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions 7 | are met: 8 | 1. Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 2. Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | 3. The name of the author or contributors may not be used to endorse or 14 | promote products derived from this software without specific prior 15 | written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 21 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | SUCH DAMAGE. 28 | 29 | 30 | ------------------------------------------------------------------------------- 31 | ALL TEMPLATES GENERATED ARE COVERED UNDER THE FOLLOWING LICENSE: 32 | 33 | Copyright (c) 2005-2015 Ben Bangert, James Gardner, Philip Jenvey 34 | and contributors. 35 | All rights reserved. 36 | 37 | Redistribution and use in source and binary forms, with or without 38 | modification, are permitted provided that the following condition is 39 | met: 40 | The name of the author or contributors may not be used to endorse or 41 | promote products derived from this software without specific prior 42 | written permission. 43 | 44 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 45 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 46 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 47 | ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 48 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 49 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 50 | OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 51 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 52 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 53 | OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 54 | SUCH DAMAGE. 55 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | recursive-include pylons/templates * 2 | recursive-include pylons/media * 3 | recursive-include tests * 4 | recursive-include test_files * 5 | include CHANGELOG 6 | include LICENSE 7 | include UPGRADING 8 | recursive-exclude tests/test_units/session * 9 | global-exclude .DS_Store *.hgignore *.hgtags 10 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | Pylons 2 | ++++++ 3 | 4 | .. image:: https://secure.travis-ci.org/Pylons/pylons.png?branch=master 5 | :alt: Build Status 6 | :target: https://secure.travis-ci.org/Pylons/pylons 7 | 8 | Pylons is a rapid web application development framework. 9 | 10 | .. note:: 11 | 12 | Pylons has merged with repoze.bfg, and is now in maintenance-only 13 | mode. It's highly recommended that new projects start with the new 14 | merged web framework, `pyramid `_. 15 | 16 | Install 17 | ======= 18 | 19 | `Read the online Installation instructions 20 | `_. 21 | 22 | If you want to install from source you can run the following command: 23 | 24 | .. code-block :: bash 25 | 26 | $ python setup.py install 27 | 28 | This will display a message and download setuptools if the module is not 29 | already installed. It will then install Pylons and all its dependencies. You 30 | may need root privileges to install setuptools. 31 | 32 | Testing 33 | ======= 34 | 35 | To test the source distribution run the following command: 36 | 37 | .. code-block :: bash 38 | 39 | $ python setup.py test 40 | 41 | This will install additional dependencies needed for the tests. As above, you 42 | may need root privileges. 43 | 44 | Documentation 45 | ============= 46 | 47 | `Read the complete Pylons web framework documentation 48 | `_. 49 | 50 | `Definitive Guide to Pylons `_ is a book about Pylons published by Apress, written by James Gardner, with free HTML rendering. 51 | 52 | Generating documentation requires Sphinx: 53 | 54 | .. code-block :: bash 55 | 56 | $ easy_install Sphinx 57 | 58 | Then to build the documentation use the commands: 59 | 60 | .. code-block :: bash 61 | 62 | $ cd pylons/docs/ 63 | $ make html 64 | -------------------------------------------------------------------------------- /UPGRADING: -------------------------------------------------------------------------------- 1 | Upgrading your Pylons Project 2 | ============================= 3 | 4 | Pylons projects should be updated using the paster command create. In addition 5 | to creating new projects, paster create when run over an existing project will 6 | provide several ways to update the project template to the latest version. 7 | 8 | Using this tool properly can make upgrading a fairly minor task. For the 9 | purpose of this document, the project being upgraded will be called 'demoapp' 10 | and all commands will use that name. 11 | 12 | Running paster create to upgrade 13 | -------------------------------- 14 | 15 | You'll first need to cd to the directory *above* your projects main directory. 16 | The main directory is the one that contains your setup.py, setup.cfg, and 17 | development.ini files. 18 | 19 | .. code:: bash 20 | /home/joe/demoapp $ cd .. 21 | /home/joe $ 22 | 23 | Then run paster create on the project directory: 24 | 25 | .. code:: bash 26 | /home/joe $ paster create demoapp -t pylons 27 | 28 | paster will prompt you on how to handle conflicts and updates to the existing 29 | project files. The options let you (hit the key in the parens to perform the 30 | operation): 31 | 32 | (d)iff them, and show you the changes between your projects file and the one 33 | that has changed in Pylons 34 | (b)ackup the file, and copy the new version into its place. The old one will 35 | end in .bak 36 | (y)es to overwrite the existing file with the new one. *Not recommended* since 37 | you will then have no way to see your existing one, unless you have seen 38 | the diff first and know there is no changes you're losing. 39 | (n)o to overwrite, and just keep your existing file. Also safe if you know 40 | that nothing has changed. 41 | 42 | It's recommended when upgrading your project that you always look at the diff 43 | first to see whats changed. Then either overwrite your existing one if you are 44 | not going to lose changes you want, or backup yours and write the new one in. 45 | You can then manually compare and add your changes back in. 46 | -------------------------------------------------------------------------------- /pylons/__init__.py: -------------------------------------------------------------------------------- 1 | """Base objects to be exported for use in Controllers""" 2 | # Import pkg_resources first so namespace handling is properly done so the 3 | # paste imports work 4 | import pkg_resources 5 | from paste.registry import StackedObjectProxy 6 | 7 | from pylons.configuration import config 8 | from pylons.controllers.util import Request 9 | from pylons.controllers.util import Response 10 | 11 | __all__ = ['app_globals', 'cache', 'config', 'request', 'response', 12 | 'session', 'tmpl_context', 'url', 'Request', 'Response'] 13 | 14 | 15 | def __figure_version(): 16 | try: 17 | from pkg_resources import require 18 | import os 19 | # NOTE: this only works when the package is either installed, 20 | # or has an .egg-info directory present (i.e. wont work with raw 21 | # SVN checkout) 22 | info = require('pylons')[0] 23 | if os.path.normcase(os.path.realpath(os.path.dirname( 24 | os.path.dirname(__file__)))) == info.location: 25 | return info.version 26 | else: 27 | return '(not installed)' 28 | except: 29 | return '(not installed)' 30 | 31 | __version__ = __figure_version() 32 | 33 | app_globals = StackedObjectProxy(name="app_globals") 34 | cache = StackedObjectProxy(name="cache") 35 | request = StackedObjectProxy(name="request") 36 | response = StackedObjectProxy(name="response") 37 | session = StackedObjectProxy(name="session") 38 | tmpl_context = StackedObjectProxy(name="tmpl_context or C") 39 | url = StackedObjectProxy(name="url") 40 | 41 | translator = StackedObjectProxy(name="translator") 42 | -------------------------------------------------------------------------------- /pylons/controllers/__init__.py: -------------------------------------------------------------------------------- 1 | """Standard Controllers intended for subclassing by web developers""" 2 | from pylons.controllers.core import WSGIController 3 | from pylons.controllers.xmlrpc import XMLRPCController 4 | from pylons.controllers.jsonrpc import JSONRPCController, JSONRPCError 5 | -------------------------------------------------------------------------------- /pylons/decorators/rest.py: -------------------------------------------------------------------------------- 1 | """REST decorators""" 2 | import logging 3 | 4 | from decorator import decorator 5 | 6 | from pylons.controllers.util import abort 7 | from pylons.decorators.util import get_pylons 8 | 9 | __all__ = ['dispatch_on', 'restrict'] 10 | 11 | log = logging.getLogger(__name__) 12 | 13 | 14 | def restrict(*methods): 15 | """Restricts access to the function depending on HTTP method 16 | 17 | Example: 18 | 19 | .. code-block:: python 20 | 21 | from pylons.decorators import rest 22 | 23 | class SomeController(BaseController): 24 | 25 | @rest.restrict('GET') 26 | def comment(self, id): 27 | 28 | """ 29 | def check_methods(func, *args, **kwargs): 30 | """Wrapper for restrict""" 31 | if get_pylons(args).request.method not in methods: 32 | log.debug("Method not allowed by restrict") 33 | abort(405, headers=[('Allow', ','.join(methods))]) 34 | return func(*args, **kwargs) 35 | return decorator(check_methods) 36 | 37 | 38 | def dispatch_on(**method_map): 39 | """Dispatches to alternate controller methods based on HTTP method 40 | 41 | Multiple keyword arguments should be passed, with the keyword 42 | corresponding to the HTTP method to dispatch on (DELETE, POST, GET, 43 | etc.) and the value being the function to call. The value should be 44 | a string indicating the name of the function to dispatch to. 45 | 46 | Example: 47 | 48 | .. code-block:: python 49 | 50 | from pylons.decorators import rest 51 | 52 | class SomeController(BaseController): 53 | 54 | @rest.dispatch_on(POST='create_comment') 55 | def comment(self): 56 | # Do something with the comment 57 | 58 | def create_comment(self, id): 59 | # Do something if its a post to comment 60 | 61 | """ 62 | def dispatcher(func, self, *args, **kwargs): 63 | """Wrapper for dispatch_on""" 64 | alt_method = method_map.get(get_pylons(args).request.method) 65 | if alt_method: 66 | alt_method = getattr(self, alt_method) 67 | log.debug("Dispatching to %s instead", alt_method) 68 | return self._inspect_call(alt_method, **kwargs) 69 | return func(self, *args, **kwargs) 70 | return decorator(dispatcher) 71 | -------------------------------------------------------------------------------- /pylons/decorators/secure.py: -------------------------------------------------------------------------------- 1 | """Security related decorators""" 2 | import logging 3 | import urlparse 4 | 5 | from decorator import decorator 6 | try: 7 | import webhelpers.html.secure_form as secure_form 8 | except ImportError: 9 | import webhelpers.pylonslib.secure_form as secure_form 10 | 11 | from pylons.controllers.util import abort, redirect 12 | from pylons.decorators.util import get_pylons 13 | 14 | __all__ = ['authenticate_form', 'https'] 15 | 16 | log = logging.getLogger(__name__) 17 | 18 | csrf_detected_message = ( 19 | "Cross-site request forgery detected, request denied. See " 20 | "http://en.wikipedia.org/wiki/Cross-site_request_forgery for more " 21 | "information.") 22 | 23 | 24 | def authenticated_form(params): 25 | submitted_token = params.get(secure_form.token_key) 26 | return submitted_token is not None and \ 27 | submitted_token == secure_form.authentication_token() 28 | 29 | 30 | @decorator 31 | def authenticate_form(func, *args, **kwargs): 32 | """Decorator for authenticating a form 33 | 34 | This decorator uses an authorization token stored in the client's 35 | session for prevention of certain Cross-site request forgery (CSRF) 36 | attacks (See 37 | http://en.wikipedia.org/wiki/Cross-site_request_forgery for more 38 | information). 39 | 40 | For use with the ``webhelpers.html.secure_form`` helper functions. 41 | 42 | """ 43 | request = get_pylons(args).request 44 | if authenticated_form(request.params): 45 | try: 46 | del request.POST[secure_form.token_key] 47 | except KeyError: 48 | del request.GET[secure_form.token_key] 49 | return func(*args, **kwargs) 50 | else: 51 | log.warn('Cross-site request forgery detected, request denied: %r ' 52 | 'REMOTE_ADDR: %s' % (request, request.remote_addr)) 53 | abort(403, detail=csrf_detected_message) 54 | 55 | 56 | def https(url_or_callable=None): 57 | """Decorator to redirect to the SSL version of a page if not 58 | currently using HTTPS. Apply this decorator to controller methods 59 | (actions). 60 | 61 | Takes a url argument: either a string url, or a callable returning a 62 | string url. The callable will be called with no arguments when the 63 | decorated method is called. The url's scheme will be rewritten to 64 | https if necessary. 65 | 66 | Non-HTTPS POST requests are aborted (405 response code) by this 67 | decorator. 68 | 69 | Example: 70 | 71 | .. code-block:: python 72 | 73 | # redirect to HTTPS /pylons 74 | @https('/pylons') 75 | def index(self): 76 | do_secure() 77 | 78 | # redirect to HTTPS /auth/login, delaying the url() call until 79 | # later (as the url object may not be functional when the 80 | # decorator/method are defined) 81 | @https(lambda: url(controller='auth', action='login')) 82 | def login(self): 83 | do_secure() 84 | 85 | # redirect to HTTPS version of myself 86 | @https() 87 | def get(self): 88 | do_secure() 89 | 90 | """ 91 | def wrapper(func, *args, **kwargs): 92 | """Decorator Wrapper function""" 93 | request = get_pylons(args).request 94 | if request.scheme.lower() == 'https': 95 | return func(*args, **kwargs) 96 | if request.method.upper() == 'POST': 97 | # don't allow POSTs (raises an exception) 98 | abort(405, headers=[('Allow', 'GET')]) 99 | 100 | if url_or_callable is None: 101 | url = request.url 102 | elif callable(url_or_callable): 103 | url = url_or_callable() 104 | else: 105 | url = url_or_callable 106 | # Ensure an https scheme, which also needs a host 107 | parts = urlparse.urlparse(url) 108 | url = urlparse.urlunparse(('https', parts[1] or request.host) + 109 | parts[2:]) 110 | 111 | log.debug('Redirecting non-https request: %s to: %s', 112 | request.path_info, url) 113 | redirect(url) 114 | return decorator(wrapper) 115 | -------------------------------------------------------------------------------- /pylons/decorators/util.py: -------------------------------------------------------------------------------- 1 | """Decorator internal utilities""" 2 | import pylons 3 | from pylons.controllers import WSGIController 4 | 5 | 6 | def get_pylons(decorator_args): 7 | """Return the `pylons` object: either the :mod`~pylons` module or 8 | the :attr:`~WSGIController._py_object` equivalent, searching a 9 | decorator's *args for the latter 10 | 11 | :attr:`~WSGIController._py_object` is more efficient as it provides 12 | direct access to the Pylons global variables. 13 | """ 14 | if decorator_args: 15 | controller = decorator_args[0] 16 | if isinstance(controller, WSGIController): 17 | return controller._py_object 18 | return pylons 19 | -------------------------------------------------------------------------------- /pylons/docs/en/.gitignore: -------------------------------------------------------------------------------- 1 | _build 2 | _themes 3 | -------------------------------------------------------------------------------- /pylons/docs/en/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = sphinx-build 7 | PAPER = 8 | 9 | # Internal variables. 10 | PAPEROPT_a4 = -D latex_paper_size=a4 11 | PAPEROPT_letter = -D latex_paper_size=letter 12 | ALLSPHINXOPTS = -d _build/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . 13 | 14 | .PHONY: help clean html web htmlhelp latex changes linkcheck 15 | 16 | help: 17 | @echo "Please use \`make ' where is one of" 18 | @echo " html to make standalone HTML files" 19 | @echo " web to make files usable by Sphinx.web" 20 | @echo " htmlhelp to make HTML files and a HTML help project" 21 | @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" 22 | @echo " changes to make an overview over all changed/added/deprecated items" 23 | @echo " linkcheck to check all external links for integrity" 24 | 25 | clean: 26 | -rm -rf _build/* 27 | 28 | html: 29 | mkdir -p _build/html _build/doctrees 30 | $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) _build/html 31 | @echo 32 | @echo "Build finished. The HTML pages are in _build/html." 33 | 34 | web: 35 | mkdir -p _build/web _build/doctrees 36 | $(SPHINXBUILD) -b web $(ALLSPHINXOPTS) _build/web 37 | @echo 38 | @echo "Build finished; now you can run" 39 | @echo " python -m sphinx.web _build/web" 40 | @echo "to start the server." 41 | 42 | htmlhelp: 43 | mkdir -p _build/htmlhelp _build/doctrees 44 | $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) _build/htmlhelp 45 | @echo 46 | @echo "Build finished; now you can run HTML Help Workshop with the" \ 47 | ".hhp project file in _build/htmlhelp." 48 | 49 | latex: 50 | mkdir -p _build/latex _build/doctrees 51 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) _build/latex 52 | @echo 53 | @echo "Build finished; the LaTeX files are in _build/latex." 54 | @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \ 55 | "run these through (pdf)latex." 56 | 57 | changes: 58 | mkdir -p _build/changes _build/doctrees 59 | $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) _build/changes 60 | @echo 61 | @echo "The overview file is in _build/changes." 62 | 63 | linkcheck: 64 | mkdir -p _build/linkcheck _build/doctrees 65 | $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) _build/linkcheck 66 | @echo 67 | @echo "Link check complete; look for any errors in the above output " \ 68 | "or in _build/linkcheck/output.txt." 69 | 70 | -------------------------------------------------------------------------------- /pylons/docs/en/_oldstatic/Pylons_Stack-Chainsaw-OSX.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/pylons/docs/en/_oldstatic/Pylons_Stack-Chainsaw-OSX.png -------------------------------------------------------------------------------- /pylons/docs/en/_oldstatic/akhet.css: -------------------------------------------------------------------------------- 1 | div.body h2 { font-size: 160%; background: url(akhettransaqua.png) 10px 3px no-repeat; padding-left: 2.66em;} 2 | pre { background: #efc url(background.png) 0 0 repeat; } 3 | -------------------------------------------------------------------------------- /pylons/docs/en/_oldstatic/akhet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/pylons/docs/en/_oldstatic/akhet.png -------------------------------------------------------------------------------- /pylons/docs/en/_oldstatic/akhet_rev.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/pylons/docs/en/_oldstatic/akhet_rev.png -------------------------------------------------------------------------------- /pylons/docs/en/_oldstatic/akhetcats.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/pylons/docs/en/_oldstatic/akhetcats.jpg -------------------------------------------------------------------------------- /pylons/docs/en/_oldstatic/akhettransaqua.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/pylons/docs/en/_oldstatic/akhettransaqua.png -------------------------------------------------------------------------------- /pylons/docs/en/_oldstatic/at.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/pylons/docs/en/_oldstatic/at.png -------------------------------------------------------------------------------- /pylons/docs/en/_oldstatic/babel_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/pylons/docs/en/_oldstatic/babel_logo.png -------------------------------------------------------------------------------- /pylons/docs/en/_oldstatic/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/pylons/docs/en/_oldstatic/background.png -------------------------------------------------------------------------------- /pylons/docs/en/_oldstatic/doctraceback.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/pylons/docs/en/_oldstatic/doctraceback.gif -------------------------------------------------------------------------------- /pylons/docs/en/_oldstatic/doctraceback.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/pylons/docs/en/_oldstatic/doctraceback.png -------------------------------------------------------------------------------- /pylons/docs/en/_oldstatic/hellotemplate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/pylons/docs/en/_oldstatic/hellotemplate.png -------------------------------------------------------------------------------- /pylons/docs/en/_oldstatic/helloworld.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/pylons/docs/en/_oldstatic/helloworld.png -------------------------------------------------------------------------------- /pylons/docs/en/_oldstatic/pygments.css: -------------------------------------------------------------------------------- 1 | .c { color: #60a0b0; font-style: italic } /* Comment */ 2 | .err { border: 1px solid #FF0000 } /* Error */ 3 | .k { color: #007020; font-weight: bold } /* Keyword */ 4 | .o { color: #666666 } /* Operator */ 5 | .cm { color: #60a0b0; font-style: italic } /* Comment.Multiline */ 6 | .cp { color: #007020 } /* Comment.Preproc */ 7 | .c1 { color: #60a0b0; font-style: italic } /* Comment.Single */ 8 | .cs { color: #60a0b0; background-color: #fff0f0 } /* Comment.Special */ 9 | .gd { color: #A00000 } /* Generic.Deleted */ 10 | .ge { font-style: italic } /* Generic.Emph */ 11 | .gr { color: #FF0000 } /* Generic.Error */ 12 | .gh { color: #000080; font-weight: bold } /* Generic.Heading */ 13 | .gi { color: #00A000 } /* Generic.Inserted */ 14 | .go { color: #808080 } /* Generic.Output */ 15 | .gp { color: #c65d09; font-weight: bold } /* Generic.Prompt */ 16 | .gs { font-weight: bold } /* Generic.Strong */ 17 | .gu { color: #800080; font-weight: bold } /* Generic.Subheading */ 18 | .gt { color: #0040D0 } /* Generic.Traceback */ 19 | .kc { color: #007020; font-weight: bold } /* Keyword.Constant */ 20 | .kd { color: #007020; font-weight: bold } /* Keyword.Declaration */ 21 | .kp { color: #007020 } /* Keyword.Pseudo */ 22 | .kr { color: #007020; font-weight: bold } /* Keyword.Reserved */ 23 | .kt { color: #902000 } /* Keyword.Type */ 24 | .m { color: #40a070 } /* Literal.Number */ 25 | .s { color: #4070a0 } /* Literal.String */ 26 | .na { color: #4070a0 } /* Name.Attribute */ 27 | .nb { color: #007020 } /* Name.Builtin */ 28 | .nc { color: #0e84b5; font-weight: bold } /* Name.Class */ 29 | .no { color: #60add5 } /* Name.Constant */ 30 | .nd { color: #555555; font-weight: bold } /* Name.Decorator */ 31 | .ni { color: #d55537; font-weight: bold } /* Name.Entity */ 32 | .ne { color: #007020 } /* Name.Exception */ 33 | .nf { color: #06287e } /* Name.Function */ 34 | .nl { color: #002070; font-weight: bold } /* Name.Label */ 35 | .nn { color: #0e84b5; font-weight: bold } /* Name.Namespace */ 36 | .nt { color: #062873; font-weight: bold } /* Name.Tag */ 37 | .nv { color: #bb60d5 } /* Name.Variable */ 38 | .ow { color: #007020; font-weight: bold } /* Operator.Word */ 39 | .w { color: #bbbbbb } /* Text.Whitespace */ 40 | .mf { color: #40a070 } /* Literal.Number.Float */ 41 | .mh { color: #40a070 } /* Literal.Number.Hex */ 42 | .mi { color: #40a070 } /* Literal.Number.Integer */ 43 | .mo { color: #40a070 } /* Literal.Number.Oct */ 44 | .sb { color: #4070a0 } /* Literal.String.Backtick */ 45 | .sc { color: #4070a0 } /* Literal.String.Char */ 46 | .sd { color: #4070a0; font-style: italic } /* Literal.String.Doc */ 47 | .s2 { color: #4070a0 } /* Literal.String.Double */ 48 | .se { color: #4070a0; font-weight: bold } /* Literal.String.Escape */ 49 | .sh { color: #4070a0 } /* Literal.String.Heredoc */ 50 | .si { color: #70a0d0; font-style: italic } /* Literal.String.Interpol */ 51 | .sx { color: #c65d09 } /* Literal.String.Other */ 52 | .sr { color: #235388 } /* Literal.String.Regex */ 53 | .s1 { color: #4070a0 } /* Literal.String.Single */ 54 | .ss { color: #517918 } /* Literal.String.Symbol */ 55 | .bp { color: #007020 } /* Name.Builtin.Pseudo */ 56 | .vc { color: #bb60d5 } /* Name.Variable.Class */ 57 | .vg { color: #bb60d5 } /* Name.Variable.Global */ 58 | .vi { color: #bb60d5 } /* Name.Variable.Instance */ 59 | .il { color: #40a070 } /* Literal.Number.Integer.Long */ -------------------------------------------------------------------------------- /pylons/docs/en/_oldstatic/pylon1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/pylons/docs/en/_oldstatic/pylon1.jpg -------------------------------------------------------------------------------- /pylons/docs/en/_oldstatic/pylon2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/pylons/docs/en/_oldstatic/pylon2.jpg -------------------------------------------------------------------------------- /pylons/docs/en/_oldstatic/pylon3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/pylons/docs/en/_oldstatic/pylon3.jpg -------------------------------------------------------------------------------- /pylons/docs/en/_oldstatic/pylon4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/pylons/docs/en/_oldstatic/pylon4.jpg -------------------------------------------------------------------------------- /pylons/docs/en/_oldstatic/pylons_as_onion.ai: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/pylons/docs/en/_oldstatic/pylons_as_onion.ai -------------------------------------------------------------------------------- /pylons/docs/en/_oldstatic/pylons_as_onion.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/pylons/docs/en/_oldstatic/pylons_as_onion.png -------------------------------------------------------------------------------- /pylons/docs/en/_oldtemplates/genindex.html: -------------------------------------------------------------------------------- 1 | {% extends "layout.html" %} 2 | {% set title = _('Index') %} 3 | {% block body %} 4 | 5 |

{{ _('Index') }}

6 | 7 | {% for key, dummy in genindexentries -%} 8 | {{ key }} {% if not loop.last %}| {% endif %} 9 | {%- endfor %} 10 | 11 |
12 | 13 | {% for key, entries in genindexentries %} 14 |

{{ key }}

15 |
16 |
17 | {%- set breakat = genindexcounts[loop.index0] // 2 %} 18 | {%- set numcols = 1 %} 19 | {%- set numitems = 0 %} 20 | {% for entryname, (links, subitems) in entries %} 21 |
{%- if links -%}{{ entryname|e }} 22 | {%- for link in links[1:] %}, [{{ loop.index }}]{% endfor -%} 23 | {%- else -%} 24 | {{ entryname|e }} 25 | {%- endif -%}
26 | {%- if subitems %} 27 |
28 | {%- for subentryname, subentrylinks in subitems %} 29 |
{{ subentryname|e }} 30 | {%- for link in subentrylinks[1:] %}, [{{ loop.index }}]{% endfor -%} 31 |
32 | {%- endfor %} 33 |
34 | {%- endif -%} 35 | {%- set numitems = numitems + 1 + (subitems|length) -%} 36 | {%- if numcols < 2 and numitems > breakat -%} 37 | {%- set numcols = numcols+1 -%} 38 |
39 | {%- endif -%} 40 | {%- endfor %} 41 |
42 | {% endfor %} 43 | 44 | {% endblock %} 45 | 46 | {% block sidebarrel %} 47 | {% if split_index %} 48 |

{{ _('Index') }}

49 |

{% for key, dummy in genindexentries -%} 50 | {{ key }} 51 | {% if not loop.last %}| {% endif %} 52 | {%- endfor %}

53 | 54 |

{{ _('Full index on one page') }}

55 | {% endif %} 56 | {{ super() }} 57 | {% endblock %} 58 | -------------------------------------------------------------------------------- /pylons/docs/en/_oldtemplates/modindex.html: -------------------------------------------------------------------------------- 1 | {% extends "layout.html" %} 2 | {% set title = _('Global Module Index') %} 3 | {% block extrahead %} 4 | {{ super() }} 5 | {% if builder != 'htmlhelp' and collapse_modindex %} 6 | 9 | {% endif %} 10 | {% endblock %} 11 | {% block body %} 12 | 13 |

{{ _('Global Module Index') }}

14 | {% if builder == 'web' and freqentries %} 15 |

{{ _('Most popular modules:') }}

16 |
17 | {%- for module in freqentries %} 18 | {{ module.name|e }} 19 | {%- endfor %} 20 |
21 | {% endif %} 22 | {% if builder == 'web' %} 23 |
24 | {{ _('Show modules only available on these platforms') }}:
25 | {% for pl in platforms -%} 26 | 28 | 29 | {% endfor %} 30 | 31 | 32 |
33 | {% endif %} 34 | 35 | {%- for letter in letters %} 36 | {{ letter }} {% if not loop.last %}| {% endif %} 37 | {%- endfor %} 38 |
39 | 40 | 41 | {%- for modname, collapse, cgroup, indent, fname, synops, pform, dep, stripped in modindexentries %} 42 | {%- if not modname -%} 43 | 44 | 45 | {%- else -%} 46 | 47 | 51 | 58 | {%- endif -%} 59 | {% endfor %} 60 |
 
{{ fname }}
{% if collapse -%} 48 | 50 | {%- endif %}{% if indent %}   {% endif %} 52 | {% if fname %}{% endif -%} 53 | {{ stripped|e }}{{ modname|e }} 54 | {%- if fname %}{% endif %} 55 | {%- if pform[0] %} ({{ pform|join(', ') }}){% endif -%} 56 | {% if dep %}{{ _('Deprecated')}}:{% endif %} 57 | {{ synops|e }}
61 | 62 | {% endblock %} 63 | -------------------------------------------------------------------------------- /pylons/docs/en/_oldtemplates/page.html: -------------------------------------------------------------------------------- 1 | {% extends "layout.html" %} 2 | {% set page_links = [ 3 | (pathto('@rss/' + sourcename), 'application/rss+xml', 'Page Comments'), 4 | ] %} 5 | {% block body %} 6 | {% if oldurl %} 7 |
8 | {% trans %}Note: You requested an out-of-date URL from this server. We've tried to redirect you to the new location of this page, but it may not be the right one.{% endtrans %} 9 |
10 | {% endif %} 11 | {{ body }} 12 | {% endblock %} 13 | -------------------------------------------------------------------------------- /pylons/docs/en/_static/Pylons_Stack-Chainsaw-OSX.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/pylons/docs/en/_static/Pylons_Stack-Chainsaw-OSX.png -------------------------------------------------------------------------------- /pylons/docs/en/_static/akhet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/pylons/docs/en/_static/akhet.png -------------------------------------------------------------------------------- /pylons/docs/en/_static/akhet_rev.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/pylons/docs/en/_static/akhet_rev.png -------------------------------------------------------------------------------- /pylons/docs/en/_static/akhetcats.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/pylons/docs/en/_static/akhetcats.jpg -------------------------------------------------------------------------------- /pylons/docs/en/_static/akhettransaqua.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/pylons/docs/en/_static/akhettransaqua.png -------------------------------------------------------------------------------- /pylons/docs/en/_static/at.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/pylons/docs/en/_static/at.png -------------------------------------------------------------------------------- /pylons/docs/en/_static/babel_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/pylons/docs/en/_static/babel_logo.png -------------------------------------------------------------------------------- /pylons/docs/en/_static/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/pylons/docs/en/_static/background.png -------------------------------------------------------------------------------- /pylons/docs/en/_static/doctraceback.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/pylons/docs/en/_static/doctraceback.gif -------------------------------------------------------------------------------- /pylons/docs/en/_static/doctraceback.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/pylons/docs/en/_static/doctraceback.png -------------------------------------------------------------------------------- /pylons/docs/en/_static/hellotemplate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/pylons/docs/en/_static/hellotemplate.png -------------------------------------------------------------------------------- /pylons/docs/en/_static/helloworld.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/pylons/docs/en/_static/helloworld.png -------------------------------------------------------------------------------- /pylons/docs/en/_static/pylon1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/pylons/docs/en/_static/pylon1.jpg -------------------------------------------------------------------------------- /pylons/docs/en/_static/pylon2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/pylons/docs/en/_static/pylon2.jpg -------------------------------------------------------------------------------- /pylons/docs/en/_static/pylon3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/pylons/docs/en/_static/pylon3.jpg -------------------------------------------------------------------------------- /pylons/docs/en/_static/pylon4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/pylons/docs/en/_static/pylon4.jpg -------------------------------------------------------------------------------- /pylons/docs/en/_static/pylons_as_onion.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/pylons/docs/en/_static/pylons_as_onion.png -------------------------------------------------------------------------------- /pylons/docs/en/advanced_pylons/index.rst: -------------------------------------------------------------------------------- 1 | .. _advanced_pylons: 2 | 3 | =============== 4 | Advanced Pylons 5 | =============== 6 | 7 | .. toctree:: 8 | :maxdepth: 1 9 | 10 | paster 11 | paster_commands 12 | creating_paste_templates 13 | entry_points_and_plugins 14 | 15 | -------------------------------------------------------------------------------- /pylons/docs/en/events.rst: -------------------------------------------------------------------------------- 1 | .. _events: 2 | 3 | ====== 4 | Events 5 | ====== 6 | 7 | -------------------------------------------------------------------------------- /pylons/docs/en/index.rst: -------------------------------------------------------------------------------- 1 | Pylons Reference Documentation 2 | ============================== 3 | 4 | .. image:: _static/pylon1.jpg 5 | :alt: The First Pylon of the Ramesseum, Thebes is approximately 69m long and 22m high, and marks the entrance to the Main Temple and the First Courtyard. 6 | :align: center 7 | :height: 255 8 | :width: 780 9 | 10 | Getting Started with Pylons 11 | --------------------------- 12 | 13 | .. toctree:: 14 | :maxdepth: 2 15 | 16 | gettingstarted 17 | concepts 18 | 19 | MVC Reference 20 | ------------- 21 | 22 | .. toctree:: 23 | :maxdepth: 2 24 | 25 | controllers 26 | views 27 | models 28 | advanced_models 29 | 30 | Project Configuration and Logging 31 | --------------------------------- 32 | 33 | .. toctree:: 34 | :maxdepth: 2 35 | 36 | configuration 37 | logging 38 | 39 | Forms, Validation, and Helpers 40 | ------------------------------ 41 | 42 | .. toctree:: 43 | :maxdepth: 2 44 | 45 | helpers 46 | forms 47 | 48 | Internationalization, Sessions, and Caching 49 | ------------------------------------------- 50 | 51 | .. toctree:: 52 | :maxdepth: 2 53 | 54 | i18n 55 | sessions 56 | caching 57 | 58 | Testing, Upgrading, and Deploying 59 | --------------------------------- 60 | 61 | .. toctree:: 62 | :maxdepth: 2 63 | 64 | testing 65 | debugging 66 | upgrading 67 | deployment 68 | 69 | Installation for Windows / Python 2.3 70 | ------------------------------------- 71 | 72 | .. toctree:: 73 | :maxdepth: 2 74 | 75 | python23_install 76 | windowsnotes 77 | 78 | Pylons on Jython 79 | ---------------- 80 | 81 | .. toctree:: 82 | :maxdepth: 2 83 | 84 | jython 85 | 86 | Advanced Pylons 87 | --------------- 88 | 89 | .. toctree:: 90 | :maxdepth: 2 91 | 92 | security_policy_for_bugs 93 | wsgi_support 94 | advanced_pylons/index 95 | execution 96 | 97 | 98 | Module Listing 99 | -------------- 100 | 101 | .. toctree:: 102 | :maxdepth: 2 103 | 104 | modules/index 105 | thirdparty/index 106 | glossary 107 | 108 | For further information, indices are available: 109 | 110 | Indices 111 | ======= 112 | 113 | * :ref:`genindex` 114 | * :ref:`modindex` 115 | * :ref:`search` 116 | * :ref:`glossary` 117 | -------------------------------------------------------------------------------- /pylons/docs/en/jython.rst: -------------------------------------------------------------------------------- 1 | .. _jython: 2 | 3 | ================ 4 | Pylons on Jython 5 | ================ 6 | 7 | Pylons supports `Jython `_ as of v0.9.7. 8 | 9 | Installation 10 | ============ 11 | 12 | The installation process is the same as CPython, as described in 13 | :ref:`getting_started`. At least Jython 2.5b2 is required. 14 | 15 | .. _java_deployment: 16 | 17 | Deploying to Java Web servers 18 | ============================= 19 | 20 | The Java platform defines the `Servlet API`_ for creating web applications. The 21 | `modjy`_ library included with Jython provides a gateway between Java Servlets 22 | and WSGI applications. 23 | 24 | The `snakefight`_ tool can create a `WAR file`_ from a Pylons application (and 25 | modjy) that's suitable for deployment to the various `Servlet containers`_ (such 26 | as `Apache Tomcat`_ or `Sun's Glassfish`_). 27 | 28 | Creating .wars with snakefight 29 | ------------------------------ 30 | 31 | First, install snakefight: 32 | 33 | .. code-block :: bash 34 | 35 | $ easy_install snakefight 36 | 37 | This adds an additional command to distutils: :command:`bdist_war`. 38 | 39 | Pylons applications are loaded from Paste, via its ``paste.app_factory`` entry 40 | point and a Paste style configuration file. :command:`bdist_war` knows how to 41 | setup Paste apps for deployment when specified the :option:`--paste-config` 42 | option: 43 | 44 | .. code-block :: bash 45 | 46 | $ paster make-config MyApp production.ini 47 | $ jython setup.py bdist_war --paste-config production.ini 48 | 49 | As with any distutils command the preferred options can instead be added to the 50 | :file:`setup.cfg` in the root directory of the project: 51 | 52 | .. code-block :: ini 53 | 54 | [bdist_war] 55 | paste-config = production.ini 56 | 57 | Then we can simply run: 58 | 59 | .. code-block :: bash 60 | 61 | $ jython setup.py bdist_war 62 | 63 | :command:`bdist_war` creates a :file:`.war` with the following: 64 | 65 | - Jython's :file:`jar` files in :file:`WEB-INF/lib` 66 | - Jython's stdlib in :file:`WEB-INF/lib-python` 67 | - Your application's required eggs in :file:`WEB-INF/lib-python` 68 | 69 | With the :option:`--paste-config` option, it also: 70 | 71 | - Creates a simple loader for the application/config 72 | - Generates a :file:`web.xml` deployment descriptor configuring modjy to load 73 | the application with the simple loader 74 | 75 | For further information/usages, see `snakefight's documentation`_. 76 | 77 | 78 | .. _`Servlet API`: http://en.wikipedia.org/wiki/Java_Servlet 79 | .. _`modjy`: http://modjy.xhaus.com/ 80 | .. _`snakefight`: http://pypi.python.org/pypi/snakefight 81 | .. _`snakefight's documentation`: http://pypi.python.org/pypi/snakefight 82 | .. _`WAR file`: http://en.wikipedia.org/wiki/Sun_WAR_(file_format) 83 | .. _`Servlet containers`: http://en.wikipedia.org/wiki/Servlet_container 84 | .. _`Apache Tomcat`: http://tomcat.apache.org/ 85 | .. _`Sun's Glassfish`: http://glassfish.org/ 86 | -------------------------------------------------------------------------------- /pylons/docs/en/modules/commands.rst: -------------------------------------------------------------------------------- 1 | :mod:`pylons.commands` -- Command line functions 2 | ================================================ 3 | 4 | .. automodule:: pylons.commands 5 | 6 | Module Contents 7 | --------------- 8 | 9 | .. autoclass:: ControllerCommand 10 | .. autoclass:: RestControllerCommand 11 | .. autoclass:: ShellCommand 12 | -------------------------------------------------------------------------------- /pylons/docs/en/modules/configuration.rst: -------------------------------------------------------------------------------- 1 | :mod:`pylons.configuration` -- Configuration object and defaults setup 2 | ====================================================================== 3 | 4 | .. automodule:: pylons.configuration 5 | 6 | Module Contents 7 | --------------- 8 | 9 | .. autoclass:: PylonsConfig 10 | :members: init_app 11 | -------------------------------------------------------------------------------- /pylons/docs/en/modules/controllers.rst: -------------------------------------------------------------------------------- 1 | :mod:`pylons.controllers` -- Controllers 2 | ======================================== 3 | 4 | .. module:: pylons.controllers 5 | 6 | This module makes available the 7 | :class:`~pylons.controllers.core.WSGIController` and 8 | :class:`~pylons.controllers.xmlrpc.XMLRPCController` for easier importing. 9 | -------------------------------------------------------------------------------- /pylons/docs/en/modules/controllers_core.rst: -------------------------------------------------------------------------------- 1 | :mod:`pylons.controllers.core` -- WSGIController Class 2 | ====================================================== 3 | 4 | .. automodule:: pylons.controllers.core 5 | 6 | Module Contents 7 | --------------- 8 | 9 | .. autoclass:: WSGIController 10 | :members: _perform_call, _inspect_call, _get_method_args, _dispatch_call, __call__ 11 | -------------------------------------------------------------------------------- /pylons/docs/en/modules/controllers_util.rst: -------------------------------------------------------------------------------- 1 | :mod:`pylons.controllers.util` -- Controller Utility functions 2 | ====================================================================== 3 | 4 | .. automodule:: pylons.controllers.util 5 | 6 | Module Contents 7 | --------------- 8 | 9 | .. autoclass:: Request 10 | :members: 11 | :undoc-members: 12 | :show-inheritance: 13 | .. autoclass:: Response 14 | :members: 15 | :undoc-members: 16 | :show-inheritance: 17 | .. autofunction:: abort 18 | .. autofunction:: etag_cache 19 | .. autofunction:: forward 20 | .. autofunction:: redirect 21 | -------------------------------------------------------------------------------- /pylons/docs/en/modules/controllers_xmlrpc.rst: -------------------------------------------------------------------------------- 1 | :mod:`pylons.controllers.xmlrpc` -- XMLRPCController Class 2 | ========================================================== 3 | 4 | .. automodule:: pylons.controllers.xmlrpc 5 | 6 | Module Contents 7 | --------------- 8 | 9 | .. autoclass:: XMLRPCController 10 | :members: __call__, system_listMethods, system_methodSignature, system_methodHelp 11 | -------------------------------------------------------------------------------- /pylons/docs/en/modules/decorators.rst: -------------------------------------------------------------------------------- 1 | :mod:`pylons.decorators` -- Decorators 2 | ====================================== 3 | 4 | .. automodule:: pylons.decorators 5 | 6 | Module Contents 7 | --------------- 8 | 9 | .. autofunction:: jsonify 10 | .. autofunction:: validate 11 | -------------------------------------------------------------------------------- /pylons/docs/en/modules/decorators_cache.rst: -------------------------------------------------------------------------------- 1 | :mod:`pylons.decorators.cache` -- Cache Decorators 2 | ====================================================================== 3 | 4 | .. automodule:: pylons.decorators.cache 5 | 6 | Module Contents 7 | --------------- 8 | 9 | .. autofunction:: beaker_cache 10 | -------------------------------------------------------------------------------- /pylons/docs/en/modules/decorators_rest.rst: -------------------------------------------------------------------------------- 1 | :mod:`pylons.decorators.rest` -- REST-ful Decorators 2 | ==================================================== 3 | 4 | .. automodule:: pylons.decorators.rest 5 | 6 | Module Contents 7 | --------------- 8 | 9 | .. autofunction:: dispatch_on 10 | .. autofunction:: restrict 11 | -------------------------------------------------------------------------------- /pylons/docs/en/modules/decorators_secure.rst: -------------------------------------------------------------------------------- 1 | :mod:`pylons.decorators.secure` -- Secure Decorators 2 | ==================================================== 3 | 4 | .. automodule:: pylons.decorators.secure 5 | 6 | Module Contents 7 | --------------- 8 | 9 | .. autofunction:: authenticate_form 10 | .. autofunction:: https 11 | -------------------------------------------------------------------------------- /pylons/docs/en/modules/error.rst: -------------------------------------------------------------------------------- 1 | :mod:`pylons.error` -- Error handling support 2 | ============================================= 3 | 4 | .. automodule:: pylons.error 5 | -------------------------------------------------------------------------------- /pylons/docs/en/modules/i18n_translation.rst: -------------------------------------------------------------------------------- 1 | :mod:`pylons.i18n.translation` -- Translation/Localization functions 2 | ==================================================================== 3 | 4 | .. automodule:: pylons.i18n.translation 5 | 6 | Module Contents 7 | --------------- 8 | 9 | .. autoexception:: LanguageError 10 | .. autoclass:: LazyString 11 | .. autofunction:: lazify 12 | .. autofunction:: gettext_noop 13 | .. autofunction:: gettext 14 | .. autofunction:: ugettext 15 | .. autofunction:: ngettext 16 | .. autofunction:: ungettext 17 | .. autofunction:: set_lang 18 | .. autofunction:: get_lang 19 | .. autofunction:: add_fallback 20 | -------------------------------------------------------------------------------- /pylons/docs/en/modules/index.rst: -------------------------------------------------------------------------------- 1 | .. _modules: 2 | 3 | ============== 4 | Pylons Modules 5 | ============== 6 | 7 | .. toctree:: 8 | :maxdepth: 2 9 | 10 | commands 11 | configuration 12 | controllers 13 | controllers_core 14 | controllers_util 15 | controllers_xmlrpc 16 | decorators 17 | decorators_cache 18 | decorators_rest 19 | decorators_secure 20 | error 21 | i18n_translation 22 | log 23 | middleware 24 | templating 25 | test 26 | util 27 | wsgiapp 28 | 29 | -------------------------------------------------------------------------------- /pylons/docs/en/modules/log.rst: -------------------------------------------------------------------------------- 1 | :mod:`pylons.log` -- Logging for WSGI errors 2 | ============================================ 3 | 4 | .. automodule:: pylons.log 5 | 6 | Module Contents 7 | --------------- 8 | 9 | .. autoclass:: WSGIErrorsHandler 10 | :members: 11 | -------------------------------------------------------------------------------- /pylons/docs/en/modules/middleware.rst: -------------------------------------------------------------------------------- 1 | :mod:`pylons.middleware` -- WSGI Middleware 2 | =========================================== 3 | 4 | .. automodule:: pylons.middleware 5 | 6 | Module Contents 7 | --------------- 8 | 9 | .. autoclass:: StatusCodeRedirect 10 | :members: __init__ 11 | .. autoclass:: StaticJavascripts 12 | .. autofunction:: ErrorHandler 13 | 14 | .. note:: 15 | 16 | The :data:`errorware` dictionary is constructed from the settings in the `DEFAULT` section of development.ini. the recognised keys and settings at initialization are: 17 | * :data:`error_email` = conf.get('email_to') 18 | * :data:`error_log` = conf.get('error_log', None) 19 | * :data:`smtp_server` = conf.get('smtp_server','localhost') 20 | * :data:`error_subject_prefix` = conf.get('error_subject_prefix', 'WebApp Error: ') 21 | * :data:`from_address` = conf.get('from_address', conf.get('error_email_from', 'pylons@yourapp.com')) 22 | * :data:`error_message` = conf.get('error_message', 'An internal server error occurred') 23 | 24 | Referenced classes 25 | ------------------ 26 | Pylons middleware uses :class:`WebError` to effect the error-handling. The two classes implicated are: 27 | 28 | ErrorMiddleware 29 | ^^^^^^^^^^^^^^^ 30 | 31 | :mod:`weberror.errormiddleware` 32 | :class:`weberror.errormiddleware.ErrorMiddleware` 33 | 34 | 35 | EvalException 36 | ^^^^^^^^^^^^^ 37 | 38 | :mod:`weberror.evalexception` 39 | :class:`weberror.evalexception.EvalException` 40 | -------------------------------------------------------------------------------- /pylons/docs/en/modules/templating.rst: -------------------------------------------------------------------------------- 1 | :mod:`pylons.templating` -- Render functions and helpers 2 | ======================================================== 3 | 4 | .. automodule:: pylons.templating 5 | 6 | Module Contents 7 | --------------- 8 | 9 | .. autofunction:: pylons_globals 10 | .. autofunction:: cached_template 11 | .. autofunction:: render_mako 12 | .. autofunction:: render_mako_def 13 | .. autofunction:: render_genshi 14 | -------------------------------------------------------------------------------- /pylons/docs/en/modules/test.rst: -------------------------------------------------------------------------------- 1 | :mod:`pylons.test` -- Test related functionality 2 | ================================================ 3 | 4 | .. automodule:: pylons.test 5 | 6 | Module Contents 7 | --------------- 8 | 9 | .. autoclass:: PylonsPlugin 10 | -------------------------------------------------------------------------------- /pylons/docs/en/modules/util.rst: -------------------------------------------------------------------------------- 1 | :mod:`pylons.util` -- Paste Template and Pylons utility functions 2 | ================================================================= 3 | 4 | .. automodule:: pylons.util 5 | 6 | Module Contents 7 | --------------- 8 | 9 | .. autoclass:: PylonsContext 10 | .. autoclass:: ContextObj 11 | .. autoclass:: AttribSafeContextObj 12 | -------------------------------------------------------------------------------- /pylons/docs/en/modules/wsgiapp.rst: -------------------------------------------------------------------------------- 1 | :mod:`pylons.wsgiapp` -- PylonsWSGI App Creator 2 | =============================================== 3 | 4 | .. automodule:: pylons.wsgiapp 5 | 6 | Module Contents 7 | --------------- 8 | 9 | .. autoclass:: PylonsApp 10 | :members: 11 | 12 | .. automethod:: PylonsApp.__call__ 13 | -------------------------------------------------------------------------------- /pylons/docs/en/objects.inv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/pylons/docs/en/objects.inv -------------------------------------------------------------------------------- /pylons/docs/en/python23_install.rst: -------------------------------------------------------------------------------- 1 | .. _python23_installation: 2 | 3 | ==================================== 4 | Python 2.3 Installation Instructions 5 | ==================================== 6 | 7 | Advice of **end of support for Python 2.3** 8 | ------------------------------------------- 9 | 10 | .. warning:: **END OF SUPPORT FOR PYTHON 2.3** This is the **LAST** version to support Python 2.3 **BEGIN UPGRADING OR DIE** 11 | 12 | Preparation 13 | ----------- 14 | 15 | First, please note that Python 2.3 users on Windows will need to install `subprocess.exe`__ before beginning the installation (whereas Python 2.4 users on Windows do not). All windows users also should read the section :ref:`windows_notes` after installation. Users of Ubuntu/debian will also likely need to install the python-dev package. 16 | 17 | System-wide Install 18 | ------------------- 19 | 20 | To install Pylons so it can be used by everyone (you'll need root access). 21 | 22 | If you already have easy install: 23 | 24 | .. code-block:: bash 25 | 26 | $ easy_install Pylons==0.9.7 27 | 28 | .. note:: 29 | On rare occasions, the python.org Cheeseshop goes down. It is still 30 | possible to install Pylons and its dependencies however by specifying our 31 | local package directory for installation with: 32 | 33 | .. code-block:: bash 34 | 35 | $ easy_install -f http://pylonshq.com/download/ Pylons==0.9.7 36 | 37 | Which will use the packages necessary for the latest release. If you're 38 | using an older version of Pylons, you can get the packages that went with 39 | it by specifying the version desired: 40 | 41 | .. code-block:: bash 42 | 43 | $ easy_install -f http://pylonshq.com/download/0.9.7/ Pylons==0.9.7 44 | 45 | Otherwise: 46 | 47 | #. Download the easy install setup file from http://peak.telecommunity.com/dist/ez_setup.py 48 | #. Run: 49 | 50 | .. code-block:: bash 51 | 52 | $ python ez_setup.py Pylons==0.9.7 53 | 54 | 55 | .. __: http://www.pylonshq.com/download/subprocess-0.1-20041012.win32-py2.3.exe 56 | 57 | .. warning:: **END OF SUPPORT FOR PYTHON 2.3** This is the **LAST** version to support Python 2.3 **BEGIN UPGRADING OR DIE** 58 | -------------------------------------------------------------------------------- /pylons/docs/en/security_policy_for_bugs.rst: -------------------------------------------------------------------------------- 1 | .. _security_policy_for_bugs: 2 | 3 | ======================== 4 | Security policy for bugs 5 | ======================== 6 | 7 | Receiving Security Updates 8 | ========================== 9 | 10 | The Pylons team have set up a mailing list at wsgi-security-announce@googlegroups.com to which any security vulnerabilities that affect Pylons will be announced. Anyone wishing to be notified of vulnerabilities in Pylons should subscribe to this list. Security announcements will only be made once a solution to the problem has been discovered. 11 | 12 | Reporting Security Issues 13 | ========================= 14 | 15 | Please report security issues by email to both the lead developers of Pylons at the following addresses: 16 | 17 | ben\ 18 | |at|\ 19 | groovie.org 20 | 21 | security\ 22 | |at|\ 23 | 3aims.com 24 | 25 | Please DO NOT announce the vulnerability to any mailing lists or on the ticket system because we would not want any malicious person to be aware of the problem before a solution is available. 26 | 27 | In the event of a confirmed vulnerability in Pylons itself, we will take the following actions: 28 | 29 | * Acknowledge to the reporter that we've received the report and that a fix is forthcoming. We'll give a rough timeline and ask the reporter to keep the issue confidential until we announce it. 30 | * Halt all other development as long as is needed to develop a fix, including patches against the current release. 31 | * Publicly announce the vulnerability and the fix as soon as it is available to the WSGI security list at wsgi-security-announce@googlegroups.com. 32 | 33 | This will probably mean a new release of Pylons, but in some cases it may simply be the release of documentation explaining how to avoid the vulnerability. 34 | 35 | In the event of a confirmed vulnerability in one of the components that Pylons uses, we will take the following actions: 36 | 37 | * Acknowledge to the reporter that we've received the report and ask the reporter to keep the issue confidential until we announce it. 38 | * Contact the developer or maintainer of the package containing the vulnerability. 39 | * If the developer or maintainer fails to release a new version in a reasonable time-scale and the vulnerability is serious we will either create documentation explaining how to avoid the problem or as a last resort, create a patched version. 40 | * Publicly announce the vulnerability and the fix as soon as it is available to the WSGI security list at wsgi-security-announce@googlegroups.com. 41 | 42 | Minimising Risk 43 | =============== 44 | 45 | * Only use official production versions of Pylons released publicly on the `Python Package Index `_. 46 | * Only use stable releases of third party software not development, alpha, beta or release candidate code. 47 | * Do not assume that related software is of the same quality as Pylons itself, even if Pylons users frequently make use of it. 48 | * Subscribe to the wsgi-security-announce@googlegroups.com mailing list to be informed of security issues and their solutions. 49 | 50 | .. |at| image:: _static/at.png 51 | -------------------------------------------------------------------------------- /pylons/docs/en/thirdparty/formencode_api.rst: -------------------------------------------------------------------------------- 1 | .. _formencode: 2 | 3 | ========== 4 | FormEncode 5 | ========== 6 | 7 | FormEncode is a validation and form generation package. The validation can be used separately from the form generation. The validation works on compound data structures, with all parts being nestable. It is separate from HTTP or any other input mechanism. 8 | 9 | These module API docs are divided into section by category. 10 | 11 | Core API 12 | ======== 13 | 14 | :mod:`formencode.api` 15 | --------------------- 16 | 17 | These functions are used mostly internally by FormEncode. 18 | 19 | .. automodule:: formencode.api 20 | 21 | .. function:: is_validator(obj) 22 | 23 | Returns whether ``obj`` is a validator object or not. 24 | 25 | .. autoclass:: Invalid 26 | :members: 27 | 28 | .. automethod:: __init__ 29 | 30 | .. autoclass:: Validator 31 | :members: 32 | 33 | .. autoclass:: FancyValidator 34 | :members: 35 | 36 | 37 | :mod:`formencode.schema` 38 | ------------------------ 39 | 40 | The FormEncode schema is one of the most important parts of using FormEncode, 41 | as it lets you organize validators into parts that can be re-used between 42 | schemas. Generally, a single schema will represent an entire form, but may 43 | inherit other schemas for re-usable validation parts (ie, maybe multiple 44 | forms all requires first and last name). 45 | 46 | .. module:: formencode.schema 47 | 48 | .. autoclass:: Schema 49 | .. autoclass:: SimpleFormValidator 50 | 51 | 52 | Validators 53 | ========== 54 | 55 | .. automodule:: formencode.validators 56 | 57 | .. autoclass:: Bool 58 | .. autoclass:: CIDR 59 | .. autoclass:: CreditCardValidator 60 | .. autoclass:: CreditCardExpires 61 | .. autoclass:: CreditCardSecurityCode 62 | .. autoclass:: DateConverter 63 | .. autoclass:: DateValidator 64 | .. autoclass:: DictConverter 65 | .. autoclass:: Email 66 | .. autoclass:: Empty 67 | .. autoclass:: FieldsMatch 68 | .. autoclass:: FieldStorageUploadConverter 69 | .. autoclass:: FileUploadKeeper 70 | .. autoclass:: FormValidator 71 | .. autoclass:: IndexListConverter 72 | .. autoclass:: Int 73 | .. autoclass:: IPhoneNumberValidator 74 | .. autoclass:: MACAddress 75 | .. autoclass:: MaxLength 76 | .. autoclass:: MinLength 77 | .. autoclass:: Number 78 | .. autoclass:: NotEmpty 79 | .. autoclass:: OneOf 80 | .. autoclass:: PhoneNumber 81 | .. autoclass:: PlainText 82 | .. autoclass:: PostalCode 83 | .. autoclass:: Regex 84 | .. autoclass:: RequireIfMissing 85 | .. autoclass:: Set 86 | .. autoclass:: SignedString 87 | .. autoclass:: StateProvince 88 | .. autoclass:: String 89 | .. autoclass:: StringBool 90 | .. autoclass:: StripField 91 | .. autoclass:: TimeConverter 92 | .. autoclass:: UnicodeString 93 | .. autoclass:: URL 94 | 95 | 96 | Wrapper Validators 97 | ------------------ 98 | 99 | .. autoclass:: ConfirmType 100 | .. autoclass:: Wrapper 101 | .. autoclass:: Constant 102 | 103 | 104 | Validator Modifiers 105 | =================== 106 | 107 | :mod:`formencode.compound` 108 | -------------------------- 109 | 110 | .. automodule:: formencode.compound 111 | 112 | .. autoclass:: Any 113 | 114 | .. autoclass:: All 115 | 116 | 117 | :mod:`formencode.foreach` 118 | ------------------------- 119 | 120 | .. automodule:: formencode.foreach 121 | 122 | .. autoclass:: ForEach 123 | 124 | 125 | HTML Parsing and Form Filling 126 | ============================= 127 | 128 | :mod:`formencode.htmlfill` 129 | -------------------------- 130 | 131 | .. automodule:: formencode.htmlfill 132 | 133 | .. autofunction:: render 134 | .. autofunction:: default_formatter 135 | .. autofunction:: none_formatter 136 | .. autofunction:: escape_formatter 137 | .. autofunction:: escapenl_formatter 138 | .. autoclass:: FillingParser 139 | 140 | -------------------------------------------------------------------------------- /pylons/docs/en/thirdparty/index.rst: -------------------------------------------------------------------------------- 1 | .. _third_party_components: 2 | 3 | ====================== 4 | Third-party components 5 | ====================== 6 | 7 | .. toctree:: 8 | :maxdepth: 1 9 | 10 | formencode_api 11 | weberror 12 | webtest 13 | webob 14 | -------------------------------------------------------------------------------- /pylons/docs/en/thirdparty/weberror.rst: -------------------------------------------------------------------------------- 1 | :mod:`weberror` -- Weberror 2 | =========================== 3 | 4 | .. automodule:: weberror 5 | 6 | :mod:`weberror.errormiddleware` 7 | ------------------------------- 8 | .. currentmodule:: weberror.errormiddleware 9 | .. automodule:: weberror.errormiddleware 10 | .. autoclass:: ErrorMiddleware 11 | :members: 12 | 13 | :mod:`weberror.evalcontext` 14 | --------------------------- 15 | .. currentmodule:: weberror.evalcontext 16 | .. automodule:: weberror.evalcontext 17 | 18 | .. autoclass:: weberror.evalcontext.EvalContext 19 | :members: 20 | 21 | :mod:`weberror.evalexception` 22 | ----------------------------- 23 | .. currentmodule:: weberror.evalexception 24 | .. automodule:: weberror.evalexception 25 | 26 | .. autoclass:: weberror.evalexception.EvalException 27 | :members: 28 | 29 | :mod:`weberror.formatter` 30 | ------------------------- 31 | .. currentmodule:: weberror.formatter 32 | .. automodule:: weberror.formatter 33 | .. autoclass:: AbstractFormatter 34 | :members: 35 | .. autoclass:: TextFormatter 36 | :members: 37 | .. autoclass:: HTMLFormatter 38 | :members: 39 | .. autoclass:: XMLFormatter 40 | :members: 41 | .. autofunction:: create_text_node 42 | .. autofunction:: html_quote 43 | .. autofunction:: format_html 44 | .. autofunction:: format_text 45 | .. autofunction:: format_xml 46 | .. autofunction:: str2html 47 | .. autofunction:: _str2html 48 | .. autofunction:: truncate 49 | .. autofunction:: make_wrappable 50 | .. autofunction:: make_pre_wrappable 51 | 52 | 53 | :mod:`weberror.reporter` 54 | ------------------------ 55 | .. currentmodule:: weberror.reporter 56 | .. automodule:: weberror.reporter 57 | .. autoclass:: Reporter 58 | :members: 59 | .. autoclass:: EmailReporter 60 | :members: 61 | .. autoclass:: LogReporter 62 | :members: 63 | .. autoclass:: FileReporter 64 | :members: 65 | .. autoclass:: WSGIAppReporter 66 | :members: 67 | 68 | 69 | 70 | :mod:`weberror.collector` 71 | ------------------------- 72 | .. currentmodule:: weberror.collector 73 | .. automodule:: weberror.collector 74 | 75 | .. autoclass:: ExceptionCollector 76 | :members: 77 | 78 | .. autoclass:: ExceptionFrame 79 | :members: 80 | 81 | .. autofunction:: collect_exception 82 | 83 | -------------------------------------------------------------------------------- /pylons/docs/en/thirdparty/webob.rst: -------------------------------------------------------------------------------- 1 | :mod:`webob` -- Request/Response objects 2 | ======================================== 3 | 4 | .. automodule:: webob 5 | 6 | Request 7 | ------- 8 | 9 | .. autoclass:: Request 10 | 11 | .. automodule:: webob.acceptparse 12 | .. autoclass:: Accept 13 | .. autoclass:: MIMEAccept 14 | 15 | .. automodule:: webob.byterange 16 | .. autoclass:: Range 17 | 18 | .. automodule:: webob.cachecontrol 19 | .. autoclass:: CacheControl 20 | 21 | .. automodule:: webob.datastruct 22 | .. autoclass:: EnvironHeaders 23 | 24 | .. automodule:: webob.etag 25 | .. autoclass:: ETagMatcher 26 | .. autoclass:: IfRange 27 | 28 | 29 | Response 30 | -------- 31 | 32 | .. autoclass:: webob.Response 33 | 34 | .. autoclass:: webob.byterange.ContentRange 35 | 36 | .. autoclass:: webob.cachecontrol.CacheControl 37 | 38 | .. automodule:: webob.headerdict 39 | .. autoclass:: HeaderDict 40 | 41 | 42 | Misc Functions 43 | -------------- 44 | 45 | .. autofunction:: webob.html_escape 46 | 47 | .. comment: 48 | not sure what to do with these constants; not autoclass 49 | .. autoclass:: webob.day 50 | .. autoclass:: webob.week 51 | .. autoclass:: webob.hour 52 | .. autoclass:: webob.minute 53 | .. autoclass:: webob.second 54 | .. autoclass:: webob.month 55 | .. autoclass:: webob.year 56 | 57 | .. autoclass:: webob.response.AppIterRange 58 | 59 | .. automodule:: webob.multidict 60 | .. autoclass:: MultiDict 61 | .. autoclass:: UnicodeMultiDict 62 | .. autoclass:: NestedMultiDict 63 | .. autoclass:: NoVars 64 | 65 | .. automodule:: webob.updatedict 66 | .. autoclass:: webob.updatedict.UpdateDict 67 | 68 | 69 | Descriptors 70 | ----------- 71 | 72 | .. autoclass:: webob.descriptors.environ_getter 73 | .. autoclass:: webob.descriptors.header_getter 74 | .. autoclass:: webob.descriptors.converter 75 | .. autoclass:: webob.descriptors.deprecated_property 76 | -------------------------------------------------------------------------------- /pylons/docs/en/thirdparty/webtest.rst: -------------------------------------------------------------------------------- 1 | :mod:`webtest` -- WebTest 2 | ========================= 3 | 4 | .. currentmodule:: webtest 5 | .. automodule:: webtest 6 | 7 | .. autoclass:: TestApp 8 | :members: 9 | 10 | .. autoclass:: TestResponse 11 | :members: 12 | 13 | .. autoclass:: Form 14 | :members: 15 | -------------------------------------------------------------------------------- /pylons/docs/en/tutorials/index.rst: -------------------------------------------------------------------------------- 1 | .. _tutorials: 2 | 3 | Pylons Tutorials 4 | ================ 5 | 6 | A small collection of relevant tutorials. 7 | 8 | .. toctree:: 9 | :maxdepth: 2 10 | 11 | quickwiki_tutorial 12 | understanding_unicode 13 | -------------------------------------------------------------------------------- /pylons/docs/en/windowsnotes.rst: -------------------------------------------------------------------------------- 1 | .. _windows_notes: 2 | 3 | ============= 4 | Windows Notes 5 | ============= 6 | 7 | Python scripts installed as part of the Pylons install process will be put in the ``Scripts`` directory of your Python installation, typically in ``C:\Python24\Scripts``. By default on Windows, this directory is not in your ``PATH``; this can cause the following error message when running a command such as ``paster`` from the command prompt: 8 | 9 | .. code-block:: text 10 | 11 | C:\Documents and Settings\James>paster 12 | 'paster' is not recognized as an internal or external command, 13 | operable program or batch file. 14 | 15 | To run the scripts installed with Pylons either the full path must be specified: 16 | 17 | .. code-block:: text 18 | 19 | C:\Documents and Settings\James>C:\Python24\Scripts\paster 20 | Usage: C:\Python24\Scripts\paster-script.py COMMAND 21 | usage: paster-script.py [paster_options] COMMAND [command_options] 22 | 23 | options: 24 | --version show program's version number and exit 25 | --plugin=PLUGINS Add a plugin to the list of commands (plugins are Egg 26 | specs; will also require() the Egg) 27 | -h, --help Show this help message 28 | 29 | ... etc ... 30 | 31 | or (the preferable solution) the ``Scripts`` directory must be added to the ``PATH`` as described below. 32 | 33 | For Win2K or WinXP 34 | ------------------ 35 | 36 | #. From the desktop or Start Menu, right click My Computer and click Properties. 37 | #. In the System Properties window, click on the Advanced tab. 38 | #. In the Advanced section, click the Environment Variables button. 39 | #. Finally, in the Environment Variables window, highlight the path variable in the Systems Variable section and click edit. Add or modify the path lines with the paths you wish the computer to access. Each different directory is separated with a semicolon as shown below: 40 | 41 | .. code-block:: text 42 | 43 | C:\Program Files;C:\WINDOWS;C:\WINDOWS\System32 44 | 45 | #. Add the path to your scripts directory: 46 | 47 | .. code-block:: text 48 | 49 | C:\Program Files;C:\WINDOWS;C:\WINDOWS\System32;C:\Python24\Scripts 50 | 51 | See `Finally`_ below. 52 | 53 | For Windows 95, 98 and ME 54 | ------------------------- 55 | 56 | Edit ``autoexec.bat``, and add the following line to the end of the file: 57 | 58 | .. code-block:: bash 59 | 60 | set PATH=%PATH%;C:\Python24\Scripts 61 | 62 | See `Finally`_ below. 63 | 64 | Finally 65 | ------- 66 | 67 | Restarting your computer may be required to enable the change to the ``PATH``. Then commands may be entered from any location: 68 | 69 | .. code-block:: text 70 | 71 | C:\Documents and Settings\James>paster 72 | Usage: C:\Python24\Scripts\paster-script.py COMMAND 73 | usage: paster-script.py [paster_options] COMMAND [command_options] 74 | 75 | options: 76 | --version show program's version number and exit 77 | --plugin=PLUGINS Add a plugin to the list of commands (plugins are Egg 78 | specs; will also require() the Egg) 79 | -h, --help Show this help message 80 | 81 | ... etc ... 82 | 83 | All documentation assumes the ``PATH`` is setup correctly as described above. 84 | -------------------------------------------------------------------------------- /pylons/error.py: -------------------------------------------------------------------------------- 1 | """Custom EvalException support 2 | 3 | Provides template engine HTML error formatters for the Template tab of 4 | EvalException. 5 | 6 | """ 7 | import sys 8 | 9 | try: 10 | import mako.exceptions 11 | except ImportError: 12 | mako = None 13 | 14 | __all__ = ['handle_mako_error'] 15 | 16 | 17 | def handle_mako_error(context, exc): 18 | try: 19 | exc.is_mako_exception = True 20 | except: 21 | pass 22 | raise exc, None, sys.exc_info()[2] 23 | 24 | 25 | def myghty_html_data(exc_value): 26 | """Format a Myghty exception as HTML""" 27 | if hasattr(exc_value, 'htmlformat'): 28 | return exc_value.htmlformat()[333:-14] 29 | if hasattr(exc_value, 'mtrace'): 30 | return exc_value.mtrace.htmlformat()[333:-14] 31 | 32 | template_error_formatters = [myghty_html_data] 33 | 34 | 35 | if mako: 36 | def mako_html_data(exc_value): 37 | """Format a Mako exception as HTML""" 38 | if getattr(exc_value, 'is_mako_exception', False) or \ 39 | isinstance(exc_value, (mako.exceptions.CompileException, 40 | mako.exceptions.SyntaxException)): 41 | return mako.exceptions.html_error_template().render(full=False, 42 | css=False) 43 | template_error_formatters.insert(0, mako_html_data) 44 | -------------------------------------------------------------------------------- /pylons/i18n/__init__.py: -------------------------------------------------------------------------------- 1 | """Internationalization and Localization functionality""" 2 | from pylons.i18n.translation import * 3 | -------------------------------------------------------------------------------- /pylons/log.py: -------------------------------------------------------------------------------- 1 | """Logging related functionality 2 | 3 | This logging Handler logs to ``environ['wsgi.errors']`` as designated 4 | in :pep:`333`. 5 | 6 | """ 7 | import logging 8 | import types 9 | 10 | import pylons 11 | 12 | __all__ = ['WSGIErrorsHandler'] 13 | 14 | 15 | class WSGIErrorsHandler(logging.Handler): 16 | 17 | """A handler class that writes logging records to 18 | `environ['wsgi.errors']`. 19 | 20 | This code is derived from CherryPy's 21 | :class:`cherrypy._cplogging.WSGIErrorHandler`. 22 | 23 | ``cache`` 24 | Whether the `wsgi.errors` stream is cached (instead of looked up 25 | via `pylons.request.environ` per every logged message). Enabling 26 | this option is not recommended (particularly for the use case of 27 | logging to `wsgi.errors` outside of a request) as the behavior 28 | of a cached `wsgi.errors` stream is not strictly defined. In 29 | particular, `mod_wsgi `_'s `wsgi.errors` 30 | will raise an exception when used outside of a request. 31 | 32 | """ 33 | 34 | def __init__(self, cache=False, *args, **kwargs): 35 | logging.Handler.__init__(self, *args, **kwargs) 36 | self.cache = cache 37 | self.cached_stream = None 38 | 39 | def get_wsgierrors(self): 40 | """Return the wsgi.errors stream 41 | 42 | Raises a TypeError when outside of a web request 43 | (pylons.request is not setup) 44 | 45 | """ 46 | if not self.cache: 47 | return pylons.request.environ.get('wsgi.errors') 48 | elif not self.cached_stream: 49 | self.cached_stream = pylons.request.environ.get('wsgi.errors') 50 | return self.cached_stream 51 | return self.cached_stream 52 | 53 | def flush(self): 54 | """Flushes the stream""" 55 | try: 56 | stream = self.get_wsgierrors() 57 | except TypeError: 58 | pass 59 | else: 60 | if stream: 61 | stream.flush() 62 | 63 | def emit(self, record): 64 | """Emit a record""" 65 | try: 66 | stream = self.get_wsgierrors() 67 | except TypeError: 68 | pass 69 | else: 70 | if not stream: 71 | return 72 | try: 73 | msg = self.format(record) 74 | fs = "%s\n" 75 | if not hasattr(types, "UnicodeType"): # if no unicode support 76 | stream.write(fs % msg) 77 | else: 78 | try: 79 | stream.write(fs % msg) 80 | except UnicodeError: 81 | stream.write(fs % msg.encode("UTF-8")) 82 | self.flush() 83 | except (KeyboardInterrupt, SystemExit): 84 | raise 85 | except: 86 | self.handleError(record) 87 | -------------------------------------------------------------------------------- /pylons/media/img/bar-bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/pylons/media/img/bar-bg.png -------------------------------------------------------------------------------- /pylons/media/img/bg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/pylons/media/img/bg.jpg -------------------------------------------------------------------------------- /pylons/media/img/bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/pylons/media/img/bg.png -------------------------------------------------------------------------------- /pylons/media/img/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/pylons/media/img/favicon.ico -------------------------------------------------------------------------------- /pylons/media/img/hatch-yellow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/pylons/media/img/hatch-yellow.png -------------------------------------------------------------------------------- /pylons/media/img/header.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/pylons/media/img/header.png -------------------------------------------------------------------------------- /pylons/media/img/highlight.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/pylons/media/img/highlight.png -------------------------------------------------------------------------------- /pylons/media/img/logo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/pylons/media/img/logo.gif -------------------------------------------------------------------------------- /pylons/media/img/main-nav-bg-on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/pylons/media/img/main-nav-bg-on.png -------------------------------------------------------------------------------- /pylons/media/img/main-nav-bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/pylons/media/img/main-nav-bg.png -------------------------------------------------------------------------------- /pylons/media/img/plus.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/pylons/media/img/plus.jpg -------------------------------------------------------------------------------- /pylons/media/img/pylons-logo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/pylons/media/img/pylons-logo.gif -------------------------------------------------------------------------------- /pylons/media/img/pylons-powered-02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/pylons/media/img/pylons-powered-02.png -------------------------------------------------------------------------------- /pylons/media/img/tab-brown.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/pylons/media/img/tab-brown.png -------------------------------------------------------------------------------- /pylons/media/img/tab-traceback.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/pylons/media/img/tab-traceback.png -------------------------------------------------------------------------------- /pylons/media/img/tab-white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/pylons/media/img/tab-white.png -------------------------------------------------------------------------------- /pylons/media/img/tab-yellow-highlight.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/pylons/media/img/tab-yellow-highlight.png -------------------------------------------------------------------------------- /pylons/media/img/tab-yellow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/pylons/media/img/tab-yellow.png -------------------------------------------------------------------------------- /pylons/media/img/warning.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/pylons/media/img/warning.gif -------------------------------------------------------------------------------- /pylons/media/style/black.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-family: arial, helvetica, sans-serif; 3 | background-color: #ffc900; 4 | background-image: url(../img/bg.png); 5 | background-repeat: repeat-x; 6 | width:100%; 7 | height:100%; 8 | margin:0; 9 | max-height: 100%; 10 | padding:0; 11 | border:none; 12 | line-height:1.4; 13 | } 14 | #container { 15 | color:white; 16 | background-color:#111; 17 | position: absolute; 18 | left: 50%; 19 | width: 500px; 20 | margin-left: -300px; 21 | padding:50px; 22 | height:100%; 23 | } 24 | #footer { 25 | margin: 120px 0 0 0; 26 | padding: 3px; 27 | text-align:center; 28 | font-size:small; 29 | background-color:#222; 30 | letter-spacing: 1px; 31 | } 32 | h1 { 33 | text-align:center; 34 | font-size:xx-large; 35 | font-weight:normal; 36 | margin: 0 0 20px 0; 37 | border:none; 38 | padding:0; 39 | letter-spacing: 5px; 40 | } 41 | h2 { 42 | font-size:xx-large; 43 | font-weight:normal; 44 | margin: 0 0 20px 0; 45 | border:none; 46 | padding:0; 47 | } 48 | hr { 49 | margin-bottom:30px; 50 | border: 1px solid #222; 51 | background-color: #222; 52 | padding: 2px; 53 | } 54 | #logo { 55 | background-image: url(../img/pylons-logo.gif); 56 | background-repeat: no-repeat; 57 | height: 0; 58 | overflow: hidden; 59 | padding-top: 99px; 60 | width: 239px; 61 | } 62 | #left { 63 | float:left; 64 | width:250px; 65 | margin:0 50px 0 0; 66 | border:none; 67 | padding:0 0 0 10px; 68 | } 69 | #right { 70 | margin:0 0 0 330px; 71 | border:none; 72 | padding:0; 73 | } 74 | ul { 75 | list-style:none; 76 | margin:0; 77 | border:none; 78 | padding:0; 79 | } 80 | a:visited { 81 | color:white; 82 | text-decoration:none; 83 | } 84 | a:link { 85 | color:white; 86 | text-decoration:none; 87 | } 88 | -------------------------------------------------------------------------------- /pylons/media/style/itraceback.css: -------------------------------------------------------------------------------- 1 | /* @override http://localhost:5000/_debug/media/pylons/style/itraceback.css */ 2 | 3 | div.credits { 4 | padding: 5px 0 0 0; 5 | color: #777; 6 | font-size: 11px; 7 | } 8 | 9 | #footer { 10 | border-top: 1px solid #666666; 11 | padding: 0; 12 | margin: 20px 0 0 0; 13 | } 14 | 15 | #pylons_logo { 16 | float: right; 17 | margin: 5px 0 0 0; 18 | } 19 | 20 | div.widget_layout { 21 | margin: 30px 0 0 0; 22 | } 23 | div.feature-highlight { 24 | float: right; 25 | width: 400px; 26 | } 27 | 28 | div.feature-highlight button { 29 | margin: 15px 0 0 20px; 30 | } 31 | 32 | div#service_widget { 33 | width: 500px; 34 | padding: 0; 35 | margin: 0; 36 | margin-right: 10px; 37 | line-height: 1.4; 38 | } 39 | 40 | div#service_widget h4, div.overviewtab h3 { 41 | margin: 0; 42 | padding: 0; 43 | font-weight: bold; 44 | font-size: 100%; 45 | } 46 | 47 | div#service_widget h2 { 48 | color: #000; 49 | border-bottom: 1px solid #0a0; 50 | font-variant: small-caps; 51 | font-size: 20px; 52 | line-height: 1.3; 53 | font-weight: bold; 54 | } 55 | 56 | div.overviewtab, div.posttracebacktab, div.searchtab { 57 | padding: 13px 10px 10px 10px; 58 | background-color: #f8f8f8; 59 | border-bottom: 1px solid #ccc; 60 | border-right: 1px solid #ccc; 61 | border-left: 1px solid #ccc; 62 | } 63 | 64 | div.clearfix { 65 | clear: left; 66 | margin: 0; 67 | padding: 0; 68 | height: 0; 69 | } 70 | 71 | .hide { 72 | display: none; 73 | } 74 | 75 | input.query { 76 | width: 350px; 77 | } 78 | 79 | p.query { 80 | margin: 0 0 0 20px; 81 | padding: 0; 82 | } 83 | 84 | /* Nav Bar */ 85 | 86 | #nv li { 87 | display:block; 88 | float:left; 89 | list-style-type:none; 90 | margin:0; 91 | padding:0; 92 | } 93 | #nv a { 94 | display:block; 95 | float:left; 96 | border: 0px; 97 | } 98 | 99 | 100 | 101 | 102 | /*** Tabs ***/ 103 | #supportnav { float: left; width: 500px; border-bottom: 1px solid #CCC; margin: 0px; padding: 0px; } 104 | #supportnav li { float: left; padding-left: 10px; margin-right: 3px; background: url("../img/tab-traceback.png") no-repeat left top; } 105 | #supportnav li.first-child { margin: 0; } 106 | #supportnav li a { display: block; padding: 3px 10px 3px 0; border: none; outline: none; background: url("../img/tab-traceback.png") no-repeat right top; color: #666; } 107 | #supportnav li a:hover { color: #333; } 108 | #supportnav li.active { position: relative; margin-bottom: -1px; background-position: 0 -40px; } 109 | #supportnav li.active a { display: block; padding: 3px 10px 4px 0; background: url("../img/tab-traceback.png") no-repeat right -40px; font-weight: bold; color: #333; } 110 | #supportnav li.active a { background-position: right -40px; } 111 | * html #supportnav { margin-bottom: 0; } 112 | 113 | div.searchresults div.result { 114 | margin-bottom: 5px; 115 | padding: 2px 0px 2px 4px; 116 | cursor: pointer; 117 | background-color: rgb(247, 247, 247); 118 | border: 1px solid rgb(235, 235, 235); 119 | } 120 | 121 | div.searchresults div.result div.meta { 122 | font-size: 0.8em; 123 | color: rgb(1, 116, 22); 124 | } 125 | 126 | p.results a { 127 | float: right; 128 | } 129 | 130 | div.searchresults div.blurb { 131 | font-size: 0.8em; 132 | } 133 | 134 | div.searchresults div.result a { 135 | text-decoration: underline; 136 | font-size: 0.9em; 137 | cursor: pointer; 138 | } 139 | -------------------------------------------------------------------------------- /pylons/templates/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/pylons/templates/__init__.py -------------------------------------------------------------------------------- /pylons/templates/controller.py_tmpl: -------------------------------------------------------------------------------- 1 | import logging 2 | 3 | from pylons import request, response, session, tmpl_context as c, url 4 | from pylons.controllers.util import abort, redirect 5 | 6 | {{importstatement}} 7 | 8 | log = logging.getLogger(__name__) 9 | 10 | class {{name}}Controller(BaseController): 11 | 12 | def index(self): 13 | # Return a rendered template 14 | #return render('/{{tmpl_name}}.mako') 15 | # or, return a string 16 | return 'Hello World' 17 | -------------------------------------------------------------------------------- /pylons/templates/default_project/+package+/__init__.py_tmpl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/pylons/templates/default_project/+package+/__init__.py_tmpl -------------------------------------------------------------------------------- /pylons/templates/default_project/+package+/config/__init__.py_tmpl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/pylons/templates/default_project/+package+/config/__init__.py_tmpl -------------------------------------------------------------------------------- /pylons/templates/default_project/+package+/config/deployment.ini_tmpl_tmpl: -------------------------------------------------------------------------------- 1 | # 2 | # {{project}} - Pylons configuration 3 | # 4 | # The %(here)s variable will be replaced with the parent directory of this file 5 | # 6 | [DEFAULT] 7 | debug = true 8 | email_to = you@yourdomain.com 9 | smtp_server = localhost 10 | error_email_from = paste@localhost 11 | 12 | [server:main] 13 | use = egg:Paste#http 14 | host = 0.0.0.0 15 | port = 5000 16 | 17 | [app:main] 18 | use = egg:{{project}} 19 | full_stack = true 20 | static_files = true 21 | 22 | cache_dir = %(here)s/data 23 | beaker.session.key = {{package}} 24 | beaker.session.secret = ${app_instance_secret} 25 | app_instance_uuid = ${app_instance_uuid} 26 | 27 | # If you'd like to fine-tune the individual locations of the cache data dirs 28 | # for the Cache data, or the Session saves, un-comment the desired settings 29 | # here: 30 | #beaker.cache.data_dir = %(here)s/data/cache 31 | #beaker.session.data_dir = %(here)s/data/sessions 32 | 33 | {{if sqlalchemy}} 34 | 35 | # SQLAlchemy database URL 36 | sqlalchemy.url = sqlite:///production.db 37 | 38 | {{endif}} 39 | 40 | # WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT* 41 | # Debug mode will enable the interactive debugging tool, allowing ANYONE to 42 | # execute malicious code after an exception is raised. 43 | set debug = false 44 | 45 | 46 | # Logging configuration 47 | [loggers] 48 | keys = root 49 | 50 | [handlers] 51 | keys = console 52 | 53 | [formatters] 54 | keys = generic 55 | 56 | [logger_root] 57 | level = INFO 58 | handlers = console 59 | 60 | [handler_console] 61 | class = StreamHandler 62 | args = (sys.stderr,) 63 | level = NOTSET 64 | formatter = generic 65 | 66 | [formatter_generic] 67 | format = %(asctime)s %(levelname)-5.5s [%(name)s] [%(threadName)s] %(message)s 68 | -------------------------------------------------------------------------------- /pylons/templates/default_project/+package+/config/environment.py_tmpl: -------------------------------------------------------------------------------- 1 | """Pylons environment configuration""" 2 | import os 3 | 4 | 5 | {{if template_engine == 'mako'}} 6 | from mako.lookup import TemplateLookup 7 | {{elif template_engine == 'genshi'}} 8 | from genshi.template import TemplateLoader 9 | {{elif template_engine == 'jinja2'}} 10 | from jinja2 import Environment, FileSystemLoader 11 | {{endif}} 12 | from pylons.configuration import PylonsConfig 13 | {{if template_engine == 'mako'}} 14 | from pylons.error import handle_mako_error 15 | {{endif}} 16 | {{if sqlalchemy}} 17 | from sqlalchemy import engine_from_config 18 | {{endif}} 19 | 20 | import {{package}}.lib.app_globals as app_globals 21 | import {{package}}.lib.helpers 22 | from {{package}}.config.routing import make_map 23 | {{if sqlalchemy}} 24 | from {{package}}.model import init_model 25 | {{endif}} 26 | 27 | def load_environment(global_conf, app_conf): 28 | """Configure the Pylons environment via the ``pylons.config`` 29 | object 30 | """ 31 | config = PylonsConfig() 32 | 33 | # Pylons paths 34 | root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 35 | paths = dict(root=root, 36 | controllers=os.path.join(root, 'controllers'), 37 | static_files=os.path.join(root, 'public'), 38 | templates=[os.path.join(root, 'templates')]) 39 | 40 | # Initialize config with the basic options 41 | config.init_app(global_conf, app_conf, package='{{package}}', paths=paths) 42 | 43 | config['routes.map'] = make_map(config) 44 | config['pylons.app_globals'] = app_globals.Globals(config) 45 | config['pylons.h'] = {{package}}.lib.helpers 46 | 47 | # Setup cache object as early as possible 48 | import pylons 49 | pylons.cache._push_object(config['pylons.app_globals'].cache) 50 | 51 | {{if template_engine == 'mako'}} 52 | 53 | # Create the Mako TemplateLookup, with the default auto-escaping 54 | config['pylons.app_globals'].mako_lookup = TemplateLookup( 55 | directories=paths['templates'], 56 | error_handler=handle_mako_error, 57 | module_directory=os.path.join(app_conf['cache_dir'], 'templates'), 58 | input_encoding='utf-8', default_filters=['escape'], 59 | imports=['from markupsafe import escape']) 60 | {{elif template_engine == 'genshi'}} 61 | 62 | # Create the Genshi TemplateLoader 63 | config['pylons.app_globals'].genshi_loader = TemplateLoader( 64 | paths['templates'], auto_reload=True) 65 | {{elif template_engine == 'jinja2'}} 66 | 67 | # Create the Jinja2 Environment 68 | jinja2_env = Environment(loader=FileSystemLoader(paths['templates'])) 69 | config['pylons.app_globals'].jinja2_env = jinja2_env 70 | {{endif}}{{if sqlalchemy}} 71 | # Setup the SQLAlchemy database engine 72 | engine = engine_from_config(config, 'sqlalchemy.') 73 | init_model(engine) 74 | {{endif}} 75 | 76 | # CONFIGURATION OPTIONS HERE (note: all config options will override 77 | # any Pylons config options) 78 | 79 | return config 80 | -------------------------------------------------------------------------------- /pylons/templates/default_project/+package+/config/middleware.py_tmpl: -------------------------------------------------------------------------------- 1 | """Pylons middleware initialization""" 2 | from beaker.middleware import SessionMiddleware 3 | from paste.cascade import Cascade 4 | from paste.registry import RegistryManager 5 | from paste.urlparser import StaticURLParser 6 | from paste.deploy.converters import asbool 7 | from pylons.middleware import ErrorHandler, StatusCodeRedirect 8 | from pylons.wsgiapp import PylonsApp 9 | from routes.middleware import RoutesMiddleware 10 | 11 | from {{package}}.config.environment import load_environment 12 | 13 | def make_app(global_conf, full_stack=True, static_files=True, **app_conf): 14 | """Create a Pylons WSGI application and return it 15 | 16 | ``global_conf`` 17 | The inherited configuration for this application. Normally from 18 | the [DEFAULT] section of the Paste ini file. 19 | 20 | ``full_stack`` 21 | Whether this application provides a full WSGI stack (by default, 22 | meaning it handles its own exceptions and errors). Disable 23 | full_stack when this application is "managed" by another WSGI 24 | middleware. 25 | 26 | ``static_files`` 27 | Whether this application serves its own static files; disable 28 | when another web server is responsible for serving them. 29 | 30 | ``app_conf`` 31 | The application's local configuration. Normally specified in 32 | the [app:] section of the Paste ini file (where 33 | defaults to main). 34 | 35 | """ 36 | # Configure the Pylons environment 37 | config = load_environment(global_conf, app_conf) 38 | 39 | # The Pylons WSGI app 40 | app = PylonsApp(config=config) 41 | 42 | # Routing/Session Middleware 43 | app = RoutesMiddleware(app, config['routes.map'], singleton=False) 44 | app = SessionMiddleware(app, config) 45 | 46 | # CUSTOM MIDDLEWARE HERE (filtered by error handling middlewares) 47 | 48 | if asbool(full_stack): 49 | # Handle Python exceptions 50 | app = ErrorHandler(app, global_conf, **config['pylons.errorware']) 51 | 52 | # Display error documents for 401, 403, 404 status codes (and 53 | # 500 when debug is disabled) 54 | if asbool(config['debug']): 55 | app = StatusCodeRedirect(app) 56 | else: 57 | app = StatusCodeRedirect(app, [400, 401, 403, 404, 500]) 58 | 59 | # Establish the Registry for this application 60 | app = RegistryManager(app) 61 | 62 | if asbool(static_files): 63 | # Serve static files 64 | static_app = StaticURLParser(config['pylons.paths']['static_files']) 65 | app = Cascade([static_app, app]) 66 | app.config = config 67 | return app 68 | -------------------------------------------------------------------------------- /pylons/templates/default_project/+package+/config/routing.py_tmpl: -------------------------------------------------------------------------------- 1 | """Routes configuration 2 | 3 | The more specific and detailed routes should be defined first so they 4 | may take precedent over the more generic routes. For more information 5 | refer to the routes manual at http://routes.groovie.org/docs/ 6 | """ 7 | from routes import Mapper 8 | 9 | def make_map(config): 10 | """Create, configure and return the routes Mapper""" 11 | map = Mapper(directory=config['pylons.paths']['controllers'], 12 | always_scan=config['debug']) 13 | map.minimization = False 14 | map.explicit = False 15 | 16 | # The ErrorController route (handles 404/500 error pages); it should 17 | # likely stay at the top, ensuring it can always be resolved 18 | map.connect('/error/{action}', controller='error') 19 | map.connect('/error/{action}/{id}', controller='error') 20 | 21 | # CUSTOM ROUTES HERE 22 | 23 | map.connect('/{controller}/{action}') 24 | map.connect('/{controller}/{action}/{id}') 25 | 26 | return map 27 | -------------------------------------------------------------------------------- /pylons/templates/default_project/+package+/controllers/__init__.py_tmpl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/pylons/templates/default_project/+package+/controllers/__init__.py_tmpl -------------------------------------------------------------------------------- /pylons/templates/default_project/+package+/controllers/error.py_tmpl: -------------------------------------------------------------------------------- 1 | import cgi 2 | 3 | from paste.urlparser import PkgResourcesParser 4 | from pylons.middleware import error_document_template 5 | from webhelpers.html.builder import literal 6 | 7 | from {{package}}.lib.base import BaseController 8 | 9 | class ErrorController(BaseController): 10 | """Generates error documents as and when they are required. 11 | 12 | The ErrorDocuments middleware forwards to ErrorController when error 13 | related status codes are returned from the application. 14 | 15 | This behaviour can be altered by changing the parameters to the 16 | ErrorDocuments middleware in your config/middleware.py file. 17 | 18 | """ 19 | def document(self): 20 | """Render the error document""" 21 | request = self._py_object.request 22 | resp = request.environ.get('pylons.original_response') 23 | content = literal(resp.body) or cgi.escape(request.GET.get('message', '')) 24 | page = error_document_template % \ 25 | dict(prefix=request.environ.get('SCRIPT_NAME', ''), 26 | code=cgi.escape(request.GET.get('code', str(resp.status_int))), 27 | message=content) 28 | return page 29 | 30 | def img(self, id): 31 | """Serve Pylons' stock images""" 32 | return self._serve_file('/'.join(['media/img', id])) 33 | 34 | def style(self, id): 35 | """Serve Pylons' stock stylesheets""" 36 | return self._serve_file('/'.join(['media/style', id])) 37 | 38 | def _serve_file(self, path): 39 | """Call Paste's FileApp (a WSGI application) to serve the file 40 | at the specified path 41 | """ 42 | request = self._py_object.request 43 | request.environ['PATH_INFO'] = '/%s' % path 44 | return PkgResourcesParser('pylons', 'pylons')(request.environ, self.start_response) 45 | -------------------------------------------------------------------------------- /pylons/templates/default_project/+package+/lib/__init__.py_tmpl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/pylons/templates/default_project/+package+/lib/__init__.py_tmpl -------------------------------------------------------------------------------- /pylons/templates/default_project/+package+/lib/app_globals.py_tmpl: -------------------------------------------------------------------------------- 1 | """The application's Globals object""" 2 | 3 | from beaker.cache import CacheManager 4 | from beaker.util import parse_cache_config_options 5 | 6 | class Globals(object): 7 | """Globals acts as a container for objects available throughout the 8 | life of the application 9 | 10 | """ 11 | 12 | def __init__(self, config): 13 | """One instance of Globals is created during application 14 | initialization and is available during requests via the 15 | 'app_globals' variable 16 | 17 | """ 18 | self.cache = CacheManager(**parse_cache_config_options(config)) 19 | -------------------------------------------------------------------------------- /pylons/templates/default_project/+package+/lib/base.py_tmpl: -------------------------------------------------------------------------------- 1 | """The base Controller API 2 | 3 | Provides the BaseController class for subclassing. 4 | """ 5 | from pylons.controllers import WSGIController 6 | {{if template_engine in ('genshi', 'jinja2', 'mako')}} 7 | from pylons.templating import render_{{template_engine}} as render 8 | {{endif}} 9 | {{if sqlalchemy}} 10 | 11 | from {{package}}.model.meta import Session 12 | {{endif}} 13 | 14 | class BaseController(WSGIController): 15 | 16 | def __call__(self, environ, start_response): 17 | """Invoke the Controller""" 18 | # WSGIController.__call__ dispatches to the Controller method 19 | # the request is routed to. This routing information is 20 | # available in environ['pylons.routes_dict'] 21 | {{if sqlalchemy}} 22 | try: 23 | return WSGIController.__call__(self, environ, start_response) 24 | finally: 25 | Session.remove(){{else}} return WSGIController.__call__(self, environ, start_response){{endif}} 26 | -------------------------------------------------------------------------------- /pylons/templates/default_project/+package+/lib/helpers.py_tmpl: -------------------------------------------------------------------------------- 1 | """Helper functions 2 | 3 | Consists of functions to typically be used within templates, but also 4 | available to Controllers. This module is available to templates as 'h'. 5 | """ 6 | # Import helpers as desired, or define your own, ie: 7 | #from webhelpers.html.tags import checkbox, password 8 | -------------------------------------------------------------------------------- /pylons/templates/default_project/+package+/model/__init__.py_tmpl: -------------------------------------------------------------------------------- 1 | {{if sqlalchemy}} 2 | """The application's model objects""" 3 | from {{package}}.model.meta import Session, Base 4 | 5 | 6 | def init_model(engine): 7 | """Call me before using any of the tables or classes in the model""" 8 | Session.configure(bind=engine) 9 | 10 | {{endif}} 11 | -------------------------------------------------------------------------------- /pylons/templates/default_project/+package+/model/meta.py_tmpl: -------------------------------------------------------------------------------- 1 | {{if sqlalchemy}} 2 | """SQLAlchemy Metadata and Session object""" 3 | from sqlalchemy.ext.declarative import declarative_base 4 | from sqlalchemy.orm import scoped_session, sessionmaker 5 | 6 | __all__ = ['Base', 'Session'] 7 | 8 | # SQLAlchemy session manager. Updated by model.init_model() 9 | Session = scoped_session(sessionmaker()) 10 | 11 | # The declarative Base 12 | Base = declarative_base() 13 | {{else}} 14 | {{skip_template()}} 15 | {{endif}} 16 | -------------------------------------------------------------------------------- /pylons/templates/default_project/+package+/public/bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/pylons/templates/default_project/+package+/public/bg.png -------------------------------------------------------------------------------- /pylons/templates/default_project/+package+/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/pylons/templates/default_project/+package+/public/favicon.ico -------------------------------------------------------------------------------- /pylons/templates/default_project/+package+/public/pylons-logo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/pylons/templates/default_project/+package+/public/pylons-logo.gif -------------------------------------------------------------------------------- /pylons/templates/default_project/+package+/templates/.distutils_placeholder: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/pylons/templates/default_project/+package+/templates/.distutils_placeholder -------------------------------------------------------------------------------- /pylons/templates/default_project/+package+/templates/__init__.py_tmpl: -------------------------------------------------------------------------------- 1 | {{if template_engine not in ['genshi', 'kid']}} 2 | {{skip_template()}} 3 | {{endif}} 4 | -------------------------------------------------------------------------------- /pylons/templates/default_project/+package+/tests/__init__.py_tmpl: -------------------------------------------------------------------------------- 1 | """Pylons application test package 2 | 3 | This package assumes the Pylons environment is already loaded, such as 4 | when this script is imported from the `nosetests --with-pylons=test.ini` 5 | command. 6 | 7 | This module initializes the application via ``websetup`` (`paster 8 | setup-app`) and provides the base testing objects. 9 | """ 10 | from unittest import TestCase 11 | import os 12 | import sys 13 | 14 | import pylons 15 | from pylons.i18n.translation import _get_translator 16 | from paste.deploy import loadapp 17 | from pylons import url 18 | from paste.script.appinstall import SetupCommand 19 | from routes.util import URLGenerator 20 | from webtest import TestApp 21 | 22 | from {{package}}.config.environment import load_environment 23 | 24 | __all__ = ['environ', 'url', 'TestController'] 25 | 26 | environ = {} 27 | here_dir = os.path.dirname(os.path.abspath(__file__)) 28 | conf_dir = os.path.dirname(os.path.dirname(here_dir)) 29 | 30 | sys.path.insert(0, conf_dir) 31 | 32 | 33 | class TestController(TestCase): 34 | def __init__(self, *args, **kwargs): 35 | wsgiapp = loadapp('config:test.ini', relative_to=conf_dir) 36 | config = wsgiapp.config 37 | pylons.app_globals._push_object(config['pylons.app_globals']) 38 | pylons.config._push_object(config) 39 | 40 | # Initialize a translator for tests that utilize i18n 41 | translator = _get_translator(pylons.config.get('lang')) 42 | pylons.translator._push_object(translator) 43 | 44 | url._push_object(URLGenerator(config['routes.map'], environ)) 45 | self.app = TestApp(wsgiapp) 46 | TestCase.__init__(self, *args, **kwargs) 47 | -------------------------------------------------------------------------------- /pylons/templates/default_project/+package+/tests/functional/__init__.py_tmpl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/pylons/templates/default_project/+package+/tests/functional/__init__.py_tmpl -------------------------------------------------------------------------------- /pylons/templates/default_project/+package+/tests/test_models.py_tmpl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/pylons/templates/default_project/+package+/tests/test_models.py_tmpl -------------------------------------------------------------------------------- /pylons/templates/default_project/+package+/websetup.py_tmpl: -------------------------------------------------------------------------------- 1 | """Setup the {{project}} application""" 2 | import logging 3 | 4 | from {{package}}.config.environment import load_environment 5 | {{if sqlalchemy}} 6 | from {{package}}.model.meta import Session, Base 7 | {{endif}} 8 | 9 | log = logging.getLogger(__name__) 10 | 11 | def setup_app(command, conf, vars): 12 | """Place any commands to setup {{package}} here""" 13 | # Don't reload the app if it was loaded under the testing environment 14 | load_environment(conf.global_conf, conf.local_conf) 15 | {{if sqlalchemy}} 16 | 17 | # Create the tables if they don't already exist 18 | Base.metadata.create_all(bind=Session.bind) 19 | {{endif}} 20 | -------------------------------------------------------------------------------- /pylons/templates/default_project/MANIFEST.in_tmpl: -------------------------------------------------------------------------------- 1 | include {{package}}/config/deployment.ini_tmpl 2 | recursive-include {{package}}/public * 3 | recursive-include {{package}}/templates * 4 | -------------------------------------------------------------------------------- /pylons/templates/default_project/README.txt_tmpl: -------------------------------------------------------------------------------- 1 | This file is for you to describe the {{project}} application. Typically 2 | you would include information such as the information below: 3 | 4 | Installation and Setup 5 | ====================== 6 | 7 | Install ``{{project}}`` using easy_install:: 8 | 9 | easy_install {{project}} 10 | 11 | Make a config file as follows:: 12 | 13 | paster make-config {{project}} config.ini 14 | 15 | Tweak the config file as appropriate and then setup the application:: 16 | 17 | paster setup-app config.ini 18 | 19 | Then you are ready to go. 20 | -------------------------------------------------------------------------------- /pylons/templates/default_project/development.ini_tmpl: -------------------------------------------------------------------------------- 1 | # 2 | # {{project}} - Pylons development environment configuration 3 | # 4 | # The %(here)s variable will be replaced with the parent directory of this file 5 | # 6 | [DEFAULT] 7 | debug = true 8 | # Uncomment and replace with the address which should receive any error reports 9 | #email_to = you@yourdomain.com 10 | smtp_server = localhost 11 | error_email_from = paste@localhost 12 | 13 | [server:main] 14 | use = egg:Paste#http 15 | host = 127.0.0.1 16 | port = 5000 17 | 18 | [app:main] 19 | use = egg:{{project}} 20 | full_stack = true 21 | static_files = true 22 | 23 | cache_dir = %(here)s/data 24 | beaker.session.key = {{package}} 25 | beaker.session.secret = somesecret 26 | 27 | # If you'd like to fine-tune the individual locations of the cache data dirs 28 | # for the Cache data, or the Session saves, un-comment the desired settings 29 | # here: 30 | #beaker.cache.data_dir = %(here)s/data/cache 31 | #beaker.session.data_dir = %(here)s/data/sessions 32 | 33 | {{if sqlalchemy}} 34 | 35 | # SQLAlchemy database URL 36 | sqlalchemy.url = sqlite:///%(here)s/development.db 37 | 38 | {{endif}} 39 | 40 | # WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT* 41 | # Debug mode will enable the interactive debugging tool, allowing ANYONE to 42 | # execute malicious code after an exception is raised. 43 | #set debug = false 44 | 45 | 46 | # Logging configuration 47 | [loggers] 48 | keys = root, routes, {{package_logger}}{{if sqlalchemy}}, sqlalchemy{{endif}} 49 | 50 | [handlers] 51 | keys = console 52 | 53 | [formatters] 54 | keys = generic 55 | 56 | [logger_root] 57 | level = INFO 58 | handlers = console 59 | 60 | [logger_routes] 61 | level = INFO 62 | handlers = 63 | qualname = routes.middleware 64 | # "level = DEBUG" logs the route matched and routing variables. 65 | 66 | [logger_{{package_logger}}] 67 | level = DEBUG 68 | handlers = 69 | qualname = {{package}} 70 | 71 | {{if sqlalchemy}} 72 | 73 | [logger_sqlalchemy] 74 | level = INFO 75 | handlers = 76 | qualname = sqlalchemy.engine 77 | # "level = INFO" logs SQL queries. 78 | # "level = DEBUG" logs SQL queries and results. 79 | # "level = WARN" logs neither. (Recommended for production systems.) 80 | {{endif}} 81 | 82 | [handler_console] 83 | class = StreamHandler 84 | args = (sys.stderr,) 85 | level = NOTSET 86 | formatter = generic 87 | 88 | [formatter_generic] 89 | format = %(asctime)s,%(msecs)03d %(levelname)-5.5s [%(name)s] [%(threadName)s] %(message)s 90 | datefmt = %H:%M:%S 91 | -------------------------------------------------------------------------------- /pylons/templates/default_project/setup.cfg_tmpl: -------------------------------------------------------------------------------- 1 | [egg_info] 2 | tag_build = dev 3 | tag_svn_revision = true 4 | 5 | [easy_install] 6 | find_links = http://www.pylonshq.com/download/ 7 | 8 | # Babel configuration 9 | [compile_catalog] 10 | domain = {{package}} 11 | directory = {{package}}/i18n 12 | statistics = true 13 | 14 | [extract_messages] 15 | add_comments = TRANSLATORS: 16 | output_file = {{package}}/i18n/{{package}}.pot 17 | width = 80 18 | 19 | [init_catalog] 20 | domain = {{package}} 21 | input_file = {{package}}/i18n/{{package}}.pot 22 | output_dir = {{package}}/i18n 23 | 24 | [update_catalog] 25 | domain = {{package}} 26 | input_file = {{package}}/i18n/{{package}}.pot 27 | output_dir = {{package}}/i18n 28 | previous = true 29 | -------------------------------------------------------------------------------- /pylons/templates/default_project/setup.py_tmpl: -------------------------------------------------------------------------------- 1 | try: 2 | from setuptools import setup, find_packages 3 | except ImportError: 4 | from ez_setup import use_setuptools 5 | use_setuptools() 6 | from setuptools import setup, find_packages 7 | 8 | setup( 9 | name='{{project}}', 10 | version='{{version}}', 11 | description={{repr(description)}}, 12 | author={{repr(author)}}, 13 | author_email={{repr(author_email)}}, 14 | url={{repr(url)}}, 15 | install_requires=[ 16 | "Pylons>=1.0.1rc1", 17 | {{if sqlalchemy}} 18 | "SQLAlchemy>=0.5", 19 | {{endif}} 20 | {{if template_engine == 'genshi'}} 21 | "Genshi>=0.4", 22 | {{elif template_engine == 'jinja2'}} 23 | "Jinja2", 24 | {{endif}} 25 | ], 26 | setup_requires=["PasteScript>=1.6.3"], 27 | packages=find_packages(exclude=['ez_setup']), 28 | include_package_data=True, 29 | test_suite='nose.collector', 30 | package_data={'{{package}}': ['i18n/*/LC_MESSAGES/*.mo']}, 31 | #message_extractors={'{{package}}': [ 32 | # ('**.py', 'python', None), 33 | # {{babel_templates_extractor}}('public/**', 'ignore', None)]}, 34 | zip_safe={{zip_safe}}, 35 | paster_plugins={{egg_plugins}}, 36 | entry_points=""" 37 | [paste.app_factory] 38 | main = {{package}}.config.middleware:make_app 39 | 40 | [paste.app_install] 41 | main = pylons.util:PylonsInstaller 42 | """, 43 | ) 44 | -------------------------------------------------------------------------------- /pylons/templates/default_project/test.ini_tmpl: -------------------------------------------------------------------------------- 1 | # 2 | # {{project}} - Pylons testing environment configuration 3 | # 4 | # The %(here)s variable will be replaced with the parent directory of this file 5 | # 6 | [DEFAULT] 7 | debug = true 8 | # Uncomment and replace with the address which should receive any error reports 9 | #email_to = you@yourdomain.com 10 | smtp_server = localhost 11 | error_email_from = paste@localhost 12 | 13 | [server:main] 14 | use = egg:Paste#http 15 | host = 127.0.0.1 16 | port = 5000 17 | 18 | [app:main] 19 | use = config:development.ini 20 | 21 | # Add additional test specific configuration options as necessary. 22 | -------------------------------------------------------------------------------- /pylons/templates/minimal_project/+package+/__init__.py_tmpl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/pylons/templates/minimal_project/+package+/__init__.py_tmpl -------------------------------------------------------------------------------- /pylons/templates/minimal_project/+package+/config/deployment.ini_tmpl_tmpl: -------------------------------------------------------------------------------- 1 | # 2 | # {{project}} - Pylons configuration 3 | # 4 | # The %(here)s variable will be replaced with the parent directory of this file 5 | # 6 | [DEFAULT] 7 | debug = true 8 | email_to = you@yourdomain.com 9 | smtp_server = localhost 10 | error_email_from = paste@localhost 11 | 12 | [server:main] 13 | use = egg:Paste#http 14 | host = 0.0.0.0 15 | port = 5000 16 | 17 | [app:main] 18 | use = egg:{{project}} 19 | full_stack = true 20 | static_files = true 21 | 22 | cache_dir = %(here)s/data 23 | beaker.session.key = {{package}} 24 | beaker.session.secret = ${app_instance_secret} 25 | app_instance_uuid = ${app_instance_uuid} 26 | 27 | # If you'd like to fine-tune the individual locations of the cache data dirs 28 | # for the Cache data, or the Session saves, un-comment the desired settings 29 | # here: 30 | #beaker.cache.data_dir = %(here)s/data/cache 31 | #beaker.session.data_dir = %(here)s/data/sessions 32 | 33 | # WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT* 34 | # Debug mode will enable the interactive debugging tool, allowing ANYONE to 35 | # execute malicious code after an exception is raised. 36 | set debug = false 37 | 38 | 39 | # Logging configuration 40 | [loggers] 41 | keys = root 42 | 43 | [handlers] 44 | keys = console 45 | 46 | [formatters] 47 | keys = generic 48 | 49 | [logger_root] 50 | level = INFO 51 | handlers = console 52 | 53 | [handler_console] 54 | class = StreamHandler 55 | args = (sys.stderr,) 56 | level = NOTSET 57 | formatter = generic 58 | 59 | [formatter_generic] 60 | format = %(asctime)s %(levelname)-5.5s [%(name)s] [%(threadName)s] %(message)s 61 | -------------------------------------------------------------------------------- /pylons/templates/minimal_project/+package+/controllers/__init__.py_tmpl: -------------------------------------------------------------------------------- 1 | """The base Controller API 2 | 3 | Provides the BaseController class for subclassing. 4 | """ 5 | from pylons.controllers import WSGIController 6 | {{if template_engine in ('genshi', 'jinja2', 'mako')}} 7 | from pylons.templating import render_{{template_engine}} as render 8 | {{endif}} 9 | 10 | class BaseController(WSGIController): 11 | 12 | def __call__(self, environ, start_response): 13 | """Invoke the Controller""" 14 | # WSGIController.__call__ dispatches to the Controller method 15 | # the request is routed to. This routing information is 16 | # available in environ['pylons.routes_dict'] 17 | return WSGIController.__call__(self, environ, start_response) 18 | -------------------------------------------------------------------------------- /pylons/templates/minimal_project/+package+/helpers.py_tmpl: -------------------------------------------------------------------------------- 1 | """Helper functions 2 | 3 | Consists of functions to typically be used within templates, but also 4 | available to Controllers. This module is available to templates as 'h'. 5 | """ 6 | # Import helpers as desired, or define your own, ie: 7 | #from webhelpers.html.tags import checkbox, password 8 | -------------------------------------------------------------------------------- /pylons/templates/minimal_project/+package+/public/bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/pylons/templates/minimal_project/+package+/public/bg.png -------------------------------------------------------------------------------- /pylons/templates/minimal_project/+package+/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/pylons/templates/minimal_project/+package+/public/favicon.ico -------------------------------------------------------------------------------- /pylons/templates/minimal_project/+package+/public/pylons-logo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/pylons/templates/minimal_project/+package+/public/pylons-logo.gif -------------------------------------------------------------------------------- /pylons/templates/minimal_project/+package+/routing.py_tmpl: -------------------------------------------------------------------------------- 1 | """Routes configuration 2 | 3 | The more specific and detailed routes should be defined first so they 4 | may take precedent over the more generic routes. For more information 5 | refer to the routes manual at http://routes.groovie.org/docs/ 6 | """ 7 | from routes import Mapper 8 | 9 | def make_map(config): 10 | """Create, configure and return the routes Mapper""" 11 | map = Mapper(directory=config['pylons.paths']['controllers'], 12 | always_scan=config['debug']) 13 | map.minimization = False 14 | map.explicit = False 15 | 16 | # The ErrorController route (handles 404/500 error pages); it should 17 | # likely stay at the top, ensuring it can always be resolved 18 | map.connect('/error/{action}', controller='error') 19 | map.connect('/error/{action}/{id}', controller='error') 20 | 21 | # CUSTOM ROUTES HERE 22 | 23 | map.connect('/{controller}/{action}') 24 | map.connect('/{controller}/{action}/{id}') 25 | 26 | return map 27 | -------------------------------------------------------------------------------- /pylons/templates/minimal_project/+package+/templates/.distutils_placeholder: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/pylons/templates/minimal_project/+package+/templates/.distutils_placeholder -------------------------------------------------------------------------------- /pylons/templates/minimal_project/+package+/templates/__init__.py_tmpl: -------------------------------------------------------------------------------- 1 | {{if template_engine not in ['genshi', 'kid']}} 2 | {{skip_template()}} 3 | {{endif}} 4 | -------------------------------------------------------------------------------- /pylons/templates/minimal_project/+package+/tests/__init__.py_tmpl: -------------------------------------------------------------------------------- 1 | """Pylons application test package 2 | 3 | This package assumes the Pylons environment is already loaded, such as 4 | when this script is imported from the `nosetests --with-pylons=test.ini` 5 | command. 6 | 7 | This module initializes the application via ``websetup`` (`paster 8 | setup-app`) and provides the base testing objects. 9 | """ 10 | from unittest import TestCase 11 | 12 | from paste.deploy import loadapp 13 | from paste.script.appinstall import SetupCommand 14 | from pylons import url 15 | from routes.util import URLGenerator 16 | from webtest import TestApp 17 | 18 | import pylons.test 19 | 20 | __all__ = ['environ', 'url', 'TestController'] 21 | 22 | # Invoke websetup with the current config file 23 | SetupCommand('setup-app').run([pylons.test.pylonsapp.config['__file__']]) 24 | 25 | environ = {} 26 | 27 | class TestController(TestCase): 28 | 29 | def __init__(self, *args, **kwargs): 30 | wsgiapp = pylons.test.pylonsapp 31 | config = wsgiapp.config 32 | self.app = TestApp(wsgiapp) 33 | url._push_object(URLGenerator(config['routes.map'], environ)) 34 | TestCase.__init__(self, *args, **kwargs) 35 | -------------------------------------------------------------------------------- /pylons/templates/minimal_project/MANIFEST.in_tmpl: -------------------------------------------------------------------------------- 1 | include {{package}}/config/deployment.ini_tmpl 2 | recursive-include {{package}}/public * 3 | recursive-include {{package}}/templates * 4 | -------------------------------------------------------------------------------- /pylons/templates/minimal_project/README.txt_tmpl: -------------------------------------------------------------------------------- 1 | This file is for you to describe the {{project}} application. Typically 2 | you would include information such as the information below: 3 | 4 | Installation and Setup 5 | ====================== 6 | 7 | Install ``{{project}}`` using easy_install:: 8 | 9 | easy_install {{project}} 10 | 11 | Make a config file as follows:: 12 | 13 | paster make-config {{project}} config.ini 14 | 15 | Tweak the config file as appropriate and then setup the application:: 16 | 17 | paster setup-app config.ini 18 | 19 | Then you are ready to go. 20 | -------------------------------------------------------------------------------- /pylons/templates/minimal_project/development.ini_tmpl: -------------------------------------------------------------------------------- 1 | # 2 | # {{project}} - Pylons development environment configuration 3 | # 4 | # The %(here)s variable will be replaced with the parent directory of this file 5 | # 6 | [DEFAULT] 7 | debug = true 8 | # Uncomment and replace with the address which should receive any error reports 9 | #email_to = you@yourdomain.com 10 | smtp_server = localhost 11 | error_email_from = paste@localhost 12 | 13 | [server:main] 14 | use = egg:Paste#http 15 | host = 127.0.0.1 16 | port = 5000 17 | 18 | [app:main] 19 | use = egg:{{project}} 20 | full_stack = true 21 | static_files = true 22 | cache_dir = %(here)s/data 23 | beaker.session.key = {{package}} 24 | beaker.session.secret = somesecret 25 | 26 | # If you'd like to fine-tune the individual locations of the cache data dirs 27 | # for the Cache data, or the Session saves, un-comment the desired settings 28 | # here: 29 | #beaker.cache.data_dir = %(here)s/data/cache 30 | #beaker.session.data_dir = %(here)s/data/sessions 31 | 32 | # WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT* 33 | # Debug mode will enable the interactive debugging tool, allowing ANYONE to 34 | # execute malicious code after an exception is raised. 35 | #set debug = false 36 | 37 | 38 | # Logging configuration 39 | [loggers] 40 | keys = root, routes, {{package_logger}} 41 | 42 | [handlers] 43 | keys = console 44 | 45 | [formatters] 46 | keys = generic 47 | 48 | [logger_root] 49 | level = INFO 50 | handlers = console 51 | 52 | [logger_routes] 53 | level = INFO 54 | handlers = 55 | qualname = routes.middleware 56 | # "level = DEBUG" logs the route matched and routing variables. 57 | 58 | [logger_{{package_logger}}] 59 | level = DEBUG 60 | handlers = 61 | qualname = {{package}} 62 | 63 | {{if sqlalchemy}} 64 | 65 | [logger_sqlalchemy] 66 | level = INFO 67 | handlers = 68 | qualname = sqlalchemy.engine 69 | # "level = INFO" logs SQL queries. 70 | # "level = DEBUG" logs SQL queries and results. 71 | # "level = WARN" logs neither. (Recommended for production systems.) 72 | {{endif}} 73 | 74 | [handler_console] 75 | class = StreamHandler 76 | args = (sys.stderr,) 77 | level = NOTSET 78 | formatter = generic 79 | 80 | [formatter_generic] 81 | format = %(asctime)s,%(msecs)03d %(levelname)-5.5s [%(name)s] [%(threadName)s] %(message)s 82 | datefmt = %H:%M:%S 83 | -------------------------------------------------------------------------------- /pylons/templates/minimal_project/setup.cfg_tmpl: -------------------------------------------------------------------------------- 1 | [egg_info] 2 | tag_build = dev 3 | tag_svn_revision = true 4 | 5 | [easy_install] 6 | find_links = http://www.pylonshq.com/download/ 7 | 8 | [nosetests] 9 | with-pylons = test.ini 10 | -------------------------------------------------------------------------------- /pylons/templates/minimal_project/setup.py_tmpl: -------------------------------------------------------------------------------- 1 | try: 2 | from setuptools import setup, find_packages 3 | except ImportError: 4 | from ez_setup import use_setuptools 5 | use_setuptools() 6 | from setuptools import setup, find_packages 7 | 8 | setup( 9 | name='{{project}}', 10 | version='{{version}}', 11 | description={{repr(description)}}, 12 | author={{repr(author)}}, 13 | author_email={{repr(author_email)}}, 14 | url={{repr(url)}}, 15 | install_requires=[ 16 | "Pylons>=1.0.1rc1", 17 | {{if sqlalchemy}} 18 | "SQLAlchemy>=0.5", 19 | {{endif}} 20 | {{if template_engine == 'genshi'}} 21 | "Genshi>=0.4", 22 | {{elif template_engine == 'jinja2'}} 23 | "Jinja2", 24 | {{endif}} 25 | ], 26 | setup_requires=["PasteScript>=1.6.3"], 27 | packages=find_packages(exclude=['ez_setup']), 28 | include_package_data=True, 29 | test_suite='nose.collector', 30 | package_data={'{{package}}': ['i18n/*/LC_MESSAGES/*.mo']}, 31 | #message_extractors={'{{package}}': [ 32 | # ('**.py', 'python', None), 33 | # {{babel_templates_extractor}}('public/**', 'ignore', None)]}, 34 | zip_safe={{zip_safe}}, 35 | paster_plugins={{egg_plugins}}, 36 | entry_points=""" 37 | [paste.app_factory] 38 | main = {{package}}.wsgiapp:make_app 39 | 40 | [paste.app_install] 41 | main = pylons.util:PylonsInstaller 42 | """, 43 | ) 44 | -------------------------------------------------------------------------------- /pylons/templates/minimal_project/test.ini_tmpl: -------------------------------------------------------------------------------- 1 | # 2 | # {{project}} - Pylons testing environment configuration 3 | # 4 | # The %(here)s variable will be replaced with the parent directory of this file 5 | # 6 | [DEFAULT] 7 | debug = true 8 | # Uncomment and replace with the address which should receive any error reports 9 | #email_to = you@yourdomain.com 10 | smtp_server = localhost 11 | error_email_from = paste@localhost 12 | 13 | [server:main] 14 | use = egg:Paste#http 15 | host = 127.0.0.1 16 | port = 5000 17 | 18 | [app:main] 19 | use = config:development.ini 20 | 21 | # Add additional test specific configuration options as necessary. 22 | -------------------------------------------------------------------------------- /pylons/templates/restcontroller.py_tmpl: -------------------------------------------------------------------------------- 1 | import logging 2 | 3 | from pylons import request, response, session, tmpl_context as c, url 4 | from pylons.controllers.util import abort, redirect 5 | 6 | {{importstatement}} 7 | 8 | log = logging.getLogger(__name__) 9 | 10 | class {{classname}}Controller(BaseController): 11 | """REST Controller styled on the Atom Publishing Protocol""" 12 | # To properly map this controller, ensure your config/routing.py 13 | # file has a resource setup: 14 | # {{resource_command}} 15 | def index(self, format='html'): 16 | """GET /{{path}}{{pluralname}}: All items in the collection""" 17 | # url('{{nameprefix}}{{pluralname}}') 18 | 19 | def create(self): 20 | """POST /{{path}}{{pluralname}}: Create a new item""" 21 | # url('{{nameprefix}}{{pluralname}}') 22 | 23 | def new(self, format='html'): 24 | """GET /{{path}}{{pluralname}}/new: Form to create a new item""" 25 | # url('{{nameprefix}}new_{{singularname}}') 26 | 27 | def update(self, id): 28 | """PUT /{{path}}{{pluralname}}/id: Update an existing item""" 29 | # Forms posted to this method should contain a hidden field: 30 | # 31 | # Or using helpers: 32 | # h.form(url('{{nameprefix}}{{singularname}}', id=ID), 33 | # method='put') 34 | # url('{{nameprefix}}{{singularname}}', id=ID) 35 | 36 | def delete(self, id): 37 | """DELETE /{{path}}{{pluralname}}/id: Delete an existing item""" 38 | # Forms posted to this method should contain a hidden field: 39 | # 40 | # Or using helpers: 41 | # h.form(url('{{nameprefix}}{{singularname}}', id=ID), 42 | # method='delete') 43 | # url('{{nameprefix}}{{singularname}}', id=ID) 44 | 45 | def show(self, id, format='html'): 46 | """GET /{{path}}{{pluralname}}/id: Show a specific item""" 47 | # url('{{nameprefix}}{{singularname}}', id=ID) 48 | 49 | def edit(self, id, format='html'): 50 | """GET /{{path}}{{pluralname}}/id/edit: Form to edit an existing item""" 51 | # url('{{nameprefix}}edit_{{singularname}}', id=ID) 52 | -------------------------------------------------------------------------------- /pylons/templates/test_controller.py_tmpl: -------------------------------------------------------------------------------- 1 | from {{base_package}}.tests import * 2 | 3 | class Test{{name}}Controller(TestController): 4 | 5 | def test_index(self): 6 | response = self.app.get(url(controller='{{fname}}', action='index')) 7 | # Test response... 8 | -------------------------------------------------------------------------------- /pylons/templates/test_restcontroller.py_tmpl: -------------------------------------------------------------------------------- 1 | from {{base_package}}.tests import * 2 | 3 | class Test{{name}}Controller(TestController): 4 | 5 | def test_index(self): 6 | response = self.app.get(url('{{nameprefix}}{{pluralname}}')) 7 | # Test response... 8 | 9 | def test_index_as_xml(self): 10 | response = self.app.get(url('formatted_{{nameprefix}}{{pluralname}}', format='xml')) 11 | 12 | def test_create(self): 13 | response = self.app.post(url('{{nameprefix}}{{pluralname}}')) 14 | 15 | def test_new(self): 16 | response = self.app.get(url('{{nameprefix}}new_{{singularname}}')) 17 | 18 | def test_new_as_xml(self): 19 | response = self.app.get(url('formatted_{{nameprefix}}new_{{singularname}}', format='xml')) 20 | 21 | def test_update(self): 22 | response = self.app.put(url('{{nameprefix}}{{singularname}}', id=1)) 23 | 24 | def test_update_browser_fakeout(self): 25 | response = self.app.post(url('{{nameprefix}}{{singularname}}', id=1), params=dict(_method='put')) 26 | 27 | def test_delete(self): 28 | response = self.app.delete(url('{{nameprefix}}{{singularname}}', id=1)) 29 | 30 | def test_delete_browser_fakeout(self): 31 | response = self.app.post(url('{{nameprefix}}{{singularname}}', id=1), params=dict(_method='delete')) 32 | 33 | def test_show(self): 34 | response = self.app.get(url('{{nameprefix}}{{singularname}}', id=1)) 35 | 36 | def test_show_as_xml(self): 37 | response = self.app.get(url('formatted_{{nameprefix}}{{singularname}}', id=1, format='xml')) 38 | 39 | def test_edit(self): 40 | response = self.app.get(url('{{nameprefix}}edit_{{singularname}}', id=1)) 41 | 42 | def test_edit_as_xml(self): 43 | response = self.app.get(url('formatted_{{nameprefix}}edit_{{singularname}}', id=1, format='xml')) 44 | -------------------------------------------------------------------------------- /pylons/test.py: -------------------------------------------------------------------------------- 1 | """Test related functionality 2 | 3 | Adds a Pylons plugin to `nose 4 | `_ that loads 5 | the Pylons app *before* scanning for doc tests. 6 | 7 | This can be configured in the projects :file:`setup.cfg` under a 8 | ``[nosetests]`` block: 9 | 10 | .. code-block:: ini 11 | 12 | [nosetests] 13 | with-pylons=development.ini 14 | 15 | Alternate ini files may be specified if the app should be loaded using 16 | a different configuration. 17 | 18 | """ 19 | import os 20 | import sys 21 | 22 | import nose.plugins 23 | import pkg_resources 24 | from paste.deploy import loadapp 25 | 26 | import pylons 27 | from pylons.i18n.translation import _get_translator 28 | 29 | pylonsapp = None 30 | 31 | 32 | class PylonsPlugin(nose.plugins.Plugin): 33 | """Nose plugin extension 34 | 35 | For use with nose to allow a project to be configured before nose 36 | proceeds to scan the project for doc tests and unit tests. This 37 | prevents modules from being loaded without a configured Pylons 38 | environment. 39 | 40 | """ 41 | enabled = False 42 | enableOpt = 'pylons_config' 43 | name = 'pylons' 44 | 45 | def options(self, parser, env=os.environ): 46 | """Add command-line options for this plugin""" 47 | env_opt = 'NOSE_WITH_%s' % self.name.upper() 48 | env_opt.replace('-', '_') 49 | 50 | parser.add_option("--with-%s" % self.name, 51 | dest=self.enableOpt, type="string", 52 | default="", 53 | help="Setup Pylons environment with the config file" 54 | " specified by ATTR [NOSE_ATTR]") 55 | 56 | def configure(self, options, conf): 57 | """Configure the plugin""" 58 | self.config_file = None 59 | self.conf = conf 60 | if hasattr(options, self.enableOpt): 61 | self.enabled = bool(getattr(options, self.enableOpt)) 62 | self.config_file = getattr(options, self.enableOpt) 63 | 64 | def begin(self): 65 | """Called before any tests are collected or run 66 | 67 | Loads the application, and in turn its configuration. 68 | 69 | """ 70 | global pylonsapp 71 | path = os.getcwd() 72 | sys.path.insert(0, path) 73 | pkg_resources.working_set.add_entry(path) 74 | self.app = pylonsapp = loadapp('config:' + self.config_file, 75 | relative_to=path) 76 | 77 | # Setup the config and app_globals, only works if we can get 78 | # to the config object 79 | conf = getattr(pylonsapp, 'config') 80 | if conf: 81 | pylons.config._push_object(conf) 82 | 83 | if 'pylons.app_globals' in conf: 84 | pylons.app_globals._push_object(conf['pylons.app_globals']) 85 | 86 | # Initialize a translator for tests that utilize i18n 87 | translator = _get_translator(pylons.config.get('lang')) 88 | pylons.translator._push_object(translator) 89 | -------------------------------------------------------------------------------- /pylons/testutil.py: -------------------------------------------------------------------------------- 1 | """Utility classes for creating workable pylons controllers for unit 2 | testing. 3 | 4 | These classes are used solely by Pylons for unit testing controller 5 | functionality. 6 | 7 | """ 8 | import gettext 9 | 10 | import pylons 11 | from pylons.configuration import request_defaults, response_defaults 12 | from pylons.controllers.util import Request, Response 13 | from pylons.util import ContextObj, PylonsContext 14 | 15 | 16 | class ControllerWrap(object): 17 | def __init__(self, controller): 18 | self.controller = controller 19 | 20 | def __call__(self, environ, start_response): 21 | app = self.controller() 22 | app.start_response = None 23 | return app(environ, start_response) 24 | 25 | 26 | class SetupCacheGlobal(object): 27 | def __init__(self, app, environ, setup_g=True, setup_cache=False, 28 | setup_session=False): 29 | if setup_g: 30 | g = type('G object', (object,), {}) 31 | g.message = 'Hello' 32 | g.counter = 0 33 | g.pylons_config = type('App conf', (object,), {}) 34 | g.pylons_config.app_conf = dict(cache_enabled='True') 35 | self.g = g 36 | self.app = app 37 | self.environ = environ 38 | self.setup_cache = setup_cache 39 | self.setup_session = setup_session 40 | self.setup_g = setup_g 41 | 42 | def __call__(self, environ, start_response): 43 | registry = environ['paste.registry'] 44 | py_obj = PylonsContext() 45 | environ_config = environ.setdefault('pylons.environ_config', {}) 46 | if self.setup_cache: 47 | py_obj.cache = environ['beaker.cache'] 48 | registry.register(pylons.cache, environ['beaker.cache']) 49 | environ_config['cache'] = 'beaker.cache' 50 | if self.setup_session: 51 | py_obj.session = environ['beaker.session'] 52 | registry.register(pylons.session, environ['beaker.session']) 53 | environ_config['session'] = 'beaker.session' 54 | if self.setup_g: 55 | py_obj.app_globals = self.g 56 | registry.register(pylons.app_globals, self.g) 57 | translator = gettext.NullTranslations() 58 | py_obj.translator = translator 59 | registry.register(pylons.translator, translator) 60 | 61 | # Update the environ 62 | req = Request(environ, charset=request_defaults['charset'], 63 | unicode_errors=request_defaults['errors'], 64 | decode_param_names=request_defaults['decode_param_names'] 65 | ) 66 | req.language = request_defaults['language'] 67 | 68 | response = Response( 69 | content_type=response_defaults['content_type'], 70 | charset=response_defaults['charset']) 71 | response.headers.update(response_defaults['headers']) 72 | 73 | environ.update(self.environ) 74 | py_obj.config = pylons.config._current_obj() 75 | py_obj.request = req 76 | py_obj.response = response 77 | py_obj.tmpl_context = ContextObj() 78 | environ['pylons.pylons'] = py_obj 79 | registry.register(pylons.request, req) 80 | registry.register(pylons.response, response) 81 | if 'routes.url' in environ: 82 | registry.register(pylons.url, environ['routes.url']) 83 | return self.app(environ, start_response) 84 | -------------------------------------------------------------------------------- /pylons/url.py: -------------------------------------------------------------------------------- 1 | from repoze.bfg.encode import urlencode 2 | from repoze.bfg.threadlocal import get_current_registry 3 | from repoze.bfg.url import _join_elements 4 | 5 | from pylons.interfaces import IRoutesMapper 6 | 7 | 8 | def route_url(route_name, request, *elements, **kw): 9 | try: 10 | reg = request.registry 11 | except AttributeError: 12 | reg = get_current_registry() # b/c 13 | mapper = reg.getUtility(IRoutesMapper) 14 | 15 | route = mapper.routes.get(route_name) 16 | if route and 'custom_url_generator' in route.__dict__: 17 | route_name, request, elements, kw = route.custom_url_generator( 18 | route_name, request, *elements, **kw) 19 | anchor = '' 20 | qs = '' 21 | app_url = None 22 | 23 | if '_query' in kw: 24 | qs = '?' + urlencode(kw.pop('_query'), doseq=True) 25 | 26 | if '_anchor' in kw: 27 | anchor = kw.pop('_anchor') 28 | if isinstance(anchor, unicode): 29 | anchor = anchor.encode('utf-8') 30 | anchor = '#' + anchor 31 | 32 | if '_app_url' in kw: 33 | app_url = kw.pop('_app_url') 34 | 35 | path = mapper.generate(route_name, kw) # raises KeyError if generate fails 36 | 37 | if elements: 38 | suffix = _join_elements(elements) 39 | if not path.endswith('/'): 40 | suffix = '/' + suffix 41 | else: 42 | suffix = '' 43 | 44 | if app_url is None: 45 | # we only defer lookup of application_url until here because 46 | # it's somewhat expensive; we won't need to do it if we've 47 | # been passed _app_url 48 | app_url = request.application_url 49 | 50 | return app_url + path + suffix + qs + anchor 51 | -------------------------------------------------------------------------------- /rtd.txt: -------------------------------------------------------------------------------- 1 | repoze.sphinx.autointerface 2 | babel 3 | -------------------------------------------------------------------------------- /scripts/gen-go-pylons.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """Generate go-pylons.py""" 3 | import sys 4 | import textwrap 5 | import virtualenv 6 | 7 | filename = 'go-pylons.py' 8 | 9 | after_install = """\ 10 | import os, subprocess 11 | def after_install(options, home_dir): 12 | etc = join(home_dir, 'etc') 13 | ## TODO: this should all come from distutils 14 | ## like distutils.sysconfig.get_python_inc() 15 | if sys.platform == 'win32': 16 | lib_dir = join(home_dir, 'Lib') 17 | bin_dir = join(home_dir, 'Scripts') 18 | elif is_jython: 19 | lib_dir = join(home_dir, 'Lib') 20 | bin_dir = join(home_dir, 'bin') 21 | else: 22 | lib_dir = join(home_dir, 'lib', py_version) 23 | bin_dir = join(home_dir, 'bin') 24 | 25 | if not os.path.exists(etc): 26 | os.makedirs(etc) 27 | subprocess.call([join(bin_dir, 'easy_install'), 28 | '-f', 'http://pylonshq.com/download/%s', 'Pylons==%s']) 29 | """ 30 | 31 | 32 | def generate(filename, version): 33 | path = version 34 | if '==' in version: 35 | path = version[:version.find('==')] 36 | output = virtualenv.create_bootstrap_script( 37 | textwrap.dedent(after_install % (path, version))) 38 | fp = open(filename, 'w') 39 | fp.write(output) 40 | fp.close() 41 | 42 | 43 | def main(): 44 | if len(sys.argv) != 2: 45 | print >> sys.stderr, 'usage: %s version' % sys.argv[0] 46 | sys.exit(1) 47 | generate(filename, sys.argv[1]) 48 | 49 | 50 | if __name__ == '__main__': 51 | main() 52 | -------------------------------------------------------------------------------- /setup.cfg: -------------------------------------------------------------------------------- 1 | [egg_info] 2 | tag_build = dev 3 | tag_date = true 4 | 5 | [bdist_wheel] 6 | universal = 1 7 | 8 | [nosetests] 9 | # constrain nosetests to the tests dir for now: 0.10 ends up 10 | # overwriting pylons.config with the actual module 11 | where=tests 12 | cover-package=pylons 13 | cover-erase=True 14 | with-doctest=True 15 | nocapture=1 16 | -------------------------------------------------------------------------------- /test_files/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/test_files/__init__.py -------------------------------------------------------------------------------- /test_files/event_file.py: -------------------------------------------------------------------------------- 1 | from pylons.events import NewRequest, NewResponse, subscriber 2 | 3 | 4 | @subscriber(NewRequest) 5 | def add_reggy(event): 6 | event.request.reg = True 7 | 8 | @subscriber(NewResponse) 9 | def add_respy(event): 10 | event.response.reg = True 11 | -------------------------------------------------------------------------------- /test_files/sample_controllers/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | -------------------------------------------------------------------------------- /test_files/sample_controllers/controllers/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | -------------------------------------------------------------------------------- /test_files/sample_controllers/controllers/goodbye.py: -------------------------------------------------------------------------------- 1 | import logging 2 | 3 | from pylons import request, response, session, tmpl_context as c, url 4 | from pylons.controllers import WSGIController 5 | from pylons.controllers.util import abort, redirect 6 | from webob import Response 7 | from webob.exc import HTTPNotFound 8 | 9 | log = logging.getLogger(__name__) 10 | 11 | class Smithy(WSGIController): 12 | def __init__(self): 13 | self._pylons_log_debug = True 14 | 15 | def index(self): 16 | return 'Hello World' 17 | 18 | __controller__ = 'Smithy' 19 | -------------------------------------------------------------------------------- /test_files/sample_controllers/controllers/hello.py: -------------------------------------------------------------------------------- 1 | import logging 2 | 3 | from pylons import request, response, session, tmpl_context as c, url 4 | from pylons.controllers import WSGIController 5 | from pylons.controllers.util import abort, redirect 6 | from pylons.templating import render_mako 7 | from webob import Response 8 | from webob.exc import HTTPNotFound 9 | 10 | log = logging.getLogger(__name__) 11 | 12 | class HelloController(WSGIController): 13 | def __init__(self): 14 | self._pylons_log_debug = True 15 | 16 | def index(self): 17 | return 'Hello World' 18 | 19 | def oops(self): 20 | raise Exception('oops') 21 | 22 | def abort(self): 23 | abort(404) 24 | 25 | def intro_template(self): 26 | return render_mako('/hello.html') 27 | 28 | def time_template(self): 29 | return render_mako('/time.html', cache_key='fred', cache_expire=20) 30 | 31 | 32 | def special_controller(environ, start_response): 33 | return HTTPNotFound() 34 | 35 | def empty_wsgi(environ, start_response): 36 | return 37 | 38 | def a_view(request): 39 | return Response('A View') 40 | -------------------------------------------------------------------------------- /test_files/sample_controllers/controllers/i18nc.py: -------------------------------------------------------------------------------- 1 | import datetime 2 | 3 | from pylons import request, response, session, url 4 | from pylons import tmpl_context as c 5 | from pylons import app_globals 6 | from pylons.i18n import _, get_lang, set_lang, LanguageError 7 | from pylons.controllers import WSGIController 8 | from pylons.controllers.util import abort, redirect 9 | 10 | class I18NcController(WSGIController): 11 | def set_lang(self): 12 | return self._set_lang(_) 13 | 14 | def set_lang_pylonscontext(self, pylons): 15 | return self._set_lang(lambda *args: pylons.translator.ugettext(*args)) 16 | 17 | def _set_lang(self, gettext): 18 | lang = request.GET['lang'] 19 | try: 20 | set_lang(lang) 21 | except (LanguageError, IOError), e: 22 | resp_unicode = gettext('Could not set language to "%(lang)s"') % {'lang': lang} 23 | else: 24 | session['lang'] = lang 25 | session.save() 26 | resp_unicode = gettext('Set language to "%(lang)s"') % {'lang': lang} 27 | return resp_unicode 28 | 29 | def i18n_index(self): 30 | obj = request._current_obj() 31 | locale_list = request.languages 32 | set_lang(request.languages) 33 | return unicode(_('basic index page')) 34 | 35 | def no_lang(self): 36 | set_lang(None) 37 | response.write(_('No language')) 38 | set_lang([]) 39 | response.write(_('No languages')) 40 | return '' 41 | 42 | def langs(self): 43 | locale_list = request.languages 44 | set_lang(request.languages) 45 | return str(get_lang()) 46 | -------------------------------------------------------------------------------- /test_files/sample_controllers/i18n/es/LC_MESSAGES/sample_controllers.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/test_files/sample_controllers/i18n/es/LC_MESSAGES/sample_controllers.mo -------------------------------------------------------------------------------- /test_files/sample_controllers/i18n/es/LC_MESSAGES/sample_controllers.po: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | msgid "" 3 | msgstr "" 4 | "Project-Id-Version: PROJECT VERSION\n" 5 | "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" 6 | "POT-Creation-Date: 2010-06-25 18:12-0700\n" 7 | "PO-Revision-Date: 2010-06-25 18:12-0700\n" 8 | "Last-Translator: FULL NAME \n" 9 | "Language-Team: es \n" 10 | "Plural-Forms: nplurals=2; plural=(n != 1)\n" 11 | "MIME-Version: 1.0\n" 12 | "Content-Type: text/plain; charset=utf-8\n" 13 | "Content-Transfer-Encoding: 8bit\n" 14 | "Generated-By: Babel 0.9.4\n" 15 | 16 | msgid "Hello" 17 | msgstr "¡Hola!" 18 | -------------------------------------------------------------------------------- /test_files/sample_controllers/i18n/fr/LC_MESSAGES/sample_controllers.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/test_files/sample_controllers/i18n/fr/LC_MESSAGES/sample_controllers.mo -------------------------------------------------------------------------------- /test_files/sample_controllers/i18n/fr/LC_MESSAGES/sample_controllers.po: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | msgid "" 3 | msgstr "" 4 | "Project-Id-Version: PROJECT VERSION\n" 5 | "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" 6 | "POT-Creation-Date: 2010-06-25 18:12-0700\n" 7 | "PO-Revision-Date: 2010-06-25 18:12-0700\n" 8 | "Last-Translator: FULL NAME \n" 9 | "Language-Team: fr \n" 10 | "Plural-Forms: nplurals=2; plural=(n > 1)\n" 11 | "MIME-Version: 1.0\n" 12 | "Content-Type: text/plain; charset=utf-8\n" 13 | "Content-Transfer-Encoding: 8bit\n" 14 | "Generated-By: Babel 0.9.4\n" 15 | 16 | msgid "Hello" 17 | msgstr "Bonjour" 18 | -------------------------------------------------------------------------------- /test_files/sample_controllers/i18n/ja/LC_MESSAGES/sample_controllers.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/test_files/sample_controllers/i18n/ja/LC_MESSAGES/sample_controllers.mo -------------------------------------------------------------------------------- /test_files/sample_controllers/i18n/ja/LC_MESSAGES/sample_controllers.po: -------------------------------------------------------------------------------- 1 | # SOME DESCRIPTIVE TITLE. 2 | # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER 3 | # This file is distributed under the same license as the PACKAGE package. 4 | # FIRST AUTHOR , YEAR. 5 | # 6 | #, fuzzy 7 | msgid "" 8 | msgstr "" 9 | "Project-Id-Version: PACKAGE VERSION\n" 10 | "Report-Msgid-Bugs-To: \n" 11 | "POT-Creation-Date: 2007-02-05 12:36+0900\n" 12 | "PO-Revision-Date: 2007-02-05 13:06+0900\n" 13 | "Last-Translator: FULL NAME \n" 14 | "Language-Team: LANGUAGE \n" 15 | "MIME-Version: 1.0\n" 16 | "Content-Type: text/plain; charset=utf-8\n" 17 | "Content-Transfer-Encoding: 8bit\n" 18 | 19 | #: controller_sample.py:7 20 | msgid "basic index page" 21 | msgstr "根本インデクスページ" 22 | 23 | #: controller_sample.py:59 24 | #, python-format 25 | msgid "Could not set language to \"%(lang)s\"" 26 | msgstr "「%(lang)s」に言語設定が変更できません" 27 | 28 | #: controller_sample.py:63 29 | #, python-format 30 | msgid "Set language to \"%(lang)s\"" 31 | msgstr "言語設定を「%(lang)s」に変更しました" -------------------------------------------------------------------------------- /test_files/sample_controllers/templates/hello.html: -------------------------------------------------------------------------------- 1 | Hi there ${4 + 2} 2 | -------------------------------------------------------------------------------- /test_files/sample_controllers/templates/time.html: -------------------------------------------------------------------------------- 1 | <%! 2 | from datetime import datetime 3 | %> 4 | Hello, the time is ${datetime.now()} 5 | -------------------------------------------------------------------------------- /tests/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | -------------------------------------------------------------------------------- /tests/conftest.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import os 3 | import shutil 4 | import pkg_resources 5 | 6 | here = os.path.dirname(__file__) 7 | base = os.path.dirname(here) 8 | sys.path.append(here) 9 | sys.path.insert(0, base) 10 | 11 | here = os.path.dirname(__file__) 12 | 13 | pkg_resources.working_set.add_entry(base) 14 | 15 | if not os.environ.get('PASTE_TESTING'): 16 | output_dir = os.path.join(here, 'test_webapps', 'output') 17 | if os.path.exists(output_dir): 18 | shutil.rmtree(output_dir) 19 | 20 | -------------------------------------------------------------------------------- /tests/test_units/__init__.py: -------------------------------------------------------------------------------- 1 | import json 2 | import os 3 | import sys 4 | from unittest import TestCase 5 | from urllib import quote_plus 6 | from xmlrpclib import loads, dumps 7 | 8 | data_dir = os.path.dirname(os.path.abspath(__file__)) 9 | 10 | try: 11 | shutil.rmtree(data_dir) 12 | except: 13 | pass 14 | 15 | cur_dir = os.path.dirname(os.path.abspath(__file__)) 16 | pylons_root = os.path.dirname(os.path.dirname(cur_dir)) 17 | test_root = os.path.join(pylons_root, 'test_files') 18 | 19 | sys.path.append(test_root) 20 | 21 | class TestMiddleware(object): 22 | def __init__(self, app): 23 | self.app = app 24 | 25 | def __call__(self, environ, start_response): 26 | if 'paste.testing_variables' not in environ: 27 | environ['paste.testing_variables'] = {} 28 | testenv = environ['paste.testing_variables'] 29 | testenv['environ'] = environ 30 | return self.app(environ, start_response) 31 | 32 | 33 | class TestWSGIController(TestCase): 34 | def setUp(self): 35 | import pylons 36 | from pylons.util import ContextObj, PylonsContext 37 | 38 | c = ContextObj() 39 | py_obj = PylonsContext() 40 | py_obj.tmpl_context = c 41 | py_obj.request = py_obj.response = None 42 | self.environ = {'pylons.routes_dict':dict(action='index'), 43 | 'paste.config':dict(global_conf=dict(debug=True)), 44 | 'pylons.pylons':py_obj} 45 | pylons.tmpl_context._push_object(c) 46 | 47 | def tearDown(self): 48 | import pylons 49 | pylons.tmpl_context._pop_object() 50 | 51 | def get_response(self, **kargs): 52 | test_args = kargs.pop('test_args', {}) 53 | url = kargs.pop('_url', '/') 54 | self.environ['pylons.routes_dict'].update(kargs) 55 | return self.app.get(url, extra_environ=self.environ, **test_args) 56 | 57 | def post_response(self, **kargs): 58 | url = kargs.pop('_url', '/') 59 | self.environ['pylons.routes_dict'].update(kargs) 60 | return self.app.post(url, extra_environ=self.environ, params=kargs) 61 | 62 | def xmlreq(self, method, args=None): 63 | if args is None: 64 | args = () 65 | ee = dict(CONTENT_TYPE='text/xml') 66 | data = dumps(args, methodname=method) 67 | self.response = response = self.app.post('/', params = data, 68 | extra_environ=ee) 69 | return loads(response.body)[0][0] 70 | 71 | def jsonreq(self, method, args=()): 72 | assert(isinstance(args, list) or 73 | isinstance(args, tuple) or 74 | isinstance(args, dict)) 75 | 76 | ee = dict(CONTENT_TYPE='application/json') 77 | data = json.dumps(dict(id='test', 78 | method=method, 79 | params=args)) 80 | self.response = response = self.app.post('/', params=quote_plus(data), 81 | extra_environ=ee) 82 | return json.loads(response.body) 83 | 84 | -------------------------------------------------------------------------------- /tests/test_units/test_decorator_authenticate_form.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import logging 3 | import logging.handlers 4 | import os 5 | 6 | from beaker.middleware import SessionMiddleware 7 | from paste.fixture import TestApp 8 | from paste.registry import RegistryManager 9 | from routes import request_config 10 | 11 | from __init__ import data_dir, TestWSGIController 12 | 13 | session_dir = os.path.join(data_dir, 'session') 14 | 15 | try: 16 | import shutil 17 | shutil.rmtree(session_dir) 18 | except: 19 | pass 20 | 21 | 22 | # Eat the logging handler messages 23 | my_logger = logging.getLogger() 24 | my_logger.setLevel(logging.INFO) 25 | # Add the log message handler to the logger 26 | class NullHandler(logging.Handler): 27 | def emit(self, record): 28 | pass 29 | my_logger.addHandler(NullHandler()) 30 | 31 | 32 | def make_protected(): 33 | from pylons.controllers import WSGIController 34 | from pylons.decorators.secure import authenticate_form 35 | from webhelpers.pylonslib import secure_form 36 | from pylons import request 37 | 38 | class ProtectedController(WSGIController): 39 | def form(self): 40 | request_config().environ = request.environ 41 | return secure_form.authentication_token() 42 | 43 | @authenticate_form 44 | def protected(self): 45 | request_config().environ = request.environ 46 | return 'Authenticated' 47 | return ProtectedController 48 | 49 | 50 | class TestAuthenticateFormDecorator(TestWSGIController): 51 | def setUp(self): 52 | from pylons.testutil import ControllerWrap, SetupCacheGlobal 53 | ProtectedController = make_protected() 54 | TestWSGIController.setUp(self) 55 | app = ControllerWrap(ProtectedController) 56 | app = SetupCacheGlobal(app, self.environ, setup_session=True) 57 | app = SessionMiddleware(app, {}, data_dir=session_dir) 58 | app = RegistryManager(app) 59 | self.app = TestApp(app) 60 | 61 | def test_unauthenticated(self): 62 | from pylons.decorators.secure import csrf_detected_message 63 | 64 | self.environ['pylons.routes_dict']['action'] = 'protected' 65 | response = self.app.post('/protected', extra_environ=self.environ, 66 | expect_errors=True) 67 | assert response.status == 403 68 | assert csrf_detected_message in response 69 | 70 | def test_authenticated(self): 71 | from webhelpers.pylonslib import secure_form 72 | 73 | self.environ['pylons.routes_dict']['action'] = 'form' 74 | response = self.app.get('/form', extra_environ=self.environ) 75 | token = response.body 76 | 77 | self.environ['pylons.routes_dict']['action'] = 'protected' 78 | response = self.app.post('/protected', 79 | params={secure_form.token_key: token}, 80 | extra_environ=self.environ, 81 | expect_errors=True) 82 | assert 'Authenticated' in response 83 | 84 | self.environ['pylons.routes_dict']['action'] = 'protected' 85 | response = self.app.put('/protected', 86 | params={secure_form.token_key: token}, 87 | extra_environ=self.environ, 88 | expect_errors=True) 89 | assert 'Authenticated' in response 90 | 91 | # GET with token_key in query string 92 | response = self.app.get('/protected', 93 | params={secure_form.token_key: token}, 94 | extra_environ=self.environ, 95 | expect_errors=True) 96 | assert 'Authenticated' in response 97 | 98 | # POST with token_key in query string 99 | response = self.app.post('/protected?' + secure_form.token_key + '=' + token, 100 | extra_environ=self.environ, 101 | expect_errors=True) 102 | assert 'Authenticated' in response 103 | -------------------------------------------------------------------------------- /tests/test_units/test_decorator_https.py: -------------------------------------------------------------------------------- 1 | from paste.fixture import TestApp 2 | from paste.registry import RegistryManager 3 | 4 | from routes.middleware import RoutesMiddleware 5 | 6 | from __init__ import TestWSGIController 7 | 8 | def make_httpscontroller(): 9 | from pylons import request, url 10 | from pylons.controllers import WSGIController 11 | from pylons.decorators.secure import https 12 | 13 | class HttpsController(WSGIController): 14 | 15 | @https('/pylons') 16 | def index(self): 17 | return 'index page' 18 | 19 | @https(lambda: url(controller='auth', action='login')) 20 | def login2(self): 21 | return 'login2 page' 22 | 23 | @https(lambda: request.url) 24 | def secure(self): 25 | return 'secure page' 26 | 27 | @https() 28 | def get(self): 29 | return 'get page' 30 | return HttpsController 31 | 32 | class TestHttpsDecorator(TestWSGIController): 33 | def setUp(self): 34 | from pylons.testutil import ControllerWrap, SetupCacheGlobal 35 | HttpsController = make_httpscontroller() 36 | TestWSGIController.setUp(self) 37 | from routes import Mapper 38 | map = Mapper() 39 | map.connect('/:action') 40 | map.connect('/:action/:id') 41 | map.connect('/:controller/:action/:id') 42 | map.connect('/:controller/:action') 43 | app = ControllerWrap(HttpsController) 44 | app = SetupCacheGlobal(app, self.environ, setup_cache=False) 45 | app = RoutesMiddleware(app, map) 46 | app = RegistryManager(app) 47 | self.app = TestApp(app) 48 | 49 | def test_https_explicit_path(self): 50 | self.environ['pylons.routes_dict']['action'] = 'index' 51 | 52 | response = self.app.get('/index', status=302) 53 | assert response.header_dict.get('location') == \ 54 | 'https://localhost/pylons' 55 | 56 | self.environ['wsgi.url_scheme'] = 'https' 57 | response = self.app.get('/index', status=200) 58 | assert 'location' not in response.header_dict 59 | assert 'index page' in response 60 | 61 | def test_https_disallows_post(self): 62 | self.environ['pylons.routes_dict']['action'] = 'index' 63 | response = self.app.post('/index', status=405) 64 | 65 | def test_https_callable(self): 66 | self.environ['pylons.routes_dict']['action'] = 'login2' 67 | 68 | response = self.app.get('/login2', status=302) 69 | assert response.header_dict.get('location') == \ 70 | 'https://localhost/auth/login' 71 | 72 | self.environ['wsgi.url_scheme'] = 'https' 73 | response = self.app.get('/login2', status=200) 74 | assert 'location' not in response.header_dict 75 | assert 'login2 page' in response 76 | 77 | def test_https_callable_current(self): 78 | self.environ['pylons.routes_dict']['action'] = 'secure' 79 | 80 | response = self.app.get('/secure', status=302) 81 | assert response.header_dict.get('location') == \ 82 | 'https://localhost/secure' 83 | 84 | self.environ['wsgi.url_scheme'] = 'https' 85 | response = self.app.get('/secure', status=200) 86 | assert 'location' not in response.header_dict 87 | assert 'secure page' in response 88 | 89 | def test_https_redirect_to_self(self): 90 | self.environ['pylons.routes_dict']['action'] = 'get' 91 | 92 | response = self.app.get('/get', status=302) 93 | assert response.header_dict.get('location') == \ 94 | 'https://localhost/get' 95 | 96 | self.environ['wsgi.url_scheme'] = 'https' 97 | response = self.app.get('/get', status=200) 98 | assert 'location' not in response.header_dict 99 | assert 'get page' in response 100 | -------------------------------------------------------------------------------- /tests/test_units/test_decorator_jsonify.py: -------------------------------------------------------------------------------- 1 | import warnings 2 | 3 | from paste.fixture import TestApp 4 | from paste.registry import RegistryManager 5 | 6 | from __init__ import TestWSGIController 7 | 8 | def make_cache_controller_app(): 9 | from pylons.testutil import ControllerWrap, SetupCacheGlobal 10 | from pylons.decorators import jsonify 11 | from pylons.controllers import WSGIController 12 | 13 | class CacheController(WSGIController): 14 | 15 | @jsonify 16 | def test_bad_json(self): 17 | return ["this is neat"] 18 | 19 | @jsonify 20 | def test_bad_json2(self): 21 | return ("this is neat",) 22 | 23 | @jsonify 24 | def test_good_json(self): 25 | return dict(fred=42) 26 | 27 | environ = {} 28 | app = ControllerWrap(CacheController) 29 | app = sap = SetupCacheGlobal(app, environ) 30 | app = RegistryManager(app) 31 | app = TestApp(app) 32 | return app, environ 33 | 34 | 35 | class TestJsonifyDecorator(TestWSGIController): 36 | def setUp(self): 37 | self.app, environ = make_cache_controller_app() 38 | TestWSGIController.setUp(self) 39 | environ.update(self.environ) 40 | warnings.simplefilter('error', Warning) 41 | 42 | def tearDown(self): 43 | warnings.simplefilter('always', Warning) 44 | 45 | def test_bad_json(self): 46 | for action in 'test_bad_json', 'test_bad_json2': 47 | try: 48 | response = self.get_response(action=action) 49 | except Warning, msg: 50 | assert 'JSON responses with Array envelopes are' in msg[0] 51 | 52 | def test_good_json(self): 53 | response = self.get_response(action='test_good_json') 54 | assert '{"fred": 42}' in response 55 | assert response.header('Content-Type') == 'application/json; charset=utf-8' 56 | -------------------------------------------------------------------------------- /tests/test_units/test_helpers.py: -------------------------------------------------------------------------------- 1 | import warnings 2 | from unittest import TestCase 3 | 4 | from paste.fixture import TestApp 5 | from paste.httpexceptions import HTTPMovedPermanently 6 | from paste.registry import RegistryManager 7 | 8 | from __init__ import TestWSGIController 9 | 10 | 11 | def make_helperscontroller(): 12 | import pylons 13 | from pylons.controllers import WSGIController 14 | from pylons.controllers.util import etag_cache 15 | 16 | class HelpersController(WSGIController): 17 | 18 | def test_etag_cache(self): 19 | etag_cache('test') 20 | return "from etag_cache" 21 | return HelpersController 22 | 23 | class TestHelpers(TestWSGIController): 24 | def __init__(self, *args, **kargs): 25 | from pylons.testutil import ControllerWrap, SetupCacheGlobal 26 | HelpersController = make_helperscontroller() 27 | TestWSGIController.__init__(self, *args, **kargs) 28 | self.baseenviron = {} 29 | app = ControllerWrap(HelpersController) 30 | app = self.sap = SetupCacheGlobal(app, self.baseenviron) 31 | app = RegistryManager(app) 32 | self.app = TestApp(app) 33 | 34 | def setUp(self): 35 | TestWSGIController.setUp(self) 36 | self.baseenviron.update(self.environ) 37 | warnings.simplefilter('error', DeprecationWarning) 38 | 39 | def tearDown(self): 40 | warnings.simplefilter('always', DeprecationWarning) 41 | 42 | def test_return_etag_cache(self): 43 | self.baseenviron['pylons.routes_dict']['action'] = 'test_etag_cache' 44 | response = self.app.get('/') 45 | assert '"test"' == response.header('Etag') 46 | assert 'from etag_cache' in response 47 | -------------------------------------------------------------------------------- /tests/test_units/test_i18n.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import os 3 | import sys 4 | 5 | from paste.fixture import TestApp 6 | 7 | from __init__ import test_root 8 | 9 | lang_setup = None 10 | 11 | 12 | def setup_py_trans(): 13 | global lang_setup 14 | import pylons 15 | from pylons.i18n.translation import _get_translator 16 | root = os.path.join(test_root, 'sample_controllers') 17 | lang_setup = {'pylons.paths': {'root': root}, 'pylons.package': 'sample_controllers'} 18 | sys.path.append(test_root) 19 | pylons.translator._push_object(_get_translator(None, pylons_config=lang_setup)) 20 | 21 | glob_set = [] 22 | 23 | 24 | class TestI18N(object): 25 | def setUp(self): 26 | setup_py_trans() 27 | 28 | def test_lazify(self): 29 | from pylons.i18n.translation import lazify 30 | 31 | def show_str(st): 32 | return '%s%s' % (st, len(glob_set)) 33 | lazy_show_str = lazify(show_str) 34 | result1 = lazy_show_str('fred') 35 | result2 = show_str('fred') 36 | assert str(result1) == str(result2) 37 | glob_set.append('1') 38 | assert str(result1) != str(result2) 39 | 40 | def test_noop(self): 41 | import pylons 42 | from pylons.i18n.translation import _, N_, set_lang 43 | foo = N_('Hello') 44 | 45 | class Bar(object): 46 | def __init__(self): 47 | self.local_foo = _(foo) 48 | 49 | assert Bar().local_foo == 'Hello' 50 | 51 | t = set_lang('fr', set_environ=False, pylons_config=lang_setup) 52 | pylons.translator._push_object(t) 53 | assert Bar().local_foo == 'Bonjour' 54 | t = set_lang('es', set_environ=False, pylons_config=lang_setup) 55 | pylons.translator._push_object(t) 56 | assert Bar().local_foo == u'¡Hola!' 57 | assert foo == 'Hello' 58 | -------------------------------------------------------------------------------- /tests/test_units/test_middleware.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from webtest import TestApp 3 | 4 | def simple_app(environ, start_response): 5 | start_response('200 OK', [('Content-type', 'text/plain')]) 6 | return ['Hello world!'] 7 | 8 | def simple_exception_app(environ, start_response): 9 | if environ['PATH_INFO'].startswith('/error/document'): 10 | start_response('200 OK', [('Content-type', 'text/plain')]) 11 | return ['Made it to the error'] 12 | else: 13 | start_response('404 Not Found', [('Content-type', 'text/plain')]) 14 | return ['No page found!'] 15 | 16 | def test_plain_wrap(): 17 | from pylons.middleware import StatusCodeRedirect 18 | app = TestApp(StatusCodeRedirect(simple_app)) 19 | res = app.get('/') 20 | assert res.status_int == 200 21 | 22 | def test_status_intercept(): 23 | from pylons.middleware import StatusCodeRedirect 24 | app = TestApp(StatusCodeRedirect(simple_exception_app)) 25 | res = app.get('/', status=404) 26 | assert 'Made it to the error' in res 27 | 28 | def test_original_path(): 29 | from pylons.middleware import StatusCodeRedirect 30 | app = TestApp(StatusCodeRedirect(simple_exception_app)) 31 | res = app.get('/', status=404) 32 | if getattr(res, 'environ', None) is not None: # webob<1.2 33 | assert res.environ['PATH_INFO'] == '/' 34 | 35 | def test_retains_response(): 36 | from pylons.middleware import StatusCodeRedirect 37 | app = TestApp(StatusCodeRedirect(simple_exception_app)) 38 | res = app.get('/', status=404) 39 | if getattr(res, 'environ', None) is not None: # webob<1.2 40 | assert 'pylons.original_response' in res.environ 41 | assert 'No page found!' in res.environ['pylons.original_response'].body 42 | 43 | def test_retains_request(): 44 | from pylons.middleware import StatusCodeRedirect 45 | app = TestApp(StatusCodeRedirect(simple_exception_app)) 46 | res = app.get('/fredrick', status=404) 47 | if getattr(res, 'environ', None) is not None: # webob<1.2 48 | assert 'pylons.original_request' in res.environ 49 | assert '/fredrick' == res.environ['pylons.original_request'].path_info 50 | 51 | -------------------------------------------------------------------------------- /tests/test_units/test_templating.py: -------------------------------------------------------------------------------- 1 | import os 2 | import re 3 | import sys 4 | 5 | from beaker.cache import CacheManager 6 | from beaker.middleware import SessionMiddleware, CacheMiddleware 7 | from mako.lookup import TemplateLookup 8 | from nose.tools import raises 9 | from paste.fixture import TestApp 10 | from paste.registry import RegistryManager 11 | from paste.deploy.converters import asbool 12 | from routes import Mapper 13 | from routes.middleware import RoutesMiddleware 14 | 15 | from nose.tools import raises 16 | 17 | from __init__ import test_root 18 | 19 | 20 | def make_app(global_conf, full_stack=True, static_files=True, include_cache_middleware=False, attribsafe=False, **app_conf): 21 | import pylons 22 | import pylons.configuration as configuration 23 | from pylons import url 24 | from pylons.decorators import jsonify 25 | from pylons.middleware import ErrorHandler, StatusCodeRedirect 26 | from pylons.error import handle_mako_error 27 | from pylons.wsgiapp import PylonsApp 28 | 29 | root = os.path.dirname(os.path.abspath(__file__)) 30 | paths = dict(root=os.path.join(test_root, 'sample_controllers'), controllers=os.path.join(test_root, 'sample_controllers', 'controllers'), 31 | templates=os.path.join(test_root, 'sample_controllers', 'templates')) 32 | sys.path.append(test_root) 33 | 34 | config = configuration.PylonsConfig() 35 | config.init_app(global_conf, app_conf, package='sample_controllers', paths=paths) 36 | map = Mapper(directory=config['pylons.paths']['controllers']) 37 | map.connect('/{controller}/{action}') 38 | config['routes.map'] = map 39 | 40 | class AppGlobals(object): pass 41 | 42 | config['pylons.app_globals'] = AppGlobals() 43 | 44 | config['pylons.app_globals'].mako_lookup = TemplateLookup( 45 | directories=paths['templates'], imports=['from markupsafe import escape'] 46 | ) 47 | 48 | if attribsafe: 49 | config['pylons.strict_tmpl_context'] = False 50 | 51 | app = PylonsApp(config=config) 52 | app = RoutesMiddleware(app, config['routes.map'], singleton=False) 53 | if include_cache_middleware: 54 | app = CacheMiddleware(app, config) 55 | app = SessionMiddleware(app, config) 56 | 57 | if asbool(full_stack): 58 | app = ErrorHandler(app, global_conf, **config['pylons.errorware']) 59 | if asbool(config['debug']): 60 | app = StatusCodeRedirect(app) 61 | else: 62 | app = StatusCodeRedirect(app, [401, 403, 404, 500]) 63 | app = RegistryManager(app) 64 | 65 | app.config = config 66 | return app 67 | 68 | class TestTemplatingApp(object): 69 | def setUp(self): 70 | self.app = TestApp(make_app({'cache_dir': os.path.join(os.path.dirname(__file__), 'cache')}, include_cache_middleware=True)) 71 | 72 | def test_testvars(self): 73 | resp = self.app.get('/hello/intro_template') 74 | assert 'Hi there 6' in resp 75 | 76 | def test_template_cache(self): 77 | resp = self.app.get('/hello/time_template') 78 | resp2 = self.app.get('/hello/time_template') 79 | assert resp.body == resp2.body 80 | 81 | -------------------------------------------------------------------------------- /tests/test_webapps/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/tests/test_webapps/__init__.py -------------------------------------------------------------------------------- /tests/test_webapps/filestotest/app_globals.py: -------------------------------------------------------------------------------- 1 | """The application's Globals object""" 2 | from pylons import config 3 | 4 | from beaker.cache import CacheManager 5 | from beaker.util import parse_cache_config_options 6 | 7 | class Globals(object): 8 | """Globals acts as a container for objects available throughout the 9 | life of the application 10 | 11 | """ 12 | def __init__(self, config): 13 | """One instance of Globals is created during application 14 | initialization and is available during requests via the 15 | 'app_globals' variable 16 | 17 | """ 18 | self.cache = CacheManager(**parse_cache_config_options(config)) 19 | self.message = 'Hello' 20 | self.counter = 0 21 | -------------------------------------------------------------------------------- /tests/test_webapps/filestotest/base_with_xmlrpc.py: -------------------------------------------------------------------------------- 1 | from pylons import tmpl_context as c, app_globals, cache, request, session 2 | from pylons.controllers import WSGIController, XMLRPCController 3 | from pylons.controllers.util import abort, etag_cache, redirect 4 | from pylons.decorators import jsonify, validate 5 | from pylons.templating import render_mako as render 6 | from pylons.i18n import N_, _, ungettext 7 | import projectname.model as model 8 | import projectname.lib.helpers as h 9 | 10 | class BaseController(WSGIController): 11 | def __call__(self, environ, start_response): 12 | # Insert any code to be run per request here. The Routes match 13 | # is under environ['pylons.routes_dict'] should you want to check 14 | # the action or route vars here 15 | return WSGIController.__call__(self, environ, start_response) 16 | 17 | # Include the '_' function in the public names 18 | __all__ = [__name for __name in locals().keys() if not __name.startswith('_') \ 19 | or __name == '_'] 20 | -------------------------------------------------------------------------------- /tests/test_webapps/filestotest/cache_controller.py: -------------------------------------------------------------------------------- 1 | from pylons import app_globals 2 | from pylons.decorators.cache import beaker_cache 3 | from projectname.lib.base import BaseController 4 | 5 | class CacheController(BaseController): 6 | 7 | @beaker_cache(key=None) 8 | def test_default_cache_decorator(self): 9 | app_globals.counter += 1 10 | return 'Counter=%s' % app_globals.counter 11 | 12 | @beaker_cache(key="param", query_args=True) 13 | def test_get_cache_decorator(self): 14 | app_globals.counter += 1 15 | return 'Counter=%s' % app_globals.counter 16 | 17 | @beaker_cache(expire=4) 18 | def test_expire_cache_decorator(self): 19 | app_globals.counter += 1 20 | return 'Counter=%s' % app_globals.counter 21 | 22 | @beaker_cache(key="id") 23 | def test_key_cache_decorator(self, id): 24 | app_globals.counter += 1 25 | return 'Counter=%s, id=%s' % (app_globals.counter, id) 26 | 27 | @beaker_cache(key=["id", "id2"]) 28 | def test_keyslist_cache_decorator(self, id, id2="123"): 29 | app_globals.counter += 1 30 | return 'Counter=%s, id=%s' % (app_globals.counter, id) 31 | -------------------------------------------------------------------------------- /tests/test_webapps/filestotest/controller_sample.py: -------------------------------------------------------------------------------- 1 | import datetime 2 | 3 | from projectname.lib.base import * 4 | import projectname.lib.helpers as h 5 | from pylons import request, response, session, url 6 | from pylons import tmpl_context as c 7 | from pylons import app_globals 8 | from pylons.decorators import rest 9 | from pylons.i18n import _, get_lang, set_lang, LanguageError 10 | from pylons.templating import render_mako, render_genshi, render_jinja2 11 | from pylons.controllers.util import abort, redirect 12 | 13 | class SampleController(BaseController): 14 | def index(self): 15 | return 'basic index page' 16 | 17 | def session_increment(self): 18 | session.setdefault('counter', -1) 19 | session['counter'] += 1 20 | session.save() 21 | return 'session incrementer' 22 | 23 | def globalup(self): 24 | return app_globals.message 25 | 26 | def global_store(self, id=None): 27 | if id: 28 | app_globals.counter += int(id) 29 | return str(app_globals.counter) 30 | 31 | def myself(self): 32 | return request.url 33 | 34 | def myparams(self): 35 | return str(request.params) 36 | 37 | def testdefault(self): 38 | c.test = "This is in c var" 39 | return render_genshi('testgenshi.html') 40 | 41 | def test_template_caching(self): 42 | return render_mako('/test_mako.html', cache_expire='never') 43 | 44 | @rest.dispatch_on(GET='test_only_get') 45 | @rest.restrict('POST') 46 | def test_only_post(self): 47 | return 'It was a post!' 48 | 49 | @rest.restrict('GET') 50 | def test_only_get(self): 51 | return 'It was a get!' 52 | 53 | @rest.restrict('POST') 54 | @rest.dispatch_on(POST='test_only_post') 55 | def impossible(self): 56 | return 'This should never be shown' 57 | 58 | def testjinja2(self): 59 | c.test = "This is in c var" 60 | c.now = datetime.datetime.now 61 | return render_jinja2('testjinja2.html') 62 | 63 | def set_lang(self): 64 | return self._set_lang(_) 65 | 66 | def set_lang_pylonscontext(self, pylons): 67 | return self._set_lang(lambda *args: pylons.translator.ugettext(*args)) 68 | 69 | def _set_lang(self, gettext): 70 | lang = request.GET['lang'] 71 | try: 72 | set_lang(lang) 73 | except (LanguageError, IOError), e: 74 | resp_unicode = gettext('Could not set language to "%(lang)s"') % {'lang': lang} 75 | else: 76 | session['lang'] = lang 77 | session.save() 78 | resp_unicode = gettext('Set language to "%(lang)s"') % {'lang': lang} 79 | return resp_unicode 80 | 81 | def i18n_index(self): 82 | locale_list = request.languages 83 | set_lang(request.languages) 84 | return unicode(_('basic index page')) 85 | 86 | def no_lang(self): 87 | set_lang(None) 88 | response.write(_('No language')) 89 | set_lang([]) 90 | response.write(_('No languages')) 91 | return '' 92 | -------------------------------------------------------------------------------- /tests/test_webapps/filestotest/controller_sqlatest.py: -------------------------------------------------------------------------------- 1 | import datetime 2 | 3 | from projectname.lib.base import * 4 | try: 5 | import sqlalchemy as sa 6 | from projectname.model.meta import Session, Base 7 | from projectname.model import Foo 8 | SQLAtesting = True 9 | except: 10 | SQLAtesting = False 11 | import projectname.lib.helpers as h 12 | from pylons import request, response, session 13 | from pylons import tmpl_context as c 14 | from pylons import app_globals 15 | from pylons.decorators import rest 16 | from pylons.i18n import _, get_lang, set_lang, LanguageError 17 | from pylons.templating import render_mako, render_genshi, render_jinja2 18 | from pylons.controllers.util import abort, redirect 19 | 20 | class SampleController(BaseController): 21 | def index(self): 22 | return 'basic index page' 23 | 24 | def testsqlalchemy(self): 25 | if SQLAtesting: 26 | c.foos = Session.query(Foo).all() 27 | return render_mako('test_sqlalchemy.html') 28 | pass 29 | 30 | def set_lang(self): 31 | return self._set_lang(_) 32 | 33 | def set_lang_pylonscontext(self, pylons): 34 | return self._set_lang(lambda *args: pylons.translator.ugettext(*args)) 35 | 36 | def _set_lang(self, gettext): 37 | lang = request.GET['lang'] 38 | try: 39 | set_lang(lang) 40 | except (LanguageError, IOError), e: 41 | resp_unicode = gettext('Could not set language to "%(lang)s"') % {'lang': lang} 42 | else: 43 | session['lang'] = lang 44 | session.save() 45 | resp_unicode = gettext('Set language to "%(lang)s"') % {'lang': lang} 46 | return resp_unicode 47 | 48 | def i18n_index(self): 49 | locale_list = request.languages 50 | set_lang(request.languages) 51 | return unicode(_('basic index page')) 52 | 53 | def no_lang(self): 54 | set_lang(None) 55 | response.write(_('No language')) 56 | set_lang([]) 57 | response.write(_('No languages')) 58 | return '' 59 | 60 | -------------------------------------------------------------------------------- /tests/test_webapps/filestotest/controller_xmlrpc.py: -------------------------------------------------------------------------------- 1 | from projectname.lib.base import * 2 | from pylons.controllers import XMLRPCController 3 | 4 | class XmlrpcController(XMLRPCController): 5 | def userstatus(self): 6 | return 'basic string' 7 | userstatus.signature = [ ['string'] ] 8 | 9 | def docs(self): 10 | "This method has a docstring" 11 | return dict(mess='a little somethin', a=1, b=[1,2,3], c=('all','the')) 12 | docs.signature = [ ['struct'] ] 13 | 14 | def uni(self): 15 | "This method has a docstring" 16 | return dict(mess=u'A unicode string, oh boy') 17 | docs.signature = [ ['struct'] ] 18 | -------------------------------------------------------------------------------- /tests/test_webapps/filestotest/development.ini: -------------------------------------------------------------------------------- 1 | [DEFAULT] 2 | debug = true 3 | email_to = you@yourdomain.com 4 | smtp_server = localhost 5 | error_email_from = paste@exceptions.com 6 | 7 | [server:main] 8 | use = egg:Paste#http 9 | host = 127.0.0.1 10 | port = 5000 11 | 12 | [app:main] 13 | use = egg:projectname 14 | cache_dir = %(here)s/data 15 | beaker.session.key = projectname 16 | beaker.session.secret = somesecret 17 | 18 | # If you'd like to fine-tune the individual locations of the cache data dirs 19 | # for Myghty, the Cache data, or the Session saves, un-comment the desired 20 | # settings here: 21 | #beaker.cache_data_dir = %(here)s/data/cache 22 | #beaker.session_data_dir = %(here)s/data/sessions 23 | 24 | # If you are using SQLAlchemy you will need to specify a 25 | # dburi. You can do this with a line similar to the 26 | # one below but adjusted for your database connection 27 | # according to the SQLAlchemy documentation. The %(here)s 28 | # part is replaced with the current directory which is 29 | # useful when using sqlite on UNIX based platforms. 30 | # For Windows you should look at the SQLAlchemy 31 | # documentation for a special syntax to use because the 32 | # path returned by %(here)s contains a : character. 33 | # SQLAlchemy database URL 34 | #sqlalchemy.url = sqlite:///%(here)s/development.db 35 | 36 | # Do not set debug to true or uncomment the line below 37 | # on a production environment otherwise in the event of 38 | # an error occurring the visitor will be presented with 39 | # interactive debugging tools and these could be used to 40 | # execute malicious code. 41 | # For development purposes debug should be set to true 42 | # to enable the debugging code but be sure to set it back 43 | # to false before releasing your application. 44 | #set debug = false 45 | -------------------------------------------------------------------------------- /tests/test_webapps/filestotest/development_sqlatesting.ini: -------------------------------------------------------------------------------- 1 | [DEFAULT] 2 | debug = true 3 | email_to = you@yourdomain.com 4 | smtp_server = localhost 5 | error_email_from = paste@exceptions.com 6 | 7 | [server:main] 8 | use = egg:Paste#http 9 | host = 127.0.0.1 10 | port = 5000 11 | 12 | [app:main] 13 | use = egg:projectname 14 | cache_dir = %(here)s/data 15 | beaker.session.key = projectname 16 | beaker.session.secret = somesecret 17 | 18 | # If you'd like to fine-tune the individual locations of the cache data dirs 19 | # for Myghty, the Cache data, or the Session saves, un-comment the desired 20 | # settings here: 21 | #beaker.cache_data_dir = %(here)s/data/cache 22 | #beaker.session_data_dir = %(here)s/data/sessions 23 | 24 | # If you are using SQLAlchemy you will need to specify a 25 | # dburi. You can do this with a line similar to the 26 | # one below but adjusted for your database connection 27 | # according to the SQLAlchemy documentation. The %(here)s 28 | # part is replaced with the current directory which is 29 | # useful when using sqlite on UNIX based platforms. 30 | # For Windows you should look at the SQLAlchemy 31 | # documentation for a special syntax to use because the 32 | # path returned by %(here)s contains a : character. 33 | # SQLAlchemy database URL 34 | sqlalchemy.url = sqlite:///%(here)s/development.db 35 | sqlalchemy.echo = True 36 | 37 | # Do not set debug to true or uncomment the line below 38 | # on a production environment otherwise in the event of 39 | # an error occurring the visitor will be presented with 40 | # interactive debugging tools and these could be used to 41 | # execute malicious code. 42 | # For development purposes debug should be set to true 43 | # to enable the debugging code but be sure to set it back 44 | # to false before releasing your application. 45 | #set debug = false 46 | 47 | -------------------------------------------------------------------------------- /tests/test_webapps/filestotest/environment_def_engine.py: -------------------------------------------------------------------------------- 1 | """Pylons environment configuration""" 2 | import os 3 | 4 | 5 | from mako.lookup import TemplateLookup 6 | from genshi.template import TemplateLoader 7 | from jinja2 import ChoiceLoader, Environment, FileSystemLoader 8 | from pylons.configuration import PylonsConfig 9 | from pylons.error import handle_mako_error 10 | 11 | import projectname.lib.app_globals as app_globals 12 | import projectname.lib.helpers 13 | from projectname.config.routing import make_map 14 | 15 | def load_environment(global_conf, app_conf): 16 | """Configure the Pylons environment via the ``pylons.config`` 17 | object 18 | """ 19 | config = PylonsConfig() 20 | 21 | # Pylons paths 22 | root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 23 | paths = dict(root=root, 24 | controllers=os.path.join(root, 'controllers'), 25 | static_files=os.path.join(root, 'public'), 26 | templates=[os.path.join(root, 'templates')]) 27 | 28 | # Initialize config with the basic options 29 | config.init_app(global_conf, app_conf, package='projectname', paths=paths) 30 | 31 | config['routes.map'] = make_map(config) 32 | config['pylons.app_globals'] = app_globals.Globals(config) 33 | config['pylons.h'] = projectname.lib.helpers 34 | 35 | # Setup cache object as early as possible 36 | import pylons 37 | pylons.cache._push_object(config['pylons.app_globals'].cache) 38 | 39 | # Create the Mako TemplateLookup, with the default auto-escaping 40 | config['pylons.app_globals'].mako_lookup = TemplateLookup( 41 | directories=paths['templates'], 42 | error_handler=handle_mako_error, 43 | module_directory=os.path.join(app_conf['cache_dir'], 'templates'), 44 | input_encoding='utf-8', default_filters=['escape'], 45 | imports=['from webhelpers.html import escape']) 46 | 47 | # Create the Genshi TemplateLoader 48 | config['pylons.app_globals'].genshi_loader = TemplateLoader( 49 | paths['templates'], auto_reload=True) 50 | 51 | # Create the Jinja2 Environment 52 | config['pylons.app_globals'].jinja2_env = Environment(loader=ChoiceLoader( 53 | [FileSystemLoader(path) for path in paths['templates']])) 54 | 55 | # CONFIGURATION OPTIONS HERE (note: all config options will override 56 | # any Pylons config options) 57 | 58 | return config 59 | -------------------------------------------------------------------------------- /tests/test_webapps/filestotest/environment_def_sqlamodel.py: -------------------------------------------------------------------------------- 1 | """Pylons environment configuration""" 2 | import os 3 | 4 | 5 | from mako.lookup import TemplateLookup 6 | from genshi.template import TemplateLoader 7 | from jinja2 import ChoiceLoader, Environment, FileSystemLoader 8 | from pylons.configuration import PylonsConfig 9 | from pylons.error import handle_mako_error 10 | from sqlalchemy import engine_from_config 11 | 12 | import projectname.lib.app_globals as app_globals 13 | import projectname.lib.helpers 14 | from projectname.config.routing import make_map 15 | from projectname.model import init_model 16 | 17 | def load_environment(global_conf, app_conf): 18 | """Configure the Pylons environment via the ``pylons.config`` 19 | object 20 | """ 21 | config = PylonsConfig() 22 | 23 | # Pylons paths 24 | root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 25 | paths = dict(root=root, 26 | controllers=os.path.join(root, 'controllers'), 27 | static_files=os.path.join(root, 'public'), 28 | templates=[os.path.join(root, 'templates')]) 29 | 30 | # Initialize config with the basic options 31 | config.init_app(global_conf, app_conf, package='projectname', paths=paths) 32 | 33 | config['routes.map'] = make_map(config) 34 | config['pylons.app_globals'] = app_globals.Globals(config) 35 | config['pylons.h'] = projectname.lib.helpers 36 | 37 | # Setup cache object as early as possible 38 | import pylons 39 | pylons.cache._push_object(config['pylons.app_globals'].cache) 40 | 41 | # Create the Mako TemplateLookup, with the default auto-escaping 42 | config['pylons.app_globals'].mako_lookup = TemplateLookup( 43 | directories=paths['templates'], 44 | error_handler=handle_mako_error, 45 | module_directory=os.path.join(app_conf['cache_dir'], 'templates'), 46 | input_encoding='utf-8', default_filters=['escape'], 47 | imports=['from webhelpers.html import escape']) 48 | 49 | # Create the Genshi TemplateLoader 50 | config['pylons.app_globals'].genshi_loader = TemplateLoader( 51 | paths['templates'], auto_reload=True) 52 | 53 | # Create the Jinja2 Environment 54 | config['pylons.app_globals'].jinja2_env = Environment(loader=ChoiceLoader( 55 | [FileSystemLoader(path) for path in paths['templates']])) 56 | 57 | # CONFIGURATION OPTIONS HERE (note: all config options will override 58 | # any Pylons config options) 59 | 60 | engine = engine_from_config(config, 'sqlalchemy.') 61 | init_model(engine) 62 | 63 | return config 64 | -------------------------------------------------------------------------------- /tests/test_webapps/filestotest/functional_controller_cache_decorator.py: -------------------------------------------------------------------------------- 1 | import time 2 | 3 | from projectname.tests import * 4 | 5 | class TestCacheController(TestController): 6 | 7 | def test_default_cache_decorator(self): 8 | response = self.app.get(url(controller='cache', action='test_default_cache_decorator')) 9 | assert 'Counter=1' in response 10 | 11 | response = self.app.get(url(controller='cache', action='test_default_cache_decorator')) 12 | assert 'Counter=1' in response 13 | 14 | response = self.app.get(url(controller='cache', action='test_get_cache_decorator', param="123")) 15 | assert 'Counter=2' in response 16 | response = self.app.get(url(controller='cache', action='test_get_cache_decorator', param="123")) 17 | assert 'Counter=2' in response 18 | 19 | response = self.app.get(url(controller='cache', action='test_expire_cache_decorator')) 20 | assert 'Counter=3' in response 21 | response = self.app.get(url(controller='cache', action='test_expire_cache_decorator')) 22 | assert 'Counter=3' in response 23 | time.sleep(8) 24 | response = self.app.get(url(controller='cache', action='test_expire_cache_decorator')) 25 | assert 'Counter=4' in response 26 | 27 | response = self.app.get(url(controller='cache', action='test_key_cache_decorator', id=1)) 28 | assert 'Counter=5' in response 29 | response = self.app.get(url(controller='cache', action='test_key_cache_decorator', id=2)) 30 | assert 'Counter=6' in response 31 | response = self.app.get(url(controller='cache', action='test_key_cache_decorator', id=1)) 32 | assert 'Counter=5' in response 33 | 34 | response = self.app.get(url(controller='cache', action='test_keyslist_cache_decorator', id=1, id2=2)) 35 | assert 'Counter=7' in response 36 | response = self.app.get(url(controller='cache', action='test_keyslist_cache_decorator', id=1, id2=2)) 37 | assert 'Counter=7' in response 38 | 39 | -------------------------------------------------------------------------------- /tests/test_webapps/filestotest/functional_controller_xmlrpc.py: -------------------------------------------------------------------------------- 1 | from projectname.tests import * 2 | from xmlrpclib import loads, dumps 3 | 4 | class TestXmlrpcController(TestController): 5 | xmlurl = None 6 | 7 | def xmlreq(self, method, args=None): 8 | if args is None: 9 | args = () 10 | ee = dict(CONTENT_TYPE='text/xml') 11 | data = dumps(args, methodname=method) 12 | response = self.app.post(self.xmlurl, params = data, extra_environ=ee) 13 | return loads(response.body)[0][0] 14 | 15 | def setUp(self): 16 | self.xmlurl = url(controller='xmlrpc', action='index') 17 | 18 | def test_index(self): 19 | response = self.xmlreq('userstatus') 20 | assert response == 'basic string' 21 | 22 | def test_structure(self): 23 | response = self.xmlreq('docs') 24 | assert dict(mess='a little somethin', a=1, b=[1,2,3], c=['all','the']) == response 25 | 26 | def test_methodhelp(self): 27 | response = self.xmlreq('system.methodHelp', ('docs',)) 28 | assert "This method has a docstring" in response 29 | 30 | def test_methodsignature(self): 31 | response = self.xmlreq('system.methodSignature', ('docs',)) 32 | assert [['struct']] == response 33 | 34 | def test_listmethods(self): 35 | response = self.xmlreq('system.listMethods') 36 | assert response == ['docs', 'system.listMethods', 'system.methodHelp', 'system.methodSignature', 'uni', 'userstatus'] 37 | 38 | def test_unicode(self): 39 | response = self.xmlreq('uni') 40 | assert 'A unicode string' in response['mess'] -------------------------------------------------------------------------------- /tests/test_webapps/filestotest/functional_sample_controller_i18n.py: -------------------------------------------------------------------------------- 1 | from projectname.tests import * 2 | 3 | class TestSampleController(TestController): 4 | def test_set_lang(self): 5 | self._test_set_lang('set_lang') 6 | 7 | def test_set_lang_pylonscontext(self): 8 | self._test_set_lang('set_lang_pylonscontext') 9 | 10 | def _test_set_lang(self, action): 11 | response = self.app.get(url(controller='sample', action=action, lang='ja')) 12 | assert u'\u8a00\u8a9e\u8a2d\u5b9a\u3092\u300cja\u300d\u306b\u5909\u66f4\u3057\u307e\u3057\u305f'.encode('utf-8') in response 13 | response = self.app.get(url(controller='sample', action=action, lang='fr')) 14 | assert 'Could not set language to "fr"' in response 15 | 16 | def test_detect_lang(self): 17 | response = self.app.get(url(controller='sample', action='i18n_index'), headers={ 18 | 'Accept-Language':'fr;q=0.6, en;q=0.1, ja;q=0.3'}) 19 | # expect japanese fallback for nonexistent french. 20 | assert u'\u6839\u672c\u30a4\u30f3\u30c7\u30af\u30b9\u30da\u30fc\u30b8'.encode('utf-8') in response 21 | 22 | def test_no_lang(self): 23 | response = self.app.get(url(controller='sample', action='no_lang')) 24 | assert 'No language' in response 25 | assert 'No languages' in response 26 | -------------------------------------------------------------------------------- /tests/test_webapps/filestotest/functional_sample_controller_jinja2.py: -------------------------------------------------------------------------------- 1 | from projectname.tests import * 2 | 3 | class TestJinja2Controller(TestController): 4 | def test_jinja2(self): 5 | response = self.app.get(url(controller='sample', action='testjinja2')) 6 | assert 'Hello from Jinja2' in response 7 | assert 'This is in c var' in response 8 | -------------------------------------------------------------------------------- /tests/test_webapps/filestotest/functional_sample_controller_mako.py: -------------------------------------------------------------------------------- 1 | from projectname.tests import * 2 | 3 | class TestMakoController(TestController): 4 | def test_mako(self): 5 | response = self.app.get(url(controller='sample', action='testmako')) 6 | assert 'Hello, 5+5 is 10' in response 7 | -------------------------------------------------------------------------------- /tests/test_webapps/filestotest/functional_sample_controller_sample1.py: -------------------------------------------------------------------------------- 1 | import pylons 2 | from projectname.tests import * 3 | 4 | class TestSampleController(TestController): 5 | def test_conf_with_app_globals(self): 6 | assert 'pylons.app_globals' in pylons.config 7 | assert hasattr(pylons.app_globals, 'cache') 8 | 9 | def test_root_index(self): 10 | response = self.app.get('/') 11 | assert 'Welcome' in response 12 | # Test response... 13 | 14 | def test_index(self): 15 | response = self.app.get(url(controller='sample', action='index')) 16 | assert 'basic index page' in response 17 | 18 | def test_session(self): 19 | response = self.app.get(url(controller='sample', action='session_increment')) 20 | assert response.session.has_key('counter') 21 | assert response.session['counter'] == 0 22 | 23 | response = self.app.get(url(controller='sample', action='session_increment')) 24 | assert response.session['counter'] == 1 25 | assert 'session incrementer' in response 26 | 27 | def test_global(self): 28 | response = self.app.get(url(controller='sample', action='globalup')) 29 | assert 'Hello' in response 30 | 31 | def test_global_persistence(self): 32 | response = self.app.get(url(controller='sample', action='global_store')) 33 | assert '0' in response 34 | 35 | response = self.app.get(url(controller='sample', action='global_store', id=2)) 36 | assert '2' in response 37 | 38 | response = self.app.get(url(controller='sample', action='global_store')) 39 | assert '2' in response 40 | 41 | response = self.app.get(url(controller='sample', action='global_store', id=3)) 42 | assert '5' in response 43 | 44 | response = self.app.get(url(controller='sample', action='global_store')) 45 | assert '5' in response 46 | 47 | def test_helper_urlfor(self): 48 | response = self.app.get(url(controller='sample', action='myself')) 49 | assert 'sample/myself' in response 50 | 51 | def test_params(self): 52 | response = self.app.get(url(controller='sample', action='myparams', extra='something', data=4)) 53 | assert 'extra' in response 54 | assert 'something' in response 55 | assert 'data' in response 56 | -------------------------------------------------------------------------------- /tests/test_webapps/filestotest/functional_sample_controller_sample2.py: -------------------------------------------------------------------------------- 1 | from projectname.tests import * 2 | 3 | class TestSample2Controller(TestController): 4 | def test_session(self): 5 | response = self.app.get(url(controller='sample', action='session_increment')) 6 | assert response.session.has_key('counter') 7 | assert response.session['counter'] == 0 8 | 9 | response = self.app.get(url(controller='sample', action='session_increment')) 10 | assert response.session['counter'] == 1 11 | assert 'session incrementer' in response 12 | 13 | def test_genshi_default(self): 14 | self._test_genshi_default('testdefault') 15 | 16 | def _test_genshi_default(self, action): 17 | response = self.app.get(url(controller='sample', action=action)) 18 | assert 'Hello from Genshi' in response 19 | assert 'This is in c var' in response 20 | -------------------------------------------------------------------------------- /tests/test_webapps/filestotest/functional_sample_controller_sample3.py: -------------------------------------------------------------------------------- 1 | from projectname.tests import * 2 | 3 | class TestSample2Controller(TestController): 4 | def test_session(self): 5 | response = self.app.get(url(controller='sample', action='session_increment')) 6 | assert response.session.has_key('counter') 7 | assert response.session['counter'] == 0 8 | 9 | response = self.app.get(url(controller='sample', action='session_increment')) 10 | assert response.session['counter'] == 1 11 | assert 'session incrementer' in response 12 | 13 | def test_default(self): 14 | response = self.app.get(url(controller='sample', action='test_template_caching')) 15 | assert 'Hi everyone!' in response 16 | -------------------------------------------------------------------------------- /tests/test_webapps/filestotest/functional_sample_controller_sample4.py: -------------------------------------------------------------------------------- 1 | from projectname.tests import * 2 | 3 | class TestSample2Controller(TestController): 4 | def test_get(self): 5 | response = self.app.get(url(controller='sample', action='test_only_get')) 6 | assert 'It was a get' in response 7 | 8 | def test_redir_get(self): 9 | response = self.app.get(url(controller='sample', action='test_only_post')) 10 | assert 'It was a get' in response 11 | 12 | def test_post(self): 13 | response = self.app.post(url(controller='sample', action='test_only_post'), 14 | params={'id':4}) 15 | assert 'It was a post' in response 16 | 17 | def test_head(self): 18 | response = self.app._gen_request('HEAD', url(controller='sample', action='index')) 19 | assert '' == response.body 20 | -------------------------------------------------------------------------------- /tests/test_webapps/filestotest/functional_sample_controller_sqlatesting.py: -------------------------------------------------------------------------------- 1 | from projectname.tests import * 2 | try: 3 | from sqlalchemy.exceptions import IntegrityError 4 | except ImportError: 5 | from sqlalchemy.exc import IntegrityError 6 | 7 | from projectname.model.meta import Session, Base 8 | from projectname.model import Foo 9 | 10 | class TestSQLAlchemyController(TestController): 11 | def setUp(self): 12 | Base.metadata.create_all(bind=Session.bind) 13 | f = Foo(id = 1, bar = u"Wabbit") 14 | Session.add(f) 15 | Session.commit() 16 | assert f.bar == u"Wabbit" 17 | 18 | def tearDown(self): 19 | Base.metadata.drop_all(bind=Session.bind) 20 | 21 | def test_sqlalchemy(self): 22 | response = self.app.get(url(controller='sample', action='testsqlalchemy')) 23 | assert 'foos = [Foo:1]' in response 24 | 25 | # def test_exception(self): 26 | # me = Foo(id=3, bar='giuseppe') 27 | # me_again = Foo(id=3, bar='giuseppe') 28 | # self.assertRaises(IntegrityError, Session.commit) 29 | # Session.rollback() 30 | -------------------------------------------------------------------------------- /tests/test_webapps/filestotest/helpers_sample.py: -------------------------------------------------------------------------------- 1 | """Helper functions 2 | 3 | Consists of functions to typically be used within templates, but also 4 | available to Controllers. This module is available to both as 'h'. 5 | """ 6 | -------------------------------------------------------------------------------- /tests/test_webapps/filestotest/messages.ja.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pylons/pylons/8625d5af790560219c5114358611bc7e0edcf12f/tests/test_webapps/filestotest/messages.ja.mo -------------------------------------------------------------------------------- /tests/test_webapps/filestotest/messages.ja.po: -------------------------------------------------------------------------------- 1 | # SOME DESCRIPTIVE TITLE. 2 | # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER 3 | # This file is distributed under the same license as the PACKAGE package. 4 | # FIRST AUTHOR , YEAR. 5 | # 6 | #, fuzzy 7 | msgid "" 8 | msgstr "" 9 | "Project-Id-Version: PACKAGE VERSION\n" 10 | "Report-Msgid-Bugs-To: \n" 11 | "POT-Creation-Date: 2007-02-05 12:36+0900\n" 12 | "PO-Revision-Date: 2007-02-05 13:06+0900\n" 13 | "Last-Translator: FULL NAME \n" 14 | "Language-Team: LANGUAGE \n" 15 | "MIME-Version: 1.0\n" 16 | "Content-Type: text/plain; charset=utf-8\n" 17 | "Content-Transfer-Encoding: 8bit\n" 18 | 19 | #: controller_sample.py:7 20 | msgid "basic index page" 21 | msgstr "根本インデクスページ" 22 | 23 | #: controller_sample.py:59 24 | #, python-format 25 | msgid "Could not set language to \"%(lang)s\"" 26 | msgstr "「%(lang)s」に言語設定が変更できません" 27 | 28 | #: controller_sample.py:63 29 | #, python-format 30 | msgid "Set language to \"%(lang)s\"" 31 | msgstr "言語設定を「%(lang)s」に変更しました" -------------------------------------------------------------------------------- /tests/test_webapps/filestotest/messages.pot: -------------------------------------------------------------------------------- 1 | # SOME DESCRIPTIVE TITLE. 2 | # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER 3 | # This file is distributed under the same license as the PACKAGE package. 4 | # FIRST AUTHOR , YEAR. 5 | # 6 | #, fuzzy 7 | msgid "" 8 | msgstr "" 9 | "Project-Id-Version: PACKAGE VERSION\n" 10 | "Report-Msgid-Bugs-To: \n" 11 | "POT-Creation-Date: 2007-02-05 12:36+0900\n" 12 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 13 | "Last-Translator: FULL NAME \n" 14 | "Language-Team: LANGUAGE \n" 15 | "MIME-Version: 1.0\n" 16 | "Content-Type: text/plain; charset=CHARSET\n" 17 | "Content-Transfer-Encoding: 8bit\n" 18 | 19 | #: controller_sample.py:7 20 | msgid "basic index page" 21 | msgstr "" 22 | 23 | #: controller_sample.py:59 24 | #, python-format 25 | msgid "Could not set language to \"%(lang)s\"" 26 | msgstr "" 27 | 28 | #: controller_sample.py:63 29 | #, python-format 30 | msgid "Set language to \"%(lang)s\"" 31 | msgstr "" 32 | -------------------------------------------------------------------------------- /tests/test_webapps/filestotest/middleware_mako.py: -------------------------------------------------------------------------------- 1 | """Pylons middleware initialization""" 2 | from beaker.middleware import SessionMiddleware 3 | from paste.cascade import Cascade 4 | from paste.registry import RegistryManager 5 | from paste.urlparser import StaticURLParser 6 | from paste.deploy.converters import asbool 7 | from pylons.middleware import ErrorHandler, StatusCodeRedirect 8 | from pylons.wsgiapp import PylonsApp 9 | from routes.middleware import RoutesMiddleware 10 | 11 | from projectname.config.environment import load_environment 12 | 13 | def make_app(global_conf, full_stack=True, static_files=True, **app_conf): 14 | """Create a Pylons WSGI application and return it 15 | 16 | ``global_conf`` 17 | The inherited configuration for this application. Normally from 18 | the [DEFAULT] section of the Paste ini file. 19 | 20 | ``full_stack`` 21 | Whether this application provides a full WSGI stack (by default, 22 | meaning it handles its own exceptions and errors). Disable 23 | full_stack when this application is "managed" by another WSGI 24 | middleware. 25 | 26 | ``static_files`` 27 | Whether this application serves its own static files; disable 28 | when another web server is responsible for serving them. 29 | 30 | ``app_conf`` 31 | The application's local configuration. Normally specified in 32 | the [app:] section of the Paste ini file (where 33 | defaults to main). 34 | 35 | """ 36 | # Configure the Pylons environment 37 | config = load_environment(global_conf, app_conf) 38 | 39 | # The Pylons WSGI app 40 | app = PylonsApp(config=config) 41 | 42 | # Routing/Session/Cache Middleware 43 | app = RoutesMiddleware(app, config['routes.map'], singleton=False) 44 | app = SessionMiddleware(app, config) 45 | 46 | # CUSTOM MIDDLEWARE HERE (filtered by error handling middlewares) 47 | 48 | if asbool(full_stack): 49 | # Handle Python exceptions 50 | app = ErrorHandler(app, global_conf, **config['pylons.errorware']) 51 | 52 | # Display error documents for 401, 403, 404 status codes (and 53 | # 500 when debug is disabled) 54 | if asbool(config['debug']): 55 | app = StatusCodeRedirect(app) 56 | else: 57 | app = StatusCodeRedirect(app, [400, 401, 403, 404, 500]) 58 | 59 | # Establish the Registry for this application 60 | app = RegistryManager(app) 61 | 62 | if asbool(static_files): 63 | # Serve static files 64 | static_app = StaticURLParser(config['pylons.paths']['static_files']) 65 | app = Cascade([static_app, app]) 66 | app.config = config 67 | return app 68 | -------------------------------------------------------------------------------- /tests/test_webapps/filestotest/model__init__.py: -------------------------------------------------------------------------------- 1 | """The application's model objects""" 2 | from sqlalchemy import types, Column 3 | 4 | from projectname.model.meta import Base, Session 5 | 6 | def init_model(engine): 7 | """Call me before using any of the tables or classes in the model""" 8 | Session.configure(bind=engine) 9 | 10 | 11 | class Foo(Base): 12 | __tablename__ = 'foo' 13 | 14 | id = Column(types.Integer, primary_key=True) 15 | bar = Column(types.String(255), nullable=False) 16 | def __repr__(self): 17 | return "Foo:%s" % self.id 18 | -------------------------------------------------------------------------------- /tests/test_webapps/filestotest/rest_routing.py: -------------------------------------------------------------------------------- 1 | """Routes configuration 2 | 3 | The more specific and detailed routes should be defined first so they 4 | may take precedent over the more generic routes. For more information 5 | refer to the routes manual at http://routes.groovie.org/docs/ 6 | """ 7 | from routes import Mapper 8 | 9 | def make_map(config): 10 | """Create, configure and return the routes Mapper""" 11 | map = Mapper(directory=config['pylons.paths']['controllers'], 12 | always_scan=config['debug']) 13 | map.minimization = False 14 | map.explicit = False 15 | 16 | # The ErrorController route (handles 404/500 error pages); it should 17 | # likely stay at the top, ensuring it can always be resolved 18 | map.connect('/error/{action}', controller='error') 19 | map.connect('/error/{action}/{id}', controller='error') 20 | 21 | # CUSTOM ROUTES HERE 22 | map.resource('restsample', 'restsamples') 23 | map.resource('restsample', 'restsamples', controller='mysubdir/restsamples', 24 | path_prefix='/mysubdir', name_prefix='mysubdir_') 25 | 26 | map.connect('/{controller}/{action}') 27 | map.connect('/{controller}/{action}/{id}') 28 | 29 | return map 30 | -------------------------------------------------------------------------------- /tests/test_webapps/filestotest/test_mako.html: -------------------------------------------------------------------------------- 1 | <% 2 | from datetime import datetime 3 | mytime = datetime.now() 4 | %> 5 | 6 | Hi everyone! 7 | 8 | The time is ${mytime} 9 | -------------------------------------------------------------------------------- /tests/test_webapps/filestotest/test_sqlalchemy.html: -------------------------------------------------------------------------------- 1 | foos = ${c.foos} 2 | -------------------------------------------------------------------------------- /tests/test_webapps/filestotest/testgenshi.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Hello from Genshi 6 | 7 | 8 |

Hello from Genshi

9 |

You visited the URL ${request.url} at ${datetime.datetime.now()}

10 |

${c.test}

11 | 12 | 13 | -------------------------------------------------------------------------------- /tests/test_webapps/filestotest/testjinja2.html: -------------------------------------------------------------------------------- 1 | #import datetime 2 | 3 | 4 | Hello from Jinja2 5 | 6 | 7 |

Hello from Jinja2

8 |

You visited the URL {{ request.url }} at {{ c.now() }}

9 |

{{ c.test }}

10 | 11 | 12 | -------------------------------------------------------------------------------- /tests/test_webapps/filestotest/tests__init__.py: -------------------------------------------------------------------------------- 1 | """Pylons application test package 2 | 3 | This package assumes the Pylons environment is already loaded, such as 4 | when this script is imported from the `nosetests --with-pylons=test.ini` 5 | command. 6 | 7 | This module initializes the application via ``websetup`` (`paster 8 | setup-app`) and provides the base testing objects. 9 | """ 10 | from unittest import TestCase 11 | 12 | from paste.deploy import loadapp 13 | from paste.script.appinstall import SetupCommand 14 | from pylons import url 15 | from routes.util import URLGenerator 16 | from webtest import TestApp 17 | 18 | import pylons.test 19 | 20 | __all__ = ['environ', 'url', 'TestController'] 21 | 22 | try: 23 | from sqlalchemy import engine_from_config 24 | from projectname.model.meta import Session, Base 25 | from projectname.model import Foo, init_model 26 | SQLAtesting = True 27 | except: 28 | SQLAtesting = False 29 | 30 | import os 31 | import pylons 32 | from pylons.i18n.translation import _get_translator 33 | 34 | from paste.deploy import appconfig 35 | from projectname.config.environment import load_environment 36 | 37 | here_dir = os.path.dirname(__file__) 38 | conf_dir = os.path.dirname(os.path.dirname(here_dir)) 39 | 40 | test_file = os.path.join(conf_dir, 'test.ini') 41 | conf = appconfig('config:' + test_file) 42 | config = load_environment(conf.global_conf, conf.local_conf) 43 | 44 | if SQLAtesting: 45 | engine = engine_from_config(config, 'sqlalchemy.') 46 | init_model(engine) 47 | 48 | # Invoke websetup with the current config file 49 | SetupCommand('setup-app').run([test_file]) 50 | 51 | environ = {} 52 | 53 | class TestController(TestCase): 54 | def __init__(self, *args, **kwargs): 55 | wsgiapp = loadapp('config:test.ini', relative_to=conf_dir) 56 | config = wsgiapp.config 57 | pylons.app_globals._push_object(config['pylons.app_globals']) 58 | pylons.config._push_object(config) 59 | 60 | # Initialize a translator for tests that utilize i18n 61 | translator = _get_translator(pylons.config.get('lang')) 62 | pylons.translator._push_object(translator) 63 | 64 | url._push_object(URLGenerator(config['routes.map'], environ)) 65 | self.app = TestApp(wsgiapp) 66 | TestCase.__init__(self, *args, **kwargs) 67 | -------------------------------------------------------------------------------- /tests/test_webapps/filestotest/websetup.py: -------------------------------------------------------------------------------- 1 | """Setup the projectname application""" 2 | import logging 3 | 4 | import pylons.test 5 | 6 | from projectname.config.environment import load_environment 7 | from projectname.model.meta import Session, Base 8 | from projectname.model import Foo 9 | from sqlalchemy import engine_from_config 10 | 11 | log = logging.getLogger(__name__) 12 | 13 | def setup_app(command, conf, vars): 14 | """Place any commands to setup projectname here""" 15 | config = load_environment(conf.global_conf, conf.local_conf) 16 | # Create the tables if they don't already exist 17 | Base.metadata.create_all(bind=Session.bind) 18 | --------------------------------------------------------------------------------