On Wed, Dec 29, 2010 at 10:56:29AM -0800, Seth wrote:
> With regards to the flash messaging API, is there a reason why you chose not 
> to provide a method which returns *any* flash message from any queue 
> (preferably with a msg:queue key:val)? It would sure make template code 
> easier if I *do* want different queues but *don't* really need them to be 
> displayed in a complex manner in my templates.
> 
> For example, something like this would be nice to be able to do in my jinja2 
> templates (without having to write my own session helpers):
> 
> {% if request.session.peek_flashes() %}
> <div id="flash">
>     {% for flash in request.session.pop_flashes() %}
>         <div class="{{flash['queue'] or 
> 'noqueue'}}">{{flash['message']}}</div>
>     {% endfor %}
> </div>
> {% endif %}

The docs say that messages don't have to be strings, so you can do
exactly that, if you push dicts like this:

  request.session.flash(dict(message='Hello!', queue='welcome')).

Or you could push tuples.  Or a custom subclass of unicode with a
'css_class' attribute -- just make sure it's pickleable.

Marius Gedminas
-- 
Only great masters of style can succeed in being obtuse.
                -- Oscar Wilde

Most UNIX programmers are great masters of style.
                -- The Unnamed Usenetter

Attachment: signature.asc
Description: Digital signature

Reply via email to