Ticket #273 (closed defect: wontfix)
HTMLFormFiller has wrong __call__ signature for use by Template.generate()
| Reported by: | mitch@… | Owned by: | cmlenz |
|---|---|---|---|
| Priority: | major | Milestone: | |
| Component: | Template processing | Version: | 0.5.1 |
| Keywords: | Cc: |
Description
HTMLFormFiller's __call__ signature is:
def __call__(self, stream):
Template.generate() calls filters via:
for filter_ in self.filters:
stream = filter_(iter(stream), ctxt, **vars)
This causes an error if you try to insert a filter into a template's list of filters in a "template_loaded" callback function:
def template_loaded(template):
filler = HTMLFormFiller(data=dict(name='Joe', remember=True))
template.filters.insert(0, filler)
A simple workaround is to wrap HTMLFormFiller:
class FormFiller(object):
def __init__(self, *args, **kwargs):
self.filler = HTMLFormFiller(*args, **kwargs)
def __call__(self, stream, ctxt):
return self.filler(stream)
Then:
def template_loaded(template):
filler = FormFiller(data=dict(name='Joe', remember=True))
template.filters.insert(0, filler)
Attachments
Change History
Note: See
TracTickets for help on using
tickets.
