Opened 19 years ago
Closed 19 years ago
#116 closed defect (fixed)
*args and **kargs don't work in templates
| Reported by: | jjinux@… | Owned by: | cmlenz |
|---|---|---|---|
| Priority: | major | Milestone: | 0.4.1 |
| Component: | Template processing | Version: | 0.4 |
| Keywords: | Cc: |
Description
If I write a function that accepts *args and kargs and then call it, it crashes:
<py:def function="f(*args, **kargs)"
${args}
${kargs}
</py:def>
...
${f(1, 2, a=3, b=4)}
This produces, in my app anyway, something that looks like:
Module acctmgr.controllers.login:61 in login
<< 'http://foxmarks.com'))
c.defaults = DefaultsList([request.params])
return render_response('login')
def _login(self, username):>> return render_response('login')
Module pylons.templating:302 in render_response
<< return render_response('/my/template.myt')
"""
response = pylons.Response(render(*args, **kargs))
output_encoding = kargs.get('output_encoding')
encoding_errors = kargs.get('encoding_errors')>> response = pylons.Response(render(*args, **kargs))
Module pylons.templating:288 in render
<< namespace=kargs, **cache_args)
return pylons.buffet.render(template_name=template, fragment=fragment,
namespace=kargs, **cache_args)
def render_response(*args, **kargs):>> namespace=kargs, **cache_args)
Module pylons.templating:198 in render
<< return content
return engine_config['engine'].render(namespace, template=full_path,
**options)
>> return engine_config['engine'].render(namespace, template=full_path,
Module genshi.template.plugin:99 in render
Module genshi.template.plugin:146 in transform
Module genshi.template.plugin:104 in transform
Module genshi.template.plugin:86 in load_template
Module genshi.template.loader:203 in load
Module genshi.template.markup:75 in __init__
Module genshi.template.base:321 in __init__
genshi.template.base.TemplateSyntaxError: not well-formed (invalid token): line 44, column 4 (/home/jj/work/foxmarks/src/foxmarks/apps/acctmgr/acctmgr/templates/login.html, line 44)
(Ignore the .myt thing. I think that might be a comment in Pylons or something.)
Attachments (1)
Change History (3)
comment:1 Changed 19 years ago by cmlenz
- Component changed from Expression evaluation to Template processing
- Milestone changed from 0.5 to 0.4.1
- Status changed from new to assigned
comment:2 Changed 19 years ago by cmlenz
- Resolution set to fixed
- Status changed from assigned to closed
Note: See
TracTickets for help on using
tickets.

The traceback you provided is actually due to a missing > to close the <py:def> start tag ;-)
Anyway, you're still absolutely right that *args and **kwargs don't work with py:def at the moment. I'm attaching a patch against trunk that implements the missing support. The patch should also work against 0.4.x, so feel free to try it out.