[pypy-commit] benchmarks chameleon: update mako to 1.1.0
mattip
pypy.commits at gmail.com
Thu Jan 2 08:19:36 EST 2020
Author: Matti Picus <matti.picus at gmail.com>
Branch: chameleon
Changeset: r393:2de33258aedc
Date: 2020-01-01 08:27 +0200
http://bitbucket.org/pypy/benchmarks/changeset/2de33258aedc/
Log: update mako to 1.1.0
diff too long, truncating to 2000 out of 23245 lines
diff --git a/lib/mako/CHANGES b/lib/mako/CHANGES
--- a/lib/mako/CHANGES
+++ b/lib/mako/CHANGES
@@ -1,590 +1,15 @@
-0.3.6
-- Documentation is on Sphinx.
- [ticket:126]
+=====
+MOVED
+=====
-- Beaker is now part of "extras" in
- setup.py instead of "install_requires".
- This to produce a lighter weight install
- for those who don't use the caching
- as well as to conform to Pyramid
- deployment practices. [ticket:154]
+Please see:
-- The Beaker import (or attempt thereof)
- is delayed until actually needed;
- this to remove the performance penalty
- from startup, particularly for
- "single execution" environments
- such as shell scripts. [ticket:153]
+ /docs/changelog.html
-- Patch to lexer to not generate an empty
- '' write in the case of backslash-ended
- lines. [ticket:155]
-
-- Fixed missing **extra collection in
- setup.py which prevented setup.py
- from running 2to3 on install.
- [ticket:148]
-
-- New flag on Template, TemplateLookup -
- strict_undefined=True, will cause
- variables not found in the context to
- raise a NameError immediately, instead of
- defaulting to the UNDEFINED value.
+ /docs/build/changelog.rst
-- The range of Python identifiers that
- are considered "undefined", meaning they
- are pulled from the context, has been
- trimmed back to not include variables
- declared inside of expressions (i.e. from
- list comprehensions), as well as
- in the argument list of lambdas. This
- to better support the strict_undefined
- feature. The change should be
- fully backwards-compatible but involved
- a little bit of tinkering in the AST code,
- which hadn't really been touched for
- a couple of years, just FYI.
-
-0.3.5
-- The <%namespace> tag allows expressions
- for the `file` argument, i.e. with ${}.
- The `context` variable, if needed,
- must be referenced explicitly.
- [ticket:141]
+or
-- ${} expressions embedded in tags,
- such as <%foo:bar x="${...}">, now
- allow multiline Python expressions.
-
-- Fixed previously non-covered regular
- expression, such that using a ${} expression
- inside of a tag element that doesn't allow
- them raises a CompileException instead of
- silently failing.
+ https://docs.makotemplates.org/en/latest/changelog.html
-- Added a try/except around "import markupsafe".
- This to support GAE which can't run markupsafe.
- [ticket:151] No idea whatsoever if the
- install_requires in setup.py also breaks GAE,
- couldn't get an answer on this.
-
-0.3.4
-- Now using MarkupSafe for HTML escaping,
- i.e. in place of cgi.escape(). Faster
- C-based implementation and also escapes
- single quotes for additional security.
- Supports the __html__ attribute for
- the given expression as well.
-
- When using "disable_unicode" mode,
- a pure Python HTML escaper function
- is used which also quotes single quotes.
-
- Note that Pylons by default doesn't
- use Mako's filter - check your
- environment.py file.
-
-- Fixed call to "unicode.strip" in
- exceptions.text_error_template which
- is not Py3k compatible. [ticket:137]
-
-0.3.3
-- Added conditional to RichTraceback
- such that if no traceback is passed
- and sys.exc_info() has been reset,
- the formatter just returns blank
- for the "traceback" portion.
- [ticket:135]
-
-- Fixed sometimes incorrect usage of
- exc.__class__.__name__
- in html/text error templates when using
- Python 2.4 [ticket:131]
-
-- Fixed broken @property decorator on
- template.last_modified
-
-- Fixed error formatting when a stacktrace
- line contains no line number, as in when
- inside an eval/exec-generated function.
- [ticket:132]
-
-- When a .py is being created, the tempfile
- where the source is stored temporarily is
- now made in the same directory as that of
- the .py file. This ensures that the two
- files share the same filesystem, thus
- avoiding cross-filesystem synchronization
- issues. Thanks to Charles Cazabon.
-
-0.3.2
-- Calling a def from the top, via
- template.get_def(...).render() now checks the
- argument signature the same way as it did in
- 0.2.5, so that TypeError is not raised.
- reopen of [ticket:116]
-
-
-0.3.1
-- Fixed incorrect dir name in setup.py
- [ticket:129]
-
-0.3
-- Python 2.3 support is dropped. [ticket:123]
-
-- Python 3 support is added ! See README.py3k
- for installation and testing notes.
- [ticket:119]
-
-- Unit tests now run with nose. [ticket:127]
-
-- Source code escaping has been simplified.
- In particular, module source files are now
- generated with the Python "magic encoding
- comment", and source code is passed through
- mostly unescaped, except for that code which
- is regenerated from parsed Python source.
- This fixes usage of unicode in
- <%namespace:defname> tags. [ticket:99]
-
-- RichTraceback(), html_error_template().render(),
- text_error_template().render() now accept "error"
- and "traceback" as optional arguments, and
- these are now actually used. [ticket:122]
-
-- The exception output generated when
- format_exceptions=True will now be as a Python
- unicode if it occurred during render_unicode(),
- or an encoded string if during render().
-
-- A percent sign can be emitted as the first
- non-whitespace character on a line by escaping
- it as in "%%". [ticket:112]
-
-- Template accepts empty control structure, i.e.
- % if: %endif, etc. [ticket:94]
-
-- The <%page args> tag can now be used in a base
- inheriting template - the full set of render()
- arguments are passed down through the inherits
- chain. Undeclared arguments go into **pageargs
- as usual. [ticket:116]
-
-- defs declared within a <%namespace> section, an
- uncommon feature, have been improved. The defs
- no longer get doubly-rendered in the body() scope,
- and now allow local variable assignment without
- breakage. [ticket:109]
-
-- Windows paths are handled correctly if a Template
- is passed only an absolute filename (i.e. with c:
- drive etc.) and no URI - the URI is converted
- to a forward-slash path and module_directory
- is treated as a windows path. [ticket:128]
-
-- TemplateLookup raises TopLevelLookupException for
- a given path that is a directory, not a filename,
- instead of passing through to the template to
- generate IOError. [ticket:73]
-
-0.2.6
-
-- Fix mako function decorators to preserve the
- original function's name in all cases. Patch
- from Scott Torborg.
-
-- Support the <%namespacename:defname> syntax in
- the babel extractor. [ticket:118]
-
-- Further fixes to unicode handling of .py files with the
- html_error_template. [ticket:88]
-
-0.2.5
-- Added a "decorator" kw argument to <%def>,
- allows custom decoration functions to wrap
- rendering callables. Mainly intended for
- custom caching algorithms, not sure what
- other uses there may be (but there may be).
- Examples are in the "filtering" docs.
-
-- When Mako creates subdirectories in which
- to store templates, it uses the more
- permissive mode of 0775 instead of 0750,
- helping out with certain multi-process
- scenarios. Note that the mode is always
- subject to the restrictions of the existing
- umask. [ticket:101]
-
-- Fixed namespace.__getattr__() to raise
- AttributeError on attribute not found
- instead of RuntimeError. [ticket:104]
-
-- Added last_modified accessor to Template,
- returns the time.time() when the module
- was created. [ticket:97]
-
-- Fixed lexing support for whitespace
- around '=' sign in defs. [ticket:102]
-
-- Removed errant "lower()" in the lexer which
- was causing tags to compile with
- case-insensitive names, thus messing up
- custom <%call> names. [ticket:108]
-
-- added "mako.__version__" attribute to
- the base module. [ticket:110]
-
-0.2.4
-- Fixed compatibility with Jython 2.5b1.
-
-0.2.3
-- the <%namespacename:defname> syntax described at
- http://techspot.zzzeek.org/?p=28 has now
- been added as a built in syntax, and is recommended
- as a more modern syntax versus <%call expr="expression">.
- The %call tag itself will always remain,
- with <%namespacename:defname> presenting a more HTML-like
- alternative to calling defs, both plain and
- nested. Many examples of the new syntax are in the
- "Calling a def with embedded content" section
- of the docs.
-
-- added support for Jython 2.5.
-
-- cache module now uses Beaker's CacheManager
- object directly, so that all cache types are included.
- memcached is available as both "ext:memcached" and
- "memcached", the latter for backwards compatibility.
-
-- added "cache" accessor to Template, Namespace.
- e.g. ${local.cache.get('somekey')} or
- template.cache.invalidate_body()
-
-- added "cache_enabled=True" flag to Template,
- TemplateLookup. Setting this to False causes cache
- operations to "pass through" and execute every time;
- this flag should be integrated in Pylons with its own
- cache_enabled configuration setting.
-
-- the Cache object now supports invalidate_def(name),
- invalidate_body(), invalidate_closure(name),
- invalidate(key), which will remove the given key
- from the cache, if it exists. The cache arguments
- (i.e. storage type) are derived from whatever has
- been already persisted for that template.
- [ticket:92]
-
-- For cache changes to work fully, Beaker 1.1 is required.
- 1.0.1 and up will work as well with the exception of
- cache expiry. Note that Beaker 1.1 is **required**
- for applications which use dynamically generated keys,
- since previous versions will permanently store state in memory
- for each individual key, thus consuming all available
- memory for an arbitrarily large number of distinct
- keys.
-
-- fixed bug whereby an <%included> template with
- <%page> args named the same as a __builtin__ would not
- honor the default value specified in <%page> [ticket:93]
-
-- fixed the html_error_template not handling tracebacks from
- normal .py files with a magic encoding comment [ticket:88]
-
-- RichTraceback() now accepts an optional traceback object
- to be used in place of sys.exc_info()[2]. html_error_template()
- and text_error_template() accept an optional
- render()-time argument "traceback" which is passed to the
- RichTraceback object.
-
-- added ModuleTemplate class, which allows the construction
- of a Template given a Python module generated by a previous
- Template. This allows Python modules alone to be used
- as templates with no compilation step. Source code
- and template source are optional but allow error reporting
- to work correctly.
-
-- fixed Python 2.3 compat. in mako.pyparser [ticket:90]
-
-- fix Babel 0.9.3 compatibility; stripping comment tags is now
- optional (and enabled by default).
-
-
-0.2.2
-- cached blocks now use the current context when rendering
-an expired section, instead of the original context
-passed in [ticket:87]
-- fixed a critical issue regarding caching, whereby
-a cached block would raise an error when called within a
-cache-refresh operation that was initiated after the
-initiating template had completed rendering.
-
-0.2.1
-- fixed bug where 'output_encoding' parameter would prevent
-render_unicode() from returning a unicode object.
-- bumped magic number, which forces template recompile for
-this version (fixes incompatible compile symbols from 0.1
-series).
-- added a few docs for cache options, specifically those that
-help with memcached.
-
-0.2.0
-- Speed improvements (as though we needed them, but people
- contributed and there you go):
-
- - added "bytestring passthru" mode, via
- `disable_unicode=True` argument passed to Template or
- TemplateLookup. All unicode-awareness and filtering is
- turned off, and template modules are generated with
- the appropriate magic encoding comment. In this mode,
- template expressions can only receive raw bytestrings
- or Unicode objects which represent straight ASCII, and
- render_unicode() may not be used if multibyte
- characters are present. When enabled, speed
- improvement around 10-20%. [ticket:77] (courtesy
- anonymous guest)
-
- - inlined the "write" function of Context into a local
- template variable. This affords a 12-30% speedup in
- template render time. (idea courtesy same anonymous
- guest) [ticket:76]
-
-- New Features, API changes:
-
- - added "attr" accessor to namespaces. Returns
- attributes configured as module level attributes, i.e.
- within <%! %> sections. [ticket:62] i.e.:
-
- # somefile.html
- <%!
- foo = 27
- %>
-
- # some other template
- <%namespace name="myns" file="somefile.html"/>
- ${myns.attr.foo}
-
- The slight backwards incompatibility here is, you
- can't have namespace defs named "attr" since the
- "attr" descriptor will occlude it.
-
- - cache_key argument can now render arguments passed
- directly to the %page or %def, i.e. <%def
- name="foo(x)" cached="True" cache_key="${x}"/>
- [ticket:78]
-
- - some functions on Context are now private:
- _push_buffer(), _pop_buffer(),
- caller_stack._push_frame(), caller_stack._pop_frame().
-
- - added a runner script "mako-render" which renders
- standard input as a template to stdout [ticket:81]
- [ticket:56]
-
-- Bugfixes:
- - can now use most names from __builtins__ as variable
- names without explicit declaration (i.e. 'id',
- 'exception', 'range', etc.) [ticket:83] [ticket:84]
-
- - can also use builtin names as local variable names
- (i.e. dict, locals) (came from fix for [ticket:84])
-
- - fixed bug in python generation when variable names are
- used with identifiers like "else", "finally", etc.
- inside them [ticket:68]
-
- - fixed codegen bug which occured when using <%page>
- level caching, combined with an expression-based
- cache_key, combined with the usage of <%namespace
- import="*"/> - fixed lexer exceptions not cleaning up
- temporary files, which could lead to a maximum number
- of file descriptors used in the process [ticket:69]
-
- - fixed issue with inline format_exceptions that was
- producing blank exception pages when an inheriting
- template is present [ticket:71]
-
- - format_exceptions will apply the encoding options of
- html_error_template() to the buffered output
-
- - rewrote the "whitespace adjuster" function to work
- with more elaborate combinations of quotes and
- comments [ticket:75]
-
-0.1.10
-- fixed propagation of 'caller' such that nested %def calls
- within a <%call> tag's argument list propigates 'caller'
- to the %call function itself (propigates to the inner
- calls too, this is a slight side effect which previously
- existed anyway)
-- fixed bug where local.get_namespace() could put an
- incorrect "self" in the current context
-- fixed another namespace bug where the namespace functions
- did not have access to the correct context containing
- their 'self' and 'parent'
-
-0.1.9
-- filters.Decode filter can also accept a non-basestring
-object and will call str() + unicode() on it [ticket:47]
-- comments can be placed at the end of control lines,
-i.e. if foo: # a comment, [ticket:53], thanks to
-Paul Colomiets
-- fixed expressions and page tag arguments and with embedded
-newlines in CRLF templates, follow up to [ticket:16], thanks
-Eric Woroshow
-- added an IOError catch for source file not found in RichTraceback
-exception reporter [ticket:51]
-
-0.1.8
-- variable names declared in render methods by internal
-codegen prefixed by "__M_" to prevent name collisions
-with user code
-- added a Babel (http://babel.edgewall.org/) extractor entry
-point, allowing extraction of gettext messages directly from
-mako templates via Babel [ticket:45]
-- fix to turbogears plugin to work with dot-separated names
-(i.e. load_template('foo.bar')). also takes file extension
-as a keyword argument (default is 'mak').
-- more tg fix: fixed [ticket:35], allowing string-based
-templates with tgplugin even if non-compatible args were sent
-
-0.1.7
-- one small fix to the unit tests to support python 2.3
-- a slight hack to how cache.py detects Beaker's memcached,
-works around unexplained import behavior observed on some
-python 2.3 installations
-
-0.1.6
-- caching is now supplied directly by Beaker, which has
- all of MyghtyUtils merged into it now. The latest Beaker
- (0.7.1) also fixes a bug related to how Mako was using the
- cache API.
-- fix to module_directory path generation when the path is "./"
- [ticket:34]
-- TGPlugin passes options to string-based templates [ticket:35]
-- added an explicit stack frame step to template runtime, which
- allows much simpler and hopefully bug-free tracking of 'caller',
- fixes #28
-- if plain Python defs are used with <%call>, a decorator
- @runtime.supports_callable exists to ensure that the "caller"
- stack is properly handled for the def.
-- fix to RichTraceback and exception reporting to get template
- source code as a unicode object #37
-- html_error_template includes options "full=True", "css=True"
- which control generation of HTML tags, CSS [ticket:39]
-- added the 'encoding_errors' parameter to Template/TemplateLookup
- for specifying the error handler associated with encoding to
- 'output_encoding' [ticket:40]
-- the Template returned by html_error_template now defaults to
- output_encoding=sys.getdefaultencoding(),
- encoding_errors='htmlentityreplace' [ticket:37]
-- control lines, i.e. % lines, support backslashes to continue long
- lines (#32)
-- fixed codegen bug when defining <%def> within <%call> within <%call>
-- leading utf-8 BOM in template files is honored according to pep-0263
-
-0.1.5
-- AST expression generation - added in just about everything
- expression-wise from the AST module [ticket:26]
-- AST parsing, properly detects imports of the form "import foo.bar"
- [ticket:27]
-- fix to lexing of <%docs> tag nested in other tags
-- fix to context-arguments inside of <%include> tag which broke
-during 0.1.4 [ticket:29]
-- added "n" filter, disables *all* filters normally applied to an expression
-via <%page> or default_filters (but not those within the filter)
-- added buffer_filters argument, defines filters applied to the return value
-of buffered/cached/filtered %defs, after all filters defined with the %def
-itself have been applied. allows the creation of default expression filters
-that let the output of return-valued %defs "opt out" of that filtering
-via passing special attributes or objects.
-
-0.1.4
-- got defs-within-defs to be cacheable
-- fixes to code parsing/whitespace adjusting where plain python comments
- may contain quote characters [ticket:23]
-- fix to variable scoping for identifiers only referenced within
- functions
-- added a path normalization step to lookup so URIs like
- "/foo/bar/../etc/../foo" pre-process the ".." tokens before checking
- the filesystem
-- fixed/improved "caller" semantics so that undefined caller is
- "UNDEFINED", propigates __nonzero__ method so it evaulates to False if
- not present, True otherwise. this way you can say % if caller:\n
- ${caller.body()}\n% endif
-- <%include> has an "args" attribute that can pass arguments to the
- called template (keyword arguments only, must be declared in that
- page's <%page> tag.)
-- <%include> plus arguments is also programmatically available via
- self.include_file(<filename>, **kwargs)
-- further escaping added for multibyte expressions in %def, %call
- attributes [ticket:24]
-
-
-0.1.3
-- ***Small Syntax Change*** - the single line comment character is now
-*two* hash signs, i.e. "## this is a comment". This avoids a common
-collection with CSS selectors.
-- the magic "coding" comment (i.e. # coding:utf-8) will still work with
-either one "#" sign or two for now; two is preferred going forward, i.e.
-## coding:<someencoding>.
-- new multiline comment form: "<%doc> a comment </%doc>"
-- UNDEFINED evaluates to False
-- improvement to scoping of "caller" variable when using <%call> tag
-- added lexer error for unclosed control-line (%) line
-- added "preprocessor" argument to Template, TemplateLookup - is a single
- callable or list of callables which will be applied to the template text
- before lexing. given the text as an argument, returns the new text.
-- added mako.ext.preprocessors package, contains one preprocessor so far:
- 'convert_comments', which will convert single # comments to the new ##
- format
-
-0.1.2
-- fix to parsing of code/expression blocks to insure that non-ascii
- characters, combined with a template that indicates a non-standard
- encoding, are expanded into backslash-escaped glyphs before being AST
- parsed [ticket:11]
-- all template lexing converts the template to unicode first, to
- immediately catch any encoding issues and ensure internal unicode
- representation.
-- added module_filename argument to Template to allow specification of a
- specific module file
-- added modulename_callable to TemplateLookup to allow a function to
- determine module filenames (takes filename, uri arguments). used for
- [ticket:14]
-- added optional input_encoding flag to Template, to allow sending a
- unicode() object with no magic encoding comment
-- "expression_filter" argument in <%page> applies only to expressions
-- added "default_filters" argument to Template, TemplateLookup. applies only
- to expressions, gets prepended to "expression_filter" arg from <%page>.
- defaults to ["unicode"], so that all expressions get stringified into u''
- by default (this is what Mako already does). By setting to [], expressions
- are passed through raw.
-- added "imports" argument to Template, TemplateLookup. so you can predefine
- a list of import statements at the top of the template. can be used in
- conjunction with default_filters.
-- support for CRLF templates...whoops ! welcome to all the windows users.
- [ticket:16]
-- small fix to local variable propigation for locals that are conditionally
- declared
-- got "top level" def calls to work, i.e. template.get_def("somedef").render()
-
-0.1.1
-- buffet plugin supports string-based templates, allows ToscaWidgets to work
- [ticket:8]
-- AST parsing fixes: fixed TryExcept identifier parsing
-- removed textmate tmbundle from contrib and into separate SVN location;
- windows users cant handle those files, setuptools not very good at
- "pruning" certain directories
-- fix so that "cache_timeout" parameter is propigated
-- fix to expression filters so that string conversion (actually unicode)
- properly occurs before filtering
-- better error message when a lookup is attempted with a template that has no
- lookup
-- implemented "module" attribute for namespace
-- fix to code generation to correctly track multiple defs with the same name
-- "directories" can be passed to TemplateLookup as a scalar in which case it
- gets converted to a list [ticket:9]
-
-0.1.0
-
-Initial release.
+for the current CHANGES.
diff --git a/lib/mako/LICENSE b/lib/mako/LICENSE
--- a/lib/mako/LICENSE
+++ b/lib/mako/LICENSE
@@ -1,20 +1,19 @@
-This is the MIT license: http://www.opensource.org/licenses/mit-license.php
+Copyright 2006-2019 the Mako authors and contributors <see AUTHORS file>.
-Copyright (C) 2006, 2007, 2008, 2009, 2010 Michael Bayer and contributors.
-Mako is a trademark of Michael Bayer.
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+of the Software, and to permit persons to whom the Software is furnished to do
+so, subject to the following conditions:
-Permission is hereby granted, free of charge, to any person obtaining a copy of this
-software and associated documentation files (the "Software"), to deal in the Software
-without restriction, including without limitation the rights to use, copy, modify, merge,
-publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
-to whom the Software is furnished to do so, subject to the following conditions:
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
-The above copyright notice and this permission notice shall be included in all copies or
-substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
-INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
-PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
-FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
-OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-DEALINGS IN THE SOFTWARE.
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
\ No newline at end of file
diff --git a/lib/mako/MANIFEST.in b/lib/mako/MANIFEST.in
--- a/lib/mako/MANIFEST.in
+++ b/lib/mako/MANIFEST.in
@@ -1,12 +1,8 @@
-# any kind of "*" pulls in __init__.pyc files,
-# so all extensions are explicit.
+recursive-include doc *.html *.css *.txt *.js *.png *.py Makefile *.rst *.mako
+recursive-include examples *.py *.xml *.mako *.myt *.kid *.tmpl
+recursive-include test *.py *.html *.mako
-recursive-include doc *.html *.css *.txt *.js *.jpg *.png *.py Makefile *.rst *.mako *.sty autohandler
-recursive-include examples *.py *.xml *.mako *.myt *.kid *.tmpl
-recursive-include test *.py *.dat *.html *.mako
+include README* AUTHORS LICENSE CHANGES* tox.ini
-include README* LICENSE distribute_setup.py ez_setup.py CHANGES*
+prune doc/build/output
-# when we go to sphinx
-#prune doc/build/output
-
diff --git a/lib/mako/README.rst b/lib/mako/README.rst
new file mode 100644
--- /dev/null
+++ b/lib/mako/README.rst
@@ -0,0 +1,52 @@
+=========================
+Mako Templates for Python
+=========================
+
+Mako is a template library written in Python. It provides a familiar, non-XML
+syntax which compiles into Python modules for maximum performance. Mako's
+syntax and API borrows from the best ideas of many others, including Django
+templates, Cheetah, Myghty, and Genshi. Conceptually, Mako is an embedded
+Python (i.e. Python Server Page) language, which refines the familiar ideas
+of componentized layout and inheritance to produce one of the most
+straightforward and flexible models available, while also maintaining close
+ties to Python calling and scoping semantics.
+
+Nutshell
+========
+
+::
+
+ <%inherit file="base.html"/>
+ <%
+ rows = [[v for v in range(0,10)] for row in range(0,10)]
+ %>
+ <table>
+ % for row in rows:
+ ${makerow(row)}
+ % endfor
+ </table>
+
+ <%def name="makerow(row)">
+ <tr>
+ % for name in row:
+ <td>${name}</td>\
+ % endfor
+ </tr>
+ </%def>
+
+Philosophy
+===========
+
+Python is a great scripting language. Don't reinvent the wheel...your templates can handle it !
+
+Documentation
+==============
+
+See documentation for Mako at https://docs.makotemplates.org/en/latest/
+
+License
+========
+
+Mako is licensed under an MIT-style license (see LICENSE).
+Other incorporated projects may be licensed under different licenses.
+All licenses allow for non-commercial and commercial use.
diff --git a/lib/mako/doc/build/Makefile b/lib/mako/doc/build/Makefile
deleted file mode 100644
--- a/lib/mako/doc/build/Makefile
+++ /dev/null
@@ -1,143 +0,0 @@
-# Makefile for Sphinx documentation
-#
-
-# You can set these variables from the command line.
-SPHINXOPTS =
-SPHINXBUILD = sphinx-build
-PAPER =
-BUILDDIR = output
-
-# Internal variables.
-PAPEROPT_a4 = -D latex_paper_size=a4
-PAPEROPT_letter = -D latex_paper_size=letter
-ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
-
-.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest dist-html site-mako
-
-help:
- @echo "Please use \`make <target>' where <target> is one of"
- @echo " html to make standalone HTML files"
- @echo " dist-html same as html, but places files in /doc"
- @echo " site-mako build Mako files for usage on the Mako site"
- @echo " dirhtml to make HTML files named index.html in directories"
- @echo " singlehtml to make a single large HTML file"
- @echo " pickle to make pickle files"
- @echo " json to make JSON files"
- @echo " htmlhelp to make HTML files and a HTML help project"
- @echo " qthelp to make HTML files and a qthelp project"
- @echo " devhelp to make HTML files and a Devhelp project"
- @echo " epub to make an epub"
- @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
- @echo " latexpdf to make LaTeX files and run them through pdflatex"
- @echo " text to make text files"
- @echo " man to make manual pages"
- @echo " changes to make an overview of all changed/added/deprecated items"
- @echo " linkcheck to check all external links for integrity"
- @echo " doctest to run all doctests embedded in the documentation (if enabled)"
-
-clean:
- -rm -rf $(BUILDDIR)/*
-
-html:
- $(SPHINXBUILD) -b html -A mako_layout=html $(ALLSPHINXOPTS) $(BUILDDIR)/html
- @echo
- @echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
-
-dist-html:
- $(SPHINXBUILD) -b html -A mako_layout=html $(ALLSPHINXOPTS) ..
- @echo
- @echo "Build finished. The HTML pages are in ../."
-
-site-mako:
- $(SPHINXBUILD) -b html -A mako_layout=site $(ALLSPHINXOPTS) $(BUILDDIR)/site
- @echo
- @echo "Build finished. The Mako pages are in $(BUILDDIR)/site."
-
-dirhtml:
- $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
- @echo
- @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
-
-singlehtml:
- $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
- @echo
- @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
-
-pickle:
- $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
- @echo
- @echo "Build finished; now you can process the pickle files."
-
-json:
- $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
- @echo
- @echo "Build finished; now you can process the JSON files."
-
-htmlhelp:
- $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
- @echo
- @echo "Build finished; now you can run HTML Help Workshop with the" \
- ".hhp project file in $(BUILDDIR)/htmlhelp."
-
-qthelp:
- $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
- @echo
- @echo "Build finished; now you can run "qcollectiongenerator" with the" \
- ".qhcp project file in $(BUILDDIR)/qthelp, like this:"
- @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/SQLAlchemy.qhcp"
- @echo "To view the help file:"
- @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/SQLAlchemy.qhc"
-
-devhelp:
- $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
- @echo
- @echo "Build finished."
- @echo "To view the help file:"
- @echo "# mkdir -p $$HOME/.local/share/devhelp/SQLAlchemy"
- @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/SQLAlchemy"
- @echo "# devhelp"
-
-epub:
- $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
- @echo
- @echo "Build finished. The epub file is in $(BUILDDIR)/epub."
-
-latex:
- $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
- cp texinputs/* $(BUILDDIR)/latex/
- @echo
- @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
- @echo "Run \`make' in that directory to run these through (pdf)latex" \
- "(use \`make latexpdf' here to do that automatically)."
-
-latexpdf:
- $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
- @echo "Running LaTeX files through pdflatex..."
- make -C $(BUILDDIR)/latex all-pdf
- @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
-
-text:
- $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
- @echo
- @echo "Build finished. The text files are in $(BUILDDIR)/text."
-
-man:
- $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
- @echo
- @echo "Build finished. The manual pages are in $(BUILDDIR)/man."
-
-changes:
- $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
- @echo
- @echo "The overview file is in $(BUILDDIR)/changes."
-
-linkcheck:
- $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
- @echo
- @echo "Link check complete; look for any errors in the above output " \
- "or in $(BUILDDIR)/linkcheck/output.txt."
-
-doctest:
- $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) .
- @echo "Testing of doctests in the sources finished, look at the " \
- "results in $(BUILDDIR)/doctest/output.txt."
diff --git a/lib/mako/doc/build/caching.rst b/lib/mako/doc/build/caching.rst
deleted file mode 100644
--- a/lib/mako/doc/build/caching.rst
+++ /dev/null
@@ -1,127 +0,0 @@
-.. _caching_toplevel:
-
-========
-Caching
-========
-
-Any template or component can be cached using the ``cache``
-argument to the ``<%page>`` or ``<%def>`` directives:
-
-.. sourcecode:: mako
-
- <%page cached="True"/>
-
- template text
-
-The above template, after being executed the first time, will
-store its content within a cache that by default is scoped
-within memory. Subsequent calls to the template's :meth:`~.Template.render`
-method will return content directly from the cache. When the
-:class:`.Template` object itself falls out of scope, its corresponding
-cache is garbage collected along with the template.
-
-Caching requires that the ``beaker`` package be installed on the
-system.
-
-The caching flag and all its options can be used with the
-``<%def>`` tag.
-
-.. sourcecode:: mako
-
- <%def name="mycomp" cached="True" cache_timeout="30" cache_type="memory">
- other text
- </%def>
-
-Cache arguments
-================
-
-The various cache arguments are cascaded from their default
-values, to the arguments specified programmatically to the
-:class:`.Template` or its originating :class:`.TemplateLookup`, then to those
-defined in the ``<%page>`` tag of an individual template, and
-finally to an individual ``<%def>`` tag within the template. This
-means you can define, for example, a cache type of ``dbm`` on your
-:class:`.TemplateLookup`, a cache timeout of 60 seconds in a particular
-template's ``<%page>`` tag, and within one of that template's
-``<%def>`` tags ``cache=True``, and that one particular def will
-then cache its data using a ``dbm`` cache and a data timeout of 60
-seconds.
-
-The options available are:
-
-* ``cached="False|True"`` - turn caching on
-* ``cache_timeout`` - number of seconds in which to invalidate the
- cached data. after this timeout, the content is re-generated
- on the next call.
-* ``cache_type`` - type of caching. ``memory``, ``file``, ``dbm``, or
- ``memcached``.
-* ``cache_url`` - (only used for ``memcached`` but required) a single
- IP address or a semi-colon separated list of IP address of
- memcache servers to use.
-* ``cache_dir`` - In the case of the ``file`` and ``dbm`` cache types,
- this is the filesystem directory with which to store data
- files. If this option is not present, the value of
- ``module_directory`` is used (i.e. the directory where compiled
- template modules are stored). If neither option is available
- an exception is thrown.
-
- In the case of the ``memcached`` type, this attribute is required
- and it's used to store the lock files.
-* ``cache_key`` - the "key" used to uniquely identify this content
- in the cache. the total namespace of keys within the cache is
- local to the current template, and the default value of "key"
- is the name of the def which is storing its data. It is an
- evaluable tag, so you can put a Python expression to calculate
- the value of the key on the fly. For example, heres a page
- that caches any page which inherits from it, based on the
- filename of the calling template:
-
-.. sourcecode:: mako
-
- <%page cached="True" cache_key="${self.filename}"/>
-
- ${next.body()}
-
- ## rest of template
-
-Accessing the Cache
-===================
-
-The :class:`.Template`, as well as any template-derived namespace, has
-an accessor called ``cache`` which returns the ``Cache`` object
-for that template. This object is a facade on top of the Beaker
-internal cache object, and provides some very rudimental
-capabilities, such as the ability to get and put arbitrary
-values:
-
-.. sourcecode:: mako
-
- <%
- local.cache.put("somekey", type="memory", "somevalue")
- %>
-
-Above, the cache associated with the ``local`` namespace is
-accessed and a key is placed within a memory cache.
-
-More commonly the ``cache`` object is used to invalidate cached
-sections programmatically:
-
-.. sourcecode:: python
-
- template = lookup.get_template('/sometemplate.html')
-
- # invalidate the "body" of the template
- template.cache.invalidate_body()
-
- # invalidate an individual def
- template.cache.invalidate_def('somedef')
-
- # invalidate an arbitrary key
- template.cache.invalidate('somekey')
-
-API Reference
-==============
-
-.. autoclass:: mako.cache.Cache
- :members:
- :show-inheritance:
\ No newline at end of file
diff --git a/lib/mako/doc/build/conf.py b/lib/mako/doc/build/conf.py
deleted file mode 100644
--- a/lib/mako/doc/build/conf.py
+++ /dev/null
@@ -1,280 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# Mako documentation build configuration file
-#
-# This file is execfile()d with the current directory set to its containing dir.
-#
-# Note that not all possible configuration values are present in this
-# autogenerated file.
-#
-# All configuration values have a default; values that are commented out
-# serve to show the default.
-
-import sys, os
-
-# If extensions (or modules to document with autodoc) are in another directory,
-# add these directories to sys.path here. If the directory is relative to the
-# documentation root, use os.path.abspath to make it absolute, like shown here.
-sys.path.insert(0, os.path.abspath('../..'))
-sys.path.insert(0, os.path.abspath('.'))
-
-import mako
-
-# -- General configuration -----------------------------------------------------
-
-# If your documentation needs a minimal Sphinx version, state it here.
-#needs_sphinx = '1.0'
-
-# Add any Sphinx extension module names here, as strings. They can be extensions
-# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
-#extensions = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode',
-# 'sphinx.ext.doctest', 'builder.builders']
-
-extensions = ['sphinx.ext.autodoc',
- 'sphinx.ext.doctest', 'builder.builders']
-
-# Add any paths that contain templates here, relative to this directory.
-templates_path = ['templates']
-
-nitpicky = True
-
-# The suffix of source filenames.
-source_suffix = '.rst'
-
-template_bridge = "builder.builders.MakoBridge"
-
-# The encoding of source files.
-#source_encoding = 'utf-8-sig'
-
-# The master toctree document.
-master_doc = 'index'
-
-# General information about the project.
-project = u'Mako'
-copyright = u'the Mako authors and contributors'
-
-# The version info for the project you're documenting, acts as replacement for
-# |version| and |release|, also used in various other places throughout the
-# built documents.
-#
-# The short X.Y version.
-version = mako.__version__
-# The full version, including alpha/beta/rc tags.
-release = mako.__version__
-
-# The language for content autogenerated by Sphinx. Refer to documentation
-# for a list of supported languages.
-#language = None
-
-# There are two options for replacing |today|: either, you set today to some
-# non-false value, then it is used:
-#today = ''
-# Else, today_fmt is used as the format for a strftime call.
-#today_fmt = '%B %d, %Y'
-
-# List of patterns, relative to source directory, that match files and
-# directories to ignore when looking for source files.
-exclude_patterns = ['build']
-
-# The reST default role (used for this markup: `text`) to use for all documents.
-#default_role = None
-
-# If true, '()' will be appended to :func: etc. cross-reference text.
-#add_function_parentheses = True
-
-# If true, the current module name will be prepended to all description
-# unit titles (such as .. function::).
-#add_module_names = True
-
-# If true, sectionauthor and moduleauthor directives will be shown in the
-# output. They are ignored by default.
-#show_authors = False
-
-# The name of the Pygments (syntax highlighting) style to use.
-pygments_style = 'sphinx'
-
-# A list of ignored prefixes for module index sorting.
-#modindex_common_prefix = []
-
-
-# -- Options for HTML output ---------------------------------------------------
-
-# The theme to use for HTML and HTML Help pages. See the documentation for
-# a list of builtin themes.
-html_theme = 'default'
-
-# Theme options are theme-specific and customize the look and feel of a theme
-# further. For a list of options available for each theme, see the
-# documentation.
-#html_theme_options = {}
-
-# Add any paths that contain custom themes here, relative to this directory.
-#html_theme_path = []
-
-# The style sheet to use for HTML and HTML Help pages. A file of that name
-# must exist either in Sphinx' static/ path, or in one of the custom paths
-# given in html_static_path.
-html_style = 'default.css'
-
-# The name for this set of Sphinx documents. If None, it defaults to
-# "<project> v<release> documentation".
-html_title = "%s %s Documentation" % (project, release)
-
-# A shorter title for the navigation bar. Default is the same as html_title.
-#html_short_title = None
-
-# The name of an image file (relative to this directory) to place at the top
-# of the sidebar.
-#html_logo = None
-
-# The name of an image file (within the static path) to use as favicon of the
-# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
-# pixels large.
-#html_favicon = None
-
-# Add any paths that contain custom static files (such as style sheets) here,
-# relative to this directory. They are copied after the builtin static files,
-# so a file named "default.css" will overwrite the builtin "default.css".
-html_static_path = ['static']
-
-# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
-# using the given strftime format.
-html_last_updated_fmt = '%m/%d/%Y %H:%M:%S'
-
-# If true, SmartyPants will be used to convert quotes and dashes to
-# typographically correct entities.
-#html_use_smartypants = True
-
-# Custom sidebar templates, maps document names to template names.
-#html_sidebars = {}
-
-# Additional templates that should be rendered to pages, maps page names to
-# template names.
-#html_additional_pages = {}
-
-# If false, no module index is generated.
-html_domain_indices = False
-
-# If false, no index is generated.
-#html_use_index = True
-
-# If true, the index is split into individual pages for each letter.
-#html_split_index = False
-
-# If true, the reST sources are included in the HTML build as _sources/<name>.
-#html_copy_source = True
-
-# If true, links to the reST sources are added to the pages.
-#html_show_sourcelink = True
-
-# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
-#html_show_sphinx = True
-
-# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
-#html_show_copyright = True
-
-# If true, an OpenSearch description file will be output, and all pages will
-# contain a <link> tag referring to it. The value of this option must be the
-# base URL from which the finished HTML is served.
-#html_use_opensearch = ''
-
-# This is the file name suffix for HTML files (e.g. ".xhtml").
-#html_file_suffix = None
-
-# Output file base name for HTML help builder.
-htmlhelp_basename = 'Makodoc'
-
-#autoclass_content = 'both'
-
-# -- Options for LaTeX output --------------------------------------------------
-
-# The paper size ('letter' or 'a4').
-#latex_paper_size = 'letter'
-
-# The font size ('10pt', '11pt' or '12pt').
-#latex_font_size = '10pt'
-
-# Grouping the document tree into LaTeX files. List of tuples
-# (source start file, target name, title, author, documentclass [howto/manual]).
-latex_documents = [
- ('index', 'mako_%s.tex' % release.replace('.', '_'), ur'Mako Documentation',
- ur'Mike Bayer', 'manual'),
-]
-
-# The name of an image file (relative to this directory) to place at the top of
-# the title page.
-#latex_logo = None
-
-# For "manual" documents, if this is true, then toplevel headings are parts,
-# not chapters.
-#latex_use_parts = False
-
-# If true, show page references after internal links.
-#latex_show_pagerefs = False
-
-# If true, show URL addresses after external links.
-#latex_show_urls = False
-
-# Additional stuff for the LaTeX preamble.
-# sets TOC depth to 2.
-latex_preamble = '\setcounter{tocdepth}{3}'
-
-# Documents to append as an appendix to all manuals.
-#latex_appendices = []
-
-# If false, no module index is generated.
-#latex_domain_indices = True
-
-#latex_elements = {
-# 'papersize': 'letterpaper',
-# 'pointsize': '10pt',
-#}
-
-# -- Options for manual page output --------------------------------------------
-
-# One entry per manual page. List of tuples
-# (source start file, name, description, authors, manual section).
-man_pages = [
- ('index', 'mako', u'Mako Documentation',
- [u'Mako authors'], 1)
-]
-
-
-# -- Options for Epub output ---------------------------------------------------
-
-# Bibliographic Dublin Core info.
-epub_title = u'Mako'
-epub_author = u'Mako authors'
-epub_publisher = u'Mako authors'
-epub_copyright = u'Mako authors'
-
-# The language of the text. It defaults to the language option
-# or en if the language is not set.
-#epub_language = ''
-
-# The scheme of the identifier. Typical schemes are ISBN or URL.
-#epub_scheme = ''
-
-# The unique identifier of the text. This can be a ISBN number
-# or the project homepage.
-#epub_identifier = ''
-
-# A unique identification for the text.
-#epub_uid = ''
-
-# HTML files that should be inserted before the pages created by sphinx.
-# The format is a list of tuples containing the path and title.
-#epub_pre_files = []
-
-# HTML files shat should be inserted after the pages created by sphinx.
-# The format is a list of tuples containing the path and title.
-#epub_post_files = []
-
-# A list of files that should not be packed into the epub file.
-#epub_exclude_files = []
-
-# The depth of the table of contents in toc.ncx.
-#epub_tocdepth = 3
-
-# Allow duplicate toc entries.
-#epub_tocdup = True
diff --git a/lib/mako/doc/build/defs.rst b/lib/mako/doc/build/defs.rst
deleted file mode 100644
--- a/lib/mako/doc/build/defs.rst
+++ /dev/null
@@ -1,436 +0,0 @@
-.. _defs_toplevel:
-
-====
-Defs
-====
-
-``<%def>`` is the single tag used to demarcate any block of text
-and/or code. It exists within generated Python as a callable
-function:
-
-.. sourcecode:: mako
-
- <%def name="hello()">
- hello world
- </%def>
-
-They are normally called as expressions:
-
-.. sourcecode:: mako
-
- the def: ${hello()}
-
-If the ``<%def>`` is not nested inside of another ``<%def>``,
-its known as a **top level def** and can be accessed anywhere in
-the template, including above where it was defined.
-
-All defs, top level or not, have access to the current
-contextual namespace in exactly the same way their containing
-template does. Suppose the template below is executed with the
-variables ``username`` and ``accountdata`` inside the context:
-
-.. sourcecode:: mako
-
- Hello there ${username}, how are ya. Lets see what your account says:
-
- ${account()}
-
- <%def name="account()">
- Account for ${username}:<br/>
-
- % for row in accountdata:
- Value: ${row}<br/>
- % endfor
- </%def>
-
-The ``username`` and ``accountdata`` variables are present
-within the main template body as well as the body of the
-``account()`` def.
-
-Since defs are just Python functions, you can define and pass
-arguments to them as well:
-
-.. sourcecode:: mako
-
- ${account(accountname='john')}
-
- <%def name="account(accountname, type='regular')">
- account name: ${accountname}, type ${type}
- </%def>
-
-When you declare an argument signature for your def, they are
-required to follow normal Python conventions (i.e., all
-arguments are required except keyword arguments with a default
-value). This is in contrast to using context-level variables,
-which evaluate to ``UNDEFINED`` if you reference a name that
-does not exist.
-
-Calling defs from Other Files
-==============================
-
-Top level ``<%defs>`` are **exported** by your template's
-module, and can be called from the outside; including from other
-templates, as well as normal Python code. Calling a ``<%def>``
-from another template is something like using an ``<%include>``
-- except you are calling a specific function within the
-template, not the whole template.
-
-The remote ``<%def>`` call is also a little bit like calling
-functions from other modules in Python. There is an "import"
-step to pull the names from another template into your own
-template; then the function or functions are available.
-
-To import another template, use the ``<%namespace>`` tag:
-
-.. sourcecode:: mako
-
- <%namespace name="mystuff" file="mystuff.html"/>
-
-The above tag adds a local variable "mystuff" to the current
-scope.
-
-Then, just call the defs off of ``mystuff``:
-
-.. sourcecode:: mako
-
- ${mystuff.somedef(x=5,y=7)}
-
-The ``<%namespace>`` tag also supports some of the other
-semantics of Python's ``import`` statement, including pulling
-names into the local variable space, or using ``*`` to represent
-all names, using the ``import`` attribute:
-
-.. sourcecode:: mako
-
- <%namespace file="mystuff.html" import="foo, bar"/>
-
-This is just a quick intro to the concept of a **namespace**,
-which is a central Mako concept that has its own chapter in
-these docs. For more detail and examples, see
-:ref:`namespaces_toplevel`.
-
-Calling defs programmatically
-==============================
-
-You can call def's programmatically from any :class:`.Template` object
-using the :meth:`~.Template.get_def()` method, which returns a :class:`.DefTemplate`
-object. This is a :class:`.Template` subclass which the parent
-:class:`.Template` creates, and is usable like any other template:
-
-.. sourcecode:: python
-
- from mako.template import Template
-
- template = Template("""
- <%def name="hi(name)">
- hi ${name}!
- </%def>
-
- <%def name="bye(name)">
- bye ${name}!
- </%def>
- """)
-
- print template.get_def("hi").render(name="ed")
- print template.get_def("bye").render(name="ed")
-
-
-Defs within Defs
-================
-
-The def model follows regular Python rules for closures.
-Declaring ``<%def>`` inside another ``<%def>`` declares it
-within the parent's **enclosing scope**:
-
-.. sourcecode:: mako
-
- <%def name="mydef()">
- <%def name="subdef()">
- a sub def
- </%def>
-
- im the def, and the subcomponent is ${subdef()}
- </%def>
-
-Just like Python, names that exist outside the inner ``<%def>``
-exist inside it as well:
-
-.. sourcecode:: mako
-
- <%
- x = 12
- %>
- <%def name="outer()">
- <%
- y = 15
- %>
- <%def name="inner()">
- inner, x is ${x}, y is ${y}
- </%def>
-
- outer, x is ${x}, y is ${y}
- </%def>
-
-Assigning to a name inside of a def declares that name as local
-to the scope of that def (again, like Python itself). This means
-the following code will raise an error:
-
-.. sourcecode:: mako
-
- <%
- x = 10
- %>
- <%def name="somedef()">
- ## error !
- somedef, x is ${x}
- <%
- x = 27
- %>
- </%def>
-
-...because the assignment to ``x`` declares x as local to the
-scope of ``somedef``, rendering the "outer" version unreachable
-in the expression that tries to render it.
-
-.. _defs_with_content:
-
-Calling a def with embedded content and/or other defs
-=====================================================
-
-A flip-side to def within def is a def call with content. This
-is where you call a def, and at the same time declare a block of
-content (or multiple blocks) that can be used by the def being
-called. The main point of such a call is to create custom,
-nestable tags, just like any other template language's
-custom-tag creation system - where the external tag controls the
-execution of the nested tags and can communicate state to them.
-Only with Mako, you don't have to use any external Python
-modules, you can define arbitrarily nestable tags right in your
-templates.
-
-To achieve this, the target def is invoked using the form
-``<%namepacename:defname>`` instead of the normal ``${}``
-syntax. This syntax, introduced in Mako 0.2.3, is functionally
-equivalent another tag known as ``call``, which takes the form
-``<%call expr='namespacename.defname(args)'>``. While ``%call``
-is available in all versions of Mako, the newer style is
-probably more familiar looking. The ``namespace`` portion of the
-call is the name of the **namespace** in which the def is
-defined - in the most simple cases, this can be ``local`` or
-``self`` to reference the current template's namespace (the
-difference between ``local`` and ``self`` is one of inheritance
-- see :ref:`namespaces_builtin` for details).
-
-When the target def is invoked, a variable ``caller`` is placed
-in its context which contains another namespace containing the
-body and other defs defined by the caller. The body itself is
-referenced by the method ``body()``. Below, we build a ``%def``
-that operates upon ``caller.body()`` to invoke the body of the
-custom tag:
-
-.. sourcecode:: mako
-
- <%def name="buildtable()">
- <table>
- <tr><td>
- ${caller.body()}
- </td></tr>
- </table>
- </%def>
-
- <%self:buildtable>
- I am the table body.
- </%self:buildtable>
-
-This produces the output (whitespace formatted):
-
-.. sourcecode:: html
-
- <table>
- <tr><td>
- I am the table body.
- </td></tr>
- </table>
-
-Using the older ``%call`` syntax looks like:
-
-.. sourcecode:: mako
-
- <%def name="buildtable()">
- <table>
- <tr><td>
- ${caller.body()}
- </td></tr>
- </table>
- </%def>
-
- <%call expr="buildtable()">
- I am the table body.
- </%call>
-
-The ``body()`` can be executed multiple times or not at all.
-This means you can use def-call-with-content to build iterators,
-conditionals, etc:
-
-.. sourcecode:: mako
-
- <%def name="lister(count)">
- % for x in range(count):
- ${caller.body()}
- % endfor
- </%def>
-
- <%self:lister count="${3}">
- hi
- </%self:lister>
-
-Produces:
-
-.. sourcecode:: html
-
- hi
- hi
- hi
-
-Notice above we pass ``3`` as a Python expression, so that it
-remains as an integer.
-
-A custom "conditional" tag:
-
-.. sourcecode:: mako
-
- <%def name="conditional(expression)">
- % if expression:
- ${caller.body()}
- % endif
- </%def>
-
- <%self:conditional expression="${4==4}">
- im the result
- </%self:conditional>
-
-Produces:
-
-.. sourcecode:: html
-
- im the result
-
-But that's not all. The ``body()`` function also can handle
-arguments, which will augment the local namespace of the body
-callable. The caller must define the arguments which it expects
-to receive from its target def using the ``args`` attribute,
-which is a comma-separated list of argument names. Below, our
-``<%def>`` calls the ``body()`` of its caller, passing in an
-element of data from its argument:
-
-.. sourcecode:: mako
-
- <%def name="layoutdata(somedata)">
- <table>
- % for item in somedata:
- <tr>
- % for col in item:
- <td>${caller.body(col=col)}</td>
- % endfor
- </tr>
- % endfor
- </table>
- </%def>
-
- <%self:layoutdata somedata="${[[1,2,3],[4,5,6],[7,8,9]]}" args="col">\
- Body data: ${col}\
- </%self:layoutdata>
-
-Produces:
-
-.. sourcecode:: html
-
- <table>
- <tr>
- <td>Body data: 1</td>
- <td>Body data: 2</td>
- <td>Body data: 3</td>
- </tr>
- <tr>
- <td>Body data: 4</td>
- <td>Body data: 5</td>
- <td>Body data: 6</td>
- </tr>
- <tr>
- <td>Body data: 7</td>
- <td>Body data: 8</td>
- <td>Body data: 9</td>
- </tr>
- </table>
-
-You don't have to stick to calling just the ``body()`` function.
-The caller can define any number of callables, allowing the
-``<%call>`` tag to produce whole layouts:
-
-.. sourcecode:: mako
-
- <%def name="layout()">
- ## a layout def
- <div class="mainlayout">
- <div class="header">
- ${caller.header()}
- </div>
- <div class="sidebar">
- ${caller.sidebar()}
- </div>
- <div class="content">
- ${caller.body()}
- </div>
- </div>
- </%def>
-
- ## calls the layout def
- <%self:layout>
- <%def name="header()">
- I am the header
- </%def>
- <%def name="sidebar()">
- <ul>
- <li>sidebar 1</li>
- <li>sidebar 2</li>
- </ul>
- </%def>
-
- this is the body
- </%self:layout>
-
-The above layout would produce:
-
-.. sourcecode:: html
-
- <div class="mainlayout">
- <div class="header">
- I am the header
- </div>
-
- <div class="sidebar">
- <ul>
- <li>sidebar 1</li>
- <li>sidebar 2</li>
- </ul>
- </div>
-
- <div class="content">
- this is the body
- </div>
- </div>
-
-The number of things you can do with ``<%call>`` and/or the
-``<%namespacename:defname>`` calling syntax is enormous. You can
-create form widget libraries, such as an enclosing ``<FORM>``
-tag and nested HTML input elements, or portable wrapping schemes
-using ``<div>`` or other elements. You can create tags that
-interpret rows of data, such as from a database, providing the
-individual columns of each row to a ``body()`` callable which
-lays out the row any way it wants. Basically anything you'd do
-with a "custom tag" or tag library in some other system, Mako
-provides via ``<%def>`` tags and plain Python callables which are
-invoked via ``<%namespacename:defname>`` or ``<%call>``.
-
-
-
diff --git a/lib/mako/doc/build/filtering.rst b/lib/mako/doc/build/filtering.rst
deleted file mode 100644
--- a/lib/mako/doc/build/filtering.rst
+++ /dev/null
@@ -1,340 +0,0 @@
-.. _filtering_toplevel:
-
-=======================
-Filtering and Buffering
-=======================
-
-Expression Filtering
-=====================
-
-As described in the chapter :ref:`syntax_toplevel`, the "``|``" operator can be
-applied to a "``${}``" expression to apply escape filters to the
-output:
-
-.. sourcecode:: mako
-
- ${"this is some text" | u}
-
-The above expression applies URL escaping to the expression, and
-produces ``this+is+some+text``.
-
-The built-in escape flags are:
-
-* ``u`` : URL escaping, provided by
- ``urllib.quote_plus(string.encode('utf-8'))``
-* ``h`` : HTML escaping, provided by
- ``markupsafe.escape(string)`` (new as of 0.3.4 - prior
- versions use ``cgi.escape(string, True)``)
-* ``x`` : XML escaping
-* ``trim`` : whitespace trimming, provided by ``string.strip()``
-* ``entity`` : produces HTML entity references for applicable
- strings, derived from ``htmlentitydefs``
-* ``unicode`` (``str`` on Python 3): produces a Python unicode
- string (this function is applied by default).
-* ``decode.<some encoding>`` : decode input into a Python
- unicode with the specified encoding
-* ``n`` : disable all default filtering; only filters specified
- in the local expression tag will be applied.
-
-To apply more than one filter, separate them by a comma:
-
-.. sourcecode:: mako
-
- ${" <tag>some value</tag> " | h,trim}
-
-The above produces ``<tag>some value</tag>``, with
-no leading or trailing whitespace. The HTML escaping function is
-applied first, the "trim" function second.
-
-Naturally, you can make your own filters too. A filter is just a
-Python function that accepts a single string argument, and
-returns the filtered result. The expressions after the ``|``
-operator draw upon the local namespace of the template in which
-they appear, meaning you can define escaping functions locally:
-
-.. sourcecode:: mako
-
- <%!
- def myescape(text):
- return "<TAG>" + text + "</TAG>"
- %>
-
- Heres some tagged text: ${"text" | myescape}
-
-Or from any Python module:
-
-.. sourcecode:: mako
-
- <%!
- import myfilters
- %>
-
- Heres some tagged text: ${"text" | myfilters.tagfilter}
-
-A page can apply a default set of filters to all expression tags
-using the ``expression_filter`` argument to the ``%page`` tag:
-
-.. sourcecode:: mako
-
- <%page expression_filter="h"/>
-
- Escaped text: ${"<html>some html</html>"}
-
-Result:
-
-.. sourcecode:: html
-
- Escaped text: <html>some html</html>
-
-.. _filtering_default_filters:
-
-The default_filters Argument
-----------------------------
-
-In addition to the ``expression_filter`` argument, the
-``default_filters`` argument to both ``Template`` and
-``TemplateLookup`` can specify filtering for all expression tags
-at the programmatic level. This array-based argument, when given
-its default argument of ``None``, will be internally set to
-``["unicode"]`` (or ``["str"]`` on Python 3), except when
-``disable_unicode=True`` is set in which case it defaults to
-``["str"]``:
-
-.. sourcecode:: python
-
- t = TemplateLookup(directories=['/tmp'], default_filters=['unicode'])
-
-To replace the usual ``unicode``/``str`` function with a
-specific encoding, the ``decode`` filter can be substituted:
-
-.. sourcecode:: python
-
- t = TemplateLookup(directories=['/tmp'], default_filters=['decode.utf8'])
-
-To disable ``default_filters`` entirely, set it to an empty
-list:
-
-.. sourcecode:: python
-
- t = TemplateLookup(directories=['/tmp'], default_filters=[])
-
-Any string name can be added to ``default_filters`` where it
-will be added to all expressions as a filter. The filters are
-applied from left to right, meaning the leftmost filter is
-applied first.
-
-.. sourcecode:: python
-
- t = Template(templatetext, default_filters=['unicode', 'myfilter'])
-
-To ease the usage of ``default_filters`` with custom filters,
-you can also add imports (or other code) to all templates using
-the ``imports`` argument:
-
-.. sourcecode:: python
-
- t = TemplateLookup(directories=['/tmp'],
- default_filters=['unicode', 'myfilter'],
- imports=['from mypackage import myfilter'])
-
-The above will generate templates something like this:
-
-.. sourcecode:: python
-
- # ....
- from mypackage import myfilter
-
- def render_body(context):
- context.write(myfilter(unicode("some text")))
-
-Turning off Filtering with the "n" filter
-------------------------------------------
-
-In all cases the special ``n`` filter, used locally within an
-expression, will **disable** all filters declared in the
-``<%page>`` tag as well ``default_filters``. Such as:
-
-.. sourcecode:: mako
-
- ${'myexpression' | n}
-
-Will render ``myexpression`` with no filtering of any kind, and
-
-.. sourcecode:: mako
-
- ${'myexpression' | n, trim}
-
-will render ``myexpression`` using the ``trim`` filter only.
-
-Filtering Defs
-=================
-
-The ``%def`` tag has a filter argument which will apply the
-given list of filter functions to the output of the ``%def``:
-
-.. sourcecode:: mako
-
- <%def name="foo()" filter="h, trim">
- <b>this is bold</b>
- </%def>
-
-When the filter attribute is applied to a def as above, the def
-is automatically **buffered** as well. This is described next.
-
-Buffering
-==========
-
-One of Mako's central design goals is speed. To this end, all of
-the textual content within a template and its various callables
-is by default piped directly to the single buffer that is stored
-within the ``Context`` object. While this normally is easy to
-miss, it has certain side effects. The main one is that when you
-call a def using the normal expression syntax, i.e.
-``${somedef()}``, it may appear that the return value of the
-function is the content it produced, which is then delivered to
-your template just like any other expression substitution,
-except that normally, this is not the case; the return value of
-``${somedef()}`` is simply the empty string ``''``. By the time
-you receive this empty string, the output of ``somedef()`` has
-been sent to the underlying buffer.
-
-You may not want this effect, if for example you are doing
-something like this:
-
-.. sourcecode:: mako
-
- ${" results " + somedef() + " more results "}
-
-If the ``somedef()`` function produced the content "``somedef's
-results``", the above template would produce this output:
-
-.. sourcecode:: html
-
- somedef's results results more results
-
-This is because ``somedef()`` fully executes before the
-expression returns the results of its concatenation; the
-concatenation in turn receives just the empty string as its
-middle expression.
-
-Mako provides two ways to work around this. One is by applying
-buffering to the ``%def`` itself:
-
-.. sourcecode:: mako
-
- <%def name="somedef()" buffered="True">
- somedef's results
- </%def>
-
-The above definition will generate code similar to this:
-
-.. sourcecode:: python
-
- def somedef():
- context.push_buffer()
- try:
- context.write("somedef's results")
- finally:
- buf = context.pop_buffer()
- return buf.getvalue()
-
-So that the content of ``somedef()`` is sent to a second buffer,
-which is then popped off the stack and its value returned. The
-speed hit inherent in buffering the output of a def is also
-apparent.
-
-Note that the ``filter`` argument on %def also causes the def to
-be buffered. This is so that the final content of the %def can
-be delivered to the escaping function in one batch, which
-reduces method calls and also produces more deterministic
-behavior for the filtering function itself, which can possibly
-be useful for a filtering function that wishes to apply a
-transformation to the text as a whole.
-
-The other way to buffer the output of a def or any Mako callable
-is by using the built-in ``capture`` function. This function
-performs an operation similar to the above buffering operation
-except it is specified by the caller.
-
-.. sourcecode:: mako
-
- ${" results " + capture(somedef) + " more results "}
-
-Note that the first argument to the ``capture`` function is
-**the function itself**, not the result of calling it. This is
-because the ``capture`` function takes over the job of actually
-calling the target function, after setting up a buffered
More information about the pypy-commit
mailing list