Hello community,
here is the log from the commit of package python-mako for openSUSE:Factory
checked in at Mon Jan 11 18:01:02 CET 2010.
--------
--- python-mako/python-mako.changes 2009-09-03 14:11:36.000000000 +0200
+++ /mounts/work_src_done/STABLE/python-mako/python-mako.changes 2009-09-08 15:50:11.000000000 +0200
@@ -1,0 +2,22 @@
+Tue Sep 8 12:26:28 UTC 2009 - jfunk@funktronics.ca
+
+- Update to 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]
+
+-------------------------------------------------------------------
calling whatdependson for head-i586
Old:
----
Mako-0.2.4.tar.bz2
New:
----
Mako-0.2.5.tar.bz2
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-mako.spec ++++++
--- /var/tmp/diff_new_pack.Uufoyh/_old 2010-01-11 18:00:24.000000000 +0100
+++ /var/tmp/diff_new_pack.Uufoyh/_new 2010-01-11 18:00:24.000000000 +0100
@@ -1,7 +1,7 @@
#
-# spec file for package python-mako (Version 0.2.4)
+# spec file for package python-mako (Version 0.2.5)
#
-# Copyright (c) 2009 SUSE LINUX Products GmbH, Nuernberg, Germany.
+# Copyright (c) 2010 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -19,7 +19,7 @@
%define modname Mako
Name: python-mako
-Version: 0.2.4
+Version: 0.2.5
Release: 1
Summary: A Super-Fast Templating Language
Url: http://www.makotemplates.org/
@@ -30,6 +30,7 @@
%{py_requires}
BuildRequires: python-devel
BuildRequires: python-setuptools
+BuildRequires: fdupes
Requires: python-beaker >= 1.1
%if %{?suse_version: %{suse_version} > 1110} %{!?suse_version:1}
BuildArch: noarch
@@ -58,6 +59,7 @@
%install
python setup.py install --single-version-externally-managed --prefix=%{_prefix} --root=$RPM_BUILD_ROOT --record-rpm=INSTALLED_FILES
+%fdupes %buildroot
%clean
rm -rf %{buildroot}
++++++ Mako-0.2.4.tar.bz2 -> Mako-0.2.5.tar.bz2 ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mako-0.2.4/CHANGES new/Mako-0.2.5/CHANGES
--- old/Mako-0.2.4/CHANGES 2008-12-23 04:43:44.000000000 +0100
+++ new/Mako-0.2.5/CHANGES 2009-09-07 21:28:05.000000000 +0200
@@ -1,3 +1,38 @@
+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.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mako-0.2.4/LICENSE new/Mako-0.2.5/LICENSE
--- old/Mako-0.2.4/LICENSE 2008-12-23 04:43:44.000000000 +0100
+++ new/Mako-0.2.5/LICENSE 2009-09-07 21:28:05.000000000 +0200
@@ -1,6 +1,6 @@
This is the MIT license: http://www.opensource.org/licenses/mit-license.php
-Copyright (C) 2006, 2007, 2008 Michael Bayer and contributors. Mako is a trademark of Michael
+Copyright (C) 2006, 2007, 2008, 2009 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
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mako-0.2.4/PKG-INFO new/Mako-0.2.5/PKG-INFO
--- old/Mako-0.2.4/PKG-INFO 2008-12-23 04:48:51.000000000 +0100
+++ new/Mako-0.2.5/PKG-INFO 2009-09-07 22:14:10.000000000 +0200
@@ -1,6 +1,6 @@
Metadata-Version: 1.0
Name: Mako
-Version: 0.2.4
+Version: 0.2.5
Summary: A super-fast templating language that borrows the best ideas from the existing templating languages.
Home-page: http://www.makotemplates.org/
Author: Mike Bayer
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mako-0.2.4/doc/build/content/defs.txt new/Mako-0.2.5/doc/build/content/defs.txt
--- old/Mako-0.2.4/doc/build/content/defs.txt 2008-12-23 04:43:44.000000000 +0100
+++ new/Mako-0.2.5/doc/build/content/defs.txt 2009-09-07 21:28:05.000000000 +0200
@@ -37,7 +37,7 @@
account name: ${accountname}, type ${type}
%def>
-When you declare an argument signature for your def, they are required following 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.
+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 {@name=remotedefs}
@@ -171,7 +171,7 @@
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:
<%def name="lister(count)">
- % for x in range(1,count):
+ % for x in range(count):
${caller.body()}
% endfor
%def>
@@ -298,3 +298,4 @@
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>`s and plain Python callables which are invoked via `<%namespacename:defname>` or `<%call>`.
+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mako-0.2.4/doc/build/content/filtering.txt new/Mako-0.2.5/doc/build/content/filtering.txt
--- old/Mako-0.2.4/doc/build/content/filtering.txt 2008-12-23 04:43:44.000000000 +0100
+++ new/Mako-0.2.5/doc/build/content/filtering.txt 2009-09-07 21:28:05.000000000 +0200
@@ -161,4 +161,41 @@
${somedef(17, 'hi', use_paging=True)}
+### Decorating
+
+This is a feature that's new as of version 0.2.5. Somewhat like a filter for a %def but more flexible, the `decorator` argument to `%def` allows the creation of a function that will work in a similar manner to a Python decorator. The function can control whether or not the function executes. The original intent of this function is to allow the creation of custom cache logic, but there may be other uses as well.
+
+`decorator` is intended to be used with a regular Python function, such as one defined in a library module. Here we'll illustrate the python function defined in the template for simplicities' sake:
+
+ <%!
+ def bar(fn):
+ def decorate(context, *args, **kw):
+ context.write("BAR")
+ fn(*args, **kw)
+ context.write("BAR")
+ return ''
+ return decorate
+ %>
+
+ <%def name="foo()" decorator="bar">
+ this is foo
+ %def>
+
+ ${foo()}
+The above template will return, with more whitespace than this, `"BAR this is foo BAR"`. The function is the render callable itself (or possibly a wrapper around it), and by default will write to the context. To capture its output, use the `capture` callable in the `mako.runtime` module (available in templates as just `runtime`):
+
+ <%!
+ def bar(fn):
+ def decorate(context, *args, **kw):
+ return "BAR" + runtime.capture(context, fn, *args, **kw) + "BAR"
+ return decorate
+ %>
+
+ <%def name="foo()" decorator="bar">
+ this is foo
+ %def>
+
+ ${foo()}
+
+The decorator can be used with top-level defs as well as nested defs. Note that when calling a top-level def from the `Template` api, i.e. `template.get_def('somedef').render()`, the decorator has to write the output to the `context`, i.e. as in the first example. The return value gets discarded.
\ No newline at end of file
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mako-0.2.4/doc/build/content/syntax.txt new/Mako-0.2.5/doc/build/content/syntax.txt
--- old/Mako-0.2.4/doc/build/content/syntax.txt 2008-12-23 04:43:44.000000000 +0100
+++ new/Mako-0.2.5/doc/build/content/syntax.txt 2009-09-07 21:28:05.000000000 +0200
@@ -157,7 +157,7 @@
${myfunc(7)}
-The %def tag is a lot more powerful than a plain Python def, as the Mako compiler provides many extra services with %def that you wouldn't normally have, such as the ability to export defs as template "methods", automatic propigation of the current `Context`, buffering/filtering/caching flags, and def calls with content, which enable packages of defs to be sent as arguments to other def calls (not as hard as it sounds). Get the full deal on what %def can do in [defs](rel:defs).
+The %def tag is a lot more powerful than a plain Python def, as the Mako compiler provides many extra services with %def that you wouldn't normally have, such as the ability to export defs as template "methods", automatic propagation of the current `Context`, buffering/filtering/caching flags, and def calls with content, which enable packages of defs to be sent as arguments to other def calls (not as hard as it sounds). Get the full deal on what %def can do in [defs](rel:defs).
#### <%namespace>
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mako-0.2.4/doc/build/content/usage.txt new/Mako-0.2.5/doc/build/content/usage.txt
--- old/Mako-0.2.4/doc/build/content/usage.txt 2008-12-23 04:43:44.000000000 +0100
+++ new/Mako-0.2.5/doc/build/content/usage.txt 2009-09-07 21:28:05.000000000 +0200
@@ -11,7 +11,8 @@
mytemplate = Template("hello world!")
print mytemplate.render()
-Above, the text argument to `Template` is **compiled** into a Python module representation. This module contains a function called `render_body()`, which produces the output of the template. When `mytemplate.render()` is called, Mako sets up a runtime environment for the template and calls the `render_body()` function, capturing the output into a buffer and returning it's string contents.
+Above, the text argument to `Template` is **compiled** into a Python module representation. This module contains a function called `render_body()`, which produces the output of the template. When `mytemplate.render()` is called, Mako sets up a runtime environment for the template and calls the `render_body()` function, capturing the output into a buffer and returning its string contents.
+
The code inside the `render_body()` function has access to a namespace of variables. You can specify these variables by sending them as additional keyword arguments to the `render()` method:
@@ -95,7 +96,7 @@
#### Setting Filesystem Checks {@name=checks}
-Another important flag on `TemplateLookup` is `filesystem_checks`. This defaults to `True`, and says that each time a template is returned by the `get_template()` method, the revision time of the original template file is checked against the last time the template was loaded, and if the file is newer will reload its contents and recompile the template. On a production system, seting `filesystem_checks` to `False` can afford a small to moderate performance increase (depending on the type of filesystem used).
+Another important flag on `TemplateLookup` is `filesystem_checks`. This defaults to `True`, and says that each time a template is returned by the `get_template()` method, the revision time of the original template file is checked against the last time the template was loaded, and if the file is newer will reload its contents and recompile the template. On a production system, setting `filesystem_checks` to `False` can afford a small to moderate performance increase (depending on the type of filesystem used).
### Using Unicode and Encoding
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mako-0.2.4/doc/build/genhtml.py new/Mako-0.2.5/doc/build/genhtml.py
--- old/Mako-0.2.4/doc/build/genhtml.py 2008-12-23 04:46:20.000000000 +0100
+++ new/Mako-0.2.5/doc/build/genhtml.py 2009-09-07 21:28:05.000000000 +0200
@@ -5,7 +5,7 @@
sys.path = ['../../lib', './lib/'] + sys.path
from mako.lookup import TemplateLookup
-from mako import exceptions
+from mako import exceptions, __version__ as version
import read_markdown, toc
@@ -24,7 +24,6 @@
]
title='Mako Documentation'
-version = '0.2.4'
root = toc.TOCElement('', 'root', '', version=version, doctitle=title)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mako-0.2.4/doc/caching.html new/Mako-0.2.5/doc/caching.html
--- old/Mako-0.2.4/doc/caching.html 2008-12-23 04:46:40.000000000 +0100
+++ new/Mako-0.2.5/doc/caching.html 2009-09-07 21:28:30.000000000 +0200
@@ -28,7 +28,7 @@
<h1>Mako Documentation</h1>
-<div class="versionheader">Version: 0.2.4 Last Updated: 12/22/08 22:46:37</div>
+<div class="versionheader">Version: 0.2.5 Last Updated: 09/07/09 15:28:26</div>
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mako-0.2.4/doc/defs.html new/Mako-0.2.5/doc/defs.html
--- old/Mako-0.2.4/doc/defs.html 2008-12-23 04:46:40.000000000 +0100
+++ new/Mako-0.2.5/doc/defs.html 2009-09-07 21:28:30.000000000 +0200
@@ -28,7 +28,7 @@
<h1>Mako Documentation</h1>
-<div class="versionheader">Version: 0.2.4 Last Updated: 12/22/08 22:46:37</div>
+<div class="versionheader">Version: 0.2.5 Last Updated: 09/07/09 15:28:26</div>
@@ -170,7 +170,7 @@
</pre></div>
</div>
-<p>When you declare an argument signature for your def, they are required following 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 <code>UNDEFINED</code> if you reference a name that does not exist.
+<p>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 <code>UNDEFINED</code> if you reference a name that does not exist.
</p>
@@ -434,7 +434,7 @@
<div class="code">
<div class="highlight"><pre><span class="cp"><%</span><span class="nb">def</span> <span class="na">name=</span><span class="s">"lister(count)"</span><span class="cp">></span>
- <span class="cp">%</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mf">1</span><span class="p">,</span><span class="n">count</span><span class="p">):</span>
+ <span class="cp">%</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">count</span><span class="p">):</span>
<span class="cp">${</span><span class="n">caller</span><span class="o">.</span><span class="n">body</span><span class="p">()</span><span class="cp">}</span>
<span class="cp">%</span><span class="k"> endfor</span>
<span class="cp"></%</span><span class="nb">def</span><span class="cp">></span>
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mako-0.2.4/doc/documentation.html new/Mako-0.2.5/doc/documentation.html
--- old/Mako-0.2.4/doc/documentation.html 2008-12-23 04:46:39.000000000 +0100
+++ new/Mako-0.2.5/doc/documentation.html 2009-09-07 21:28:30.000000000 +0200
@@ -30,7 +30,7 @@
<h1>Mako Documentation</h1>
-<div class="versionheader">Version: 0.2.4 Last Updated: 12/22/08 22:46:37</div>
+<div class="versionheader">Version: 0.2.5 Last Updated: 09/07/09 15:28:26</div>
@@ -415,6 +415,12 @@
<ul>
</ul>
+ <li><A style="" href="#filtering_decorating">Decorating</a></li>
+
+
+ <ul>
+ </ul>
+
</ul>
<li><A style="" href="#unicode">The Unicode Chapter</a></li>
@@ -529,7 +535,7 @@
</pre></div>
</div>
-<p>Above, the text argument to <code>Template</code> is <strong>compiled</strong> into a Python module representation. This module contains a function called <code>render_body()</code>, which produces the output of the template. When <code>mytemplate.render()</code> is called, Mako sets up a runtime environment for the template and calls the <code>render_body()</code> function, capturing the output into a buffer and returning it's string contents.
+<p>Above, the text argument to <code>Template</code> is <strong>compiled</strong> into a Python module representation. This module contains a function called <code>render_body()</code>, which produces the output of the template. When <code>mytemplate.render()</code> is called, Mako sets up a runtime environment for the template and calls the <code>render_body()</code> function, capturing the output into a buffer and returning its string contents.
</p>
<p>The code inside the <code>render_body()</code> function has access to a namespace of variables. You can specify these variables by sending them as additional keyword arguments to the <code>render()</code> method:
</p>
@@ -707,7 +713,7 @@
-<p>Another important flag on <code>TemplateLookup</code> is <code>filesystem_checks</code>. This defaults to <code>True</code>, and says that each time a template is returned by the <code>get_template()</code> method, the revision time of the original template file is checked against the last time the template was loaded, and if the file is newer will reload its contents and recompile the template. On a production system, seting <code>filesystem_checks</code> to <code>False</code> can afford a small to moderate performance increase (depending on the type of filesystem used).
+<p>Another important flag on <code>TemplateLookup</code> is <code>filesystem_checks</code>. This defaults to <code>True</code>, and says that each time a template is returned by the <code>get_template()</code> method, the revision time of the original template file is checked against the last time the template was loaded, and if the file is newer will reload its contents and recompile the template. On a production system, setting <code>filesystem_checks</code> to <code>False</code> can afford a small to moderate performance increase (depending on the type of filesystem used).
</p>
@@ -1554,7 +1560,7 @@
</pre></div>
</div>
-<p>The %def tag is a lot more powerful than a plain Python def, as the Mako compiler provides many extra services with %def that you wouldn't normally have, such as the ability to export defs as template "methods", automatic propigation of the current <code>Context</code>, buffering/filtering/caching flags, and def calls with content, which enable packages of defs to be sent as arguments to other def calls (not as hard as it sounds). Get the full deal on what %def can do in <a href="#defs">Defs</a>.
+<p>The %def tag is a lot more powerful than a plain Python def, as the Mako compiler provides many extra services with %def that you wouldn't normally have, such as the ability to export defs as template "methods", automatic propagation of the current <code>Context</code>, buffering/filtering/caching flags, and def calls with content, which enable packages of defs to be sent as arguments to other def calls (not as hard as it sounds). Get the full deal on what %def can do in <a href="#defs">Defs</a>.
</p>
@@ -1901,7 +1907,7 @@
</pre></div>
</div>
-<p>When you declare an argument signature for your def, they are required following 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 <code>UNDEFINED</code> if you reference a name that does not exist.
+<p>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 <code>UNDEFINED</code> if you reference a name that does not exist.
</p>
@@ -2165,7 +2171,7 @@
<div class="code">
<div class="highlight"><pre><span class="cp"><%</span><span class="nb">def</span> <span class="na">name=</span><span class="s">"lister(count)"</span><span class="cp">></span>
- <span class="cp">%</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mf">1</span><span class="p">,</span><span class="n">count</span><span class="p">):</span>
+ <span class="cp">%</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">count</span><span class="p">):</span>
<span class="cp">${</span><span class="n">caller</span><span class="o">.</span><span class="n">body</span><span class="p">()</span><span class="cp">}</span>
<span class="cp">%</span><span class="k"> endfor</span>
<span class="cp"></%</span><span class="nb">def</span><span class="cp">></span>
@@ -3987,6 +3993,75 @@
+ <a href="#filtering">back to section top</a>
+ </div>
+
+
+
+
+ <A name="filtering_decorating"></a>
+
+ <div class="subsection">
+
+
+ <h3>Decorating</h3>
+
+
+
+<p>This is a feature that's new as of version 0.2.5. Somewhat like a filter for a %def but more flexible, the <code>decorator</code> argument to <code>%def</code> allows the creation of a function that will work in a similar manner to a Python decorator. The function can control whether or not the function executes. The original intent of this function is to allow the creation of custom cache logic, but there may be other uses as well.
+</p>
+<p><code>decorator</code> is intended to be used with a regular Python function, such as one defined in a library module. Here we'll illustrate the python function defined in the template for simplicities' sake:
+</p>
+
+
+
+
+ <div class="code">
+ <div class="highlight"><pre><span class="cp"><%!</span>
+ <span class="k">def</span> <span class="nf">bar</span><span class="p">(</span><span class="n">fn</span><span class="p">):</span>
+ <span class="k">def</span> <span class="nf">decorate</span><span class="p">(</span><span class="n">context</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kw</span><span class="p">):</span>
+ <span class="n">context</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s">"BAR"</span><span class="p">)</span>
+ <span class="n">fn</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kw</span><span class="p">)</span>
+ <span class="n">context</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s">"BAR"</span><span class="p">)</span>
+ <span class="k">return</span> <span class="s">''</span>
+ <span class="k">return</span> <span class="n">decorate</span>
+<span class="cp">%></span>
+
+<span class="cp"><%</span><span class="nb">def</span> <span class="na">name=</span><span class="s">"foo()"</span> <span class="na">decorator=</span><span class="s">"bar"</span><span class="cp">></span>
+ this is foo
+<span class="cp"></%</span><span class="nb">def</span><span class="cp">></span>
+
+<span class="cp">${</span><span class="n">foo</span><span class="p">()</span><span class="cp">}</span>
+</pre></div>
+
+ </div>
+<p>The above template will return, with more whitespace than this, <code>"BAR this is foo BAR"</code>. The function is the render callable itself (or possibly a wrapper around it), and by default will write to the context. To capture its output, use the <code>capture</code> callable in the <code>mako.runtime</code> module (available in templates as just <code>runtime</code>):
+</p>
+
+
+
+
+ <div class="code">
+ <div class="highlight"><pre><span class="cp"><%!</span>
+ <span class="k">def</span> <span class="nf">bar</span><span class="p">(</span><span class="n">fn</span><span class="p">):</span>
+ <span class="k">def</span> <span class="nf">decorate</span><span class="p">(</span><span class="n">context</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kw</span><span class="p">):</span>
+ <span class="k">return</span> <span class="s">"BAR"</span> <span class="o">+</span> <span class="n">runtime</span><span class="o">.</span><span class="n">capture</span><span class="p">(</span><span class="n">context</span><span class="p">,</span> <span class="n">fn</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kw</span><span class="p">)</span> <span class="o">+</span> <span class="s">"BAR"</span>
+ <span class="k">return</span> <span class="n">decorate</span>
+<span class="cp">%></span>
+
+<span class="cp"><%</span><span class="nb">def</span> <span class="na">name=</span><span class="s">"foo()"</span> <span class="na">decorator=</span><span class="s">"bar"</span><span class="cp">></span>
+ this is foo
+<span class="cp"></%</span><span class="nb">def</span><span class="cp">></span>
+
+<span class="cp">${</span><span class="n">foo</span><span class="p">()</span><span class="cp">}</span>
+</pre></div>
+
+ </div>
+<p>The decorator can be used with top-level defs as well as nested defs. Note that when calling a top-level def from the <code>Template</code> api, i.e. <code>template.get_def('somedef').render()</code>, the decorator has to write the output to the <code>context</code>, i.e. as in the first example. The return value gets discarded.
+</p>
+
+
+
</div>
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mako-0.2.4/doc/filtering.html new/Mako-0.2.5/doc/filtering.html
--- old/Mako-0.2.4/doc/filtering.html 2008-12-23 04:46:40.000000000 +0100
+++ new/Mako-0.2.5/doc/filtering.html 2009-09-07 21:28:30.000000000 +0200
@@ -28,7 +28,7 @@
<h1>Mako Documentation</h1>
-<div class="versionheader">Version: 0.2.4 Last Updated: 12/22/08 22:46:37</div>
+<div class="versionheader">Version: 0.2.5 Last Updated: 09/07/09 15:28:26</div>
@@ -88,6 +88,12 @@
<ul>
</ul>
+ <li><A style="" href="filtering.html#filtering_decorating">Decorating</a></li>
+
+
+ <ul>
+ </ul>
+
</ul>
</div>
@@ -520,6 +526,75 @@
+ <a href="#top">back to section top</a>
+ </div>
+
+
+
+
+ <A name="filtering_decorating"></a>
+
+ <div class="subsection">
+
+
+ <h3>Decorating</h3>
+
+
+
+<p>This is a feature that's new as of version 0.2.5. Somewhat like a filter for a %def but more flexible, the <code>decorator</code> argument to <code>%def</code> allows the creation of a function that will work in a similar manner to a Python decorator. The function can control whether or not the function executes. The original intent of this function is to allow the creation of custom cache logic, but there may be other uses as well.
+</p>
+<p><code>decorator</code> is intended to be used with a regular Python function, such as one defined in a library module. Here we'll illustrate the python function defined in the template for simplicities' sake:
+</p>
+
+
+
+
+ <div class="code">
+ <div class="highlight"><pre><span class="cp"><%!</span>
+ <span class="k">def</span> <span class="nf">bar</span><span class="p">(</span><span class="n">fn</span><span class="p">):</span>
+ <span class="k">def</span> <span class="nf">decorate</span><span class="p">(</span><span class="n">context</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kw</span><span class="p">):</span>
+ <span class="n">context</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s">"BAR"</span><span class="p">)</span>
+ <span class="n">fn</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kw</span><span class="p">)</span>
+ <span class="n">context</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s">"BAR"</span><span class="p">)</span>
+ <span class="k">return</span> <span class="s">''</span>
+ <span class="k">return</span> <span class="n">decorate</span>
+<span class="cp">%></span>
+
+<span class="cp"><%</span><span class="nb">def</span> <span class="na">name=</span><span class="s">"foo()"</span> <span class="na">decorator=</span><span class="s">"bar"</span><span class="cp">></span>
+ this is foo
+<span class="cp"></%</span><span class="nb">def</span><span class="cp">></span>
+
+<span class="cp">${</span><span class="n">foo</span><span class="p">()</span><span class="cp">}</span>
+</pre></div>
+
+ </div>
+<p>The above template will return, with more whitespace than this, <code>"BAR this is foo BAR"</code>. The function is the render callable itself (or possibly a wrapper around it), and by default will write to the context. To capture its output, use the <code>capture</code> callable in the <code>mako.runtime</code> module (available in templates as just <code>runtime</code>):
+</p>
+
+
+
+
+ <div class="code">
+ <div class="highlight"><pre><span class="cp"><%!</span>
+ <span class="k">def</span> <span class="nf">bar</span><span class="p">(</span><span class="n">fn</span><span class="p">):</span>
+ <span class="k">def</span> <span class="nf">decorate</span><span class="p">(</span><span class="n">context</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kw</span><span class="p">):</span>
+ <span class="k">return</span> <span class="s">"BAR"</span> <span class="o">+</span> <span class="n">runtime</span><span class="o">.</span><span class="n">capture</span><span class="p">(</span><span class="n">context</span><span class="p">,</span> <span class="n">fn</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kw</span><span class="p">)</span> <span class="o">+</span> <span class="s">"BAR"</span>
+ <span class="k">return</span> <span class="n">decorate</span>
+<span class="cp">%></span>
+
+<span class="cp"><%</span><span class="nb">def</span> <span class="na">name=</span><span class="s">"foo()"</span> <span class="na">decorator=</span><span class="s">"bar"</span><span class="cp">></span>
+ this is foo
+<span class="cp"></%</span><span class="nb">def</span><span class="cp">></span>
+
+<span class="cp">${</span><span class="n">foo</span><span class="p">()</span><span class="cp">}</span>
+</pre></div>
+
+ </div>
+<p>The decorator can be used with top-level defs as well as nested defs. Note that when calling a top-level def from the <code>Template</code> api, i.e. <code>template.get_def('somedef').render()</code>, the decorator has to write the output to the <code>context</code>, i.e. as in the first example. The return value gets discarded.
+</p>
+
+
+
</div>
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mako-0.2.4/doc/index.html new/Mako-0.2.5/doc/index.html
--- old/Mako-0.2.4/doc/index.html 2008-12-23 04:46:37.000000000 +0100
+++ new/Mako-0.2.5/doc/index.html 2009-09-07 21:28:27.000000000 +0200
@@ -30,7 +30,7 @@
<h1>Mako Documentation</h1>
-<div class="versionheader">Version: 0.2.4 Last Updated: 12/22/08 22:46:37</div>
+<div class="versionheader">Version: 0.2.5 Last Updated: 09/07/09 15:28:26</div>
@@ -413,6 +413,12 @@
<ul>
+ </ul>
+
+ <li><A style="" href="filtering.html#filtering_decorating">Decorating</a></li>
+
+
+ <ul>
</ul>
</ul>
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mako-0.2.4/doc/inheritance.html new/Mako-0.2.5/doc/inheritance.html
--- old/Mako-0.2.4/doc/inheritance.html 2008-12-23 04:46:40.000000000 +0100
+++ new/Mako-0.2.5/doc/inheritance.html 2009-09-07 21:28:30.000000000 +0200
@@ -28,7 +28,7 @@
<h1>Mako Documentation</h1>
-<div class="versionheader">Version: 0.2.4 Last Updated: 12/22/08 22:46:37</div>
+<div class="versionheader">Version: 0.2.5 Last Updated: 09/07/09 15:28:26</div>
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mako-0.2.4/doc/namespaces.html new/Mako-0.2.5/doc/namespaces.html
--- old/Mako-0.2.4/doc/namespaces.html 2008-12-23 04:46:40.000000000 +0100
+++ new/Mako-0.2.5/doc/namespaces.html 2009-09-07 21:28:30.000000000 +0200
@@ -28,7 +28,7 @@
<h1>Mako Documentation</h1>
-<div class="versionheader">Version: 0.2.4 Last Updated: 12/22/08 22:46:37</div>
+<div class="versionheader">Version: 0.2.5 Last Updated: 09/07/09 15:28:26</div>
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mako-0.2.4/doc/runtime.html new/Mako-0.2.5/doc/runtime.html
--- old/Mako-0.2.4/doc/runtime.html 2008-12-23 04:46:40.000000000 +0100
+++ new/Mako-0.2.5/doc/runtime.html 2009-09-07 21:28:30.000000000 +0200
@@ -28,7 +28,7 @@
<h1>Mako Documentation</h1>
-<div class="versionheader">Version: 0.2.4 Last Updated: 12/22/08 22:46:37</div>
+<div class="versionheader">Version: 0.2.5 Last Updated: 09/07/09 15:28:26</div>
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mako-0.2.4/doc/syntax.html new/Mako-0.2.5/doc/syntax.html
--- old/Mako-0.2.4/doc/syntax.html 2008-12-23 04:46:39.000000000 +0100
+++ new/Mako-0.2.5/doc/syntax.html 2009-09-07 21:28:30.000000000 +0200
@@ -28,7 +28,7 @@
<h1>Mako Documentation</h1>
-<div class="versionheader">Version: 0.2.4 Last Updated: 12/22/08 22:46:37</div>
+<div class="versionheader">Version: 0.2.5 Last Updated: 09/07/09 15:28:26</div>
@@ -634,7 +634,7 @@
</pre></div>
</div>
-<p>The %def tag is a lot more powerful than a plain Python def, as the Mako compiler provides many extra services with %def that you wouldn't normally have, such as the ability to export defs as template "methods", automatic propigation of the current <code>Context</code>, buffering/filtering/caching flags, and def calls with content, which enable packages of defs to be sent as arguments to other def calls (not as hard as it sounds). Get the full deal on what %def can do in <a href="defs.html">Defs</a>.
+<p>The %def tag is a lot more powerful than a plain Python def, as the Mako compiler provides many extra services with %def that you wouldn't normally have, such as the ability to export defs as template "methods", automatic propagation of the current <code>Context</code>, buffering/filtering/caching flags, and def calls with content, which enable packages of defs to be sent as arguments to other def calls (not as hard as it sounds). Get the full deal on what %def can do in <a href="defs.html">Defs</a>.
</p>
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mako-0.2.4/doc/unicode.html new/Mako-0.2.5/doc/unicode.html
--- old/Mako-0.2.4/doc/unicode.html 2008-12-23 04:46:40.000000000 +0100
+++ new/Mako-0.2.5/doc/unicode.html 2009-09-07 21:28:30.000000000 +0200
@@ -28,7 +28,7 @@
<h1>Mako Documentation</h1>
-<div class="versionheader">Version: 0.2.4 Last Updated: 12/22/08 22:46:37</div>
+<div class="versionheader">Version: 0.2.5 Last Updated: 09/07/09 15:28:26</div>
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mako-0.2.4/doc/usage.html new/Mako-0.2.5/doc/usage.html
--- old/Mako-0.2.4/doc/usage.html 2008-12-23 04:46:39.000000000 +0100
+++ new/Mako-0.2.5/doc/usage.html 2009-09-07 21:28:30.000000000 +0200
@@ -28,7 +28,7 @@
<h1>Mako Documentation</h1>
-<div class="versionheader">Version: 0.2.4 Last Updated: 12/22/08 22:46:37</div>
+<div class="versionheader">Version: 0.2.5 Last Updated: 09/07/09 15:28:26</div>
@@ -163,7 +163,7 @@
</pre></div>
</div>
-<p>Above, the text argument to <code>Template</code> is <strong>compiled</strong> into a Python module representation. This module contains a function called <code>render_body()</code>, which produces the output of the template. When <code>mytemplate.render()</code> is called, Mako sets up a runtime environment for the template and calls the <code>render_body()</code> function, capturing the output into a buffer and returning it's string contents.
+<p>Above, the text argument to <code>Template</code> is <strong>compiled</strong> into a Python module representation. This module contains a function called <code>render_body()</code>, which produces the output of the template. When <code>mytemplate.render()</code> is called, Mako sets up a runtime environment for the template and calls the <code>render_body()</code> function, capturing the output into a buffer and returning its string contents.
</p>
<p>The code inside the <code>render_body()</code> function has access to a namespace of variables. You can specify these variables by sending them as additional keyword arguments to the <code>render()</code> method:
</p>
@@ -341,7 +341,7 @@
-<p>Another important flag on <code>TemplateLookup</code> is <code>filesystem_checks</code>. This defaults to <code>True</code>, and says that each time a template is returned by the <code>get_template()</code> method, the revision time of the original template file is checked against the last time the template was loaded, and if the file is newer will reload its contents and recompile the template. On a production system, seting <code>filesystem_checks</code> to <code>False</code> can afford a small to moderate performance increase (depending on the type of filesystem used).
+<p>Another important flag on <code>TemplateLookup</code> is <code>filesystem_checks</code>. This defaults to <code>True</code>, and says that each time a template is returned by the <code>get_template()</code> method, the revision time of the original template file is checked against the last time the template was loaded, and if the file is newer will reload its contents and recompile the template. On a production system, setting <code>filesystem_checks</code> to <code>False</code> can afford a small to moderate performance increase (depending on the type of filesystem used).
</p>
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mako-0.2.4/examples/wsgi/run_wsgi.py new/Mako-0.2.5/examples/wsgi/run_wsgi.py
--- old/Mako-0.2.4/examples/wsgi/run_wsgi.py 2008-12-23 04:43:44.000000000 +0100
+++ new/Mako-0.2.5/examples/wsgi/run_wsgi.py 2009-09-07 21:28:05.000000000 +0200
@@ -70,8 +70,8 @@
return extensions_map['']
if __name__ == '__main__':
- from wsgiutils import wsgiServer
- server = wsgiServer.WSGIServer (('localhost', port), {'/': serve})
+ import wsgiref.simple_server
+ server = wsgiref.simple_server.make_server('', port, serve)
print "Server listening on port %d" % port
server.serve_forever()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mako-0.2.4/lib/Mako.egg-info/PKG-INFO new/Mako-0.2.5/lib/Mako.egg-info/PKG-INFO
--- old/Mako-0.2.4/lib/Mako.egg-info/PKG-INFO 2008-12-23 04:48:51.000000000 +0100
+++ new/Mako-0.2.5/lib/Mako.egg-info/PKG-INFO 2009-09-07 22:14:09.000000000 +0200
@@ -1,6 +1,6 @@
Metadata-Version: 1.0
Name: Mako
-Version: 0.2.4
+Version: 0.2.5
Summary: A super-fast templating language that borrows the best ideas from the existing templating languages.
Home-page: http://www.makotemplates.org/
Author: Mike Bayer
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mako-0.2.4/lib/Mako.egg-info/SOURCES.txt new/Mako-0.2.5/lib/Mako.egg-info/SOURCES.txt
--- old/Mako-0.2.4/lib/Mako.egg-info/SOURCES.txt 2008-12-23 04:48:51.000000000 +0100
+++ new/Mako-0.2.5/lib/Mako.egg-info/SOURCES.txt 2009-09-07 22:14:09.000000000 +0200
@@ -95,6 +95,7 @@
test/babelplugin.py
test/cache.py
test/call.py
+test/decorators.py
test/def.py
test/exceptions_.py
test/filters.py
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mako-0.2.4/lib/mako/__init__.py new/Mako-0.2.5/lib/mako/__init__.py
--- old/Mako-0.2.4/lib/mako/__init__.py 2008-12-23 04:43:44.000000000 +0100
+++ new/Mako-0.2.5/lib/mako/__init__.py 2009-09-07 21:28:05.000000000 +0200
@@ -1,6 +1,9 @@
# __init__.py
-# Copyright (C) 2006, 2007, 2008 Michael Bayer mike_mp@zzzcomputing.com
+# Copyright (C) 2006, 2007, 2008, 2009 Michael Bayer mike_mp@zzzcomputing.com
#
# This module is part of Mako and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
+
+__version__ = '0.2.5'
+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mako-0.2.4/lib/mako/ast.py new/Mako-0.2.5/lib/mako/ast.py
--- old/Mako-0.2.4/lib/mako/ast.py 2008-12-23 04:43:44.000000000 +0100
+++ new/Mako-0.2.5/lib/mako/ast.py 2009-09-07 21:28:05.000000000 +0200
@@ -1,5 +1,5 @@
# ast.py
-# Copyright (C) 2006, 2007, 2008 Michael Bayer mike_mp@zzzcomputing.com
+# Copyright (C) 2006, 2007, 2008, 2009 Michael Bayer mike_mp@zzzcomputing.com
#
# This module is part of Mako and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mako-0.2.4/lib/mako/codegen.py new/Mako-0.2.5/lib/mako/codegen.py
--- old/Mako-0.2.4/lib/mako/codegen.py 2008-12-23 04:43:44.000000000 +0100
+++ new/Mako-0.2.5/lib/mako/codegen.py 2009-09-07 21:28:05.000000000 +0200
@@ -1,5 +1,5 @@
# codegen.py
-# Copyright (C) 2006, 2007, 2008 Michael Bayer mike_mp@zzzcomputing.com
+# Copyright (C) 2006, 2007, 2008, 2009 Michael Bayer mike_mp@zzzcomputing.com
#
# This module is part of Mako and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
@@ -160,6 +160,12 @@
"""write a top-level render callable.
this could be the main render() method or that of a top-level def."""
+
+ if self.in_def:
+ decorator = node.decorator
+ if decorator:
+ self.printer.writeline("@runtime._decorate_toplevel(%s)" % decorator)
+
self.printer.writelines(
"def %s(%s):" % (name, ','.join(args)),
"context.caller_stack._push_frame()",
@@ -325,6 +331,10 @@
def write_inline_def(self, node, identifiers, nested):
"""write a locally-available def callable inside an enclosing def."""
namedecls = node.function_decl.get_argument_expressions()
+
+ decorator = node.decorator
+ if decorator:
+ self.printer.writeline("@runtime._decorate_inline(context, %s)" % decorator)
self.printer.writeline("def %s(%s):" % (node.name, ",".join(namedecls)))
filtered = len(node.filter_args.args) > 0
buffered = eval(node.attributes.get('buffered', 'False'))
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mako-0.2.4/lib/mako/exceptions.py new/Mako-0.2.5/lib/mako/exceptions.py
--- old/Mako-0.2.4/lib/mako/exceptions.py 2008-12-23 04:43:44.000000000 +0100
+++ new/Mako-0.2.5/lib/mako/exceptions.py 2009-09-07 21:28:05.000000000 +0200
@@ -1,5 +1,5 @@
# exceptions.py
-# Copyright (C) 2006, 2007, 2008 Michael Bayer mike_mp@zzzcomputing.com
+# Copyright (C) 2006, 2007, 2008, 2009 Michael Bayer mike_mp@zzzcomputing.com
#
# This module is part of Mako and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mako-0.2.4/lib/mako/ext/babelplugin.py new/Mako-0.2.5/lib/mako/ext/babelplugin.py
--- old/Mako-0.2.4/lib/mako/ext/babelplugin.py 2008-12-23 04:43:44.000000000 +0100
+++ new/Mako-0.2.5/lib/mako/ext/babelplugin.py 2009-09-07 21:28:05.000000000 +0200
@@ -22,7 +22,7 @@
template_node = lexer.Lexer(fileobj.read(),
input_encoding=encoding).parse()
for extracted in extract_nodes(template_node.get_children(),
- keywords, comment_tags, options):
+ keywords, comment_tags, options):
yield extracted
def extract_nodes(nodes, keywords, comment_tags, options):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mako-0.2.4/lib/mako/filters.py new/Mako-0.2.5/lib/mako/filters.py
--- old/Mako-0.2.4/lib/mako/filters.py 2008-12-23 04:43:44.000000000 +0100
+++ new/Mako-0.2.5/lib/mako/filters.py 2009-09-07 21:28:05.000000000 +0200
@@ -1,5 +1,5 @@
# filters.py
-# Copyright (C) 2006, 2007, 2008 Geoffrey T. Dairiki