[Checkins] SVN: z3c.pt/trunk/ Fixed issue where non-keyword arguments were not passed in correctly.
Malthe Borch
mborch at gmail.com
Mon Apr 19 09:23:27 EDT 2010
Log message for revision 111090:
Fixed issue where non-keyword arguments were not passed in correctly.
Changed:
U z3c.pt/trunk/CHANGES.txt
U z3c.pt/trunk/src/z3c/pt/README.txt
U z3c.pt/trunk/src/z3c/pt/pagetemplate.py
-=-
Modified: z3c.pt/trunk/CHANGES.txt
===================================================================
--- z3c.pt/trunk/CHANGES.txt 2010-04-19 12:42:27 UTC (rev 111089)
+++ z3c.pt/trunk/CHANGES.txt 2010-04-19 13:23:26 UTC (rev 111090)
@@ -1,17 +1,12 @@
Changelog
---------
-1.1.3 (unreleased)
-------------------
+In next release...
-- Your change here..
+- Fixed regression introduced with ``args`` being passed
+ in. Incidentally, the name ``args`` was used as the star argument
+ name.
-
-1.1.2 (2010/04/14)
-------------------
-
-- Make sure the interpolation flag is recursive.
-
1.1.1 (2010/04/06)
------------------
Modified: z3c.pt/trunk/src/z3c/pt/README.txt
===================================================================
--- z3c.pt/trunk/src/z3c/pt/README.txt 2010-04-19 12:42:27 UTC (rev 111089)
+++ z3c.pt/trunk/src/z3c/pt/README.txt 2010-04-19 13:23:26 UTC (rev 111090)
@@ -214,7 +214,6 @@
</div>
</div>
-
Text templates
--------------
@@ -237,6 +236,30 @@
>>> print template.bind(view)(color=u'#ccc')
print "<html>#ccc</html>";
+Non-keyword arguments
+---------------------
+
+These are passed in as ``options/args``, when using the ``__call__`` method.
+
+ >>> print PageTemplate("""\
+ ... <div xmlns="http://www.w3.org/1999/xhtml">
+ ... <div tal:repeat="arg options/args">
+ ... <span tal:content="arg" />
+ ... </div>
+ ... </div>""").__call__(1, 2, 3)
+ <div xmlns="http://www.w3.org/1999/xhtml">
+ <div>
+ <span>1</span>
+ </div>
+ <div>
+ <span>2</span>
+ </div>
+ <div>
+ <span>3</span>
+ </div>
+ </div>
+
+
Global 'path' Function
----------------------
Modified: z3c.pt/trunk/src/z3c/pt/pagetemplate.py
===================================================================
--- z3c.pt/trunk/src/z3c/pt/pagetemplate.py 2010-04-19 12:42:27 UTC (rev 111089)
+++ z3c.pt/trunk/src/z3c/pt/pagetemplate.py 2010-04-19 13:23:26 UTC (rev 111090)
@@ -101,7 +101,7 @@
default_parser = language.Parser()
version = 2
- def bind(self, ob, request=None, macro=None, global_scope=True):
+ def bind(self, ob=None, request=None, macro=None, global_scope=True):
def render(target_language=None, request=request, **kwargs):
context = self._pt_get_context(ob, request, kwargs)
request = request or context.get('request')
@@ -136,8 +136,8 @@
return BoundPageTemplate(self, render)
- def __call__(self, _ob=None, *args, **kwargs):
- bound_pt = self.bind(_ob)
+ def __call__(self, *args, **kwargs):
+ bound_pt = self.bind()
return bound_pt(*args, **kwargs)
def _pt_get_context(self, instance, request, kwargs):
@@ -234,8 +234,8 @@
def __call__(self, _ob=None, context=None, request=None, **kwargs):
kwargs.setdefault('context', context)
kwargs.setdefault('request', request)
- return super(ViewPageTemplate, self).__call__(
- _ob=_ob, **kwargs)
+ bound_pt = self.bind(_ob)
+ return bound_pt(**kwargs)
class ViewPageTemplateFile(ViewPageTemplate, PageTemplateFile):
"""If ``filename`` is a relative path, the module path of the
@@ -254,7 +254,8 @@
filename = property(lambda self: self.im_self.filename)
def __call__(self, *args, **kw):
- return self.im_func(args=args, **kw)
+ kw.setdefault('args', args)
+ return self.im_func(**kw)
def __setattr__(self, name, v):
raise AttributeError("Can't set attribute", name)
More information about the checkins
mailing list