Quantcast
Channel: dev sniper » Pyramid Framework
Viewing all articles
Browse latest Browse all 9

Pyramid framework tips : Flash messages

$
0
0

flash msg

flash msg error

In Pyramid Applications you can set Flash messages in sessions. To use flash messaging, you must enable a session factory. For pyramid_beaker add-on: Pyramid framework tips : Beaker session factory settings
In your controller code after save, update or delete:

  dbsession.add(category)
  # warning; is for css class
  request.session.flash("warning;New Category is saved!")

In mako templates:

${self.flash_messages()} ${next.body()}
## flash messages with css class und fade in options <%def name="flash_messages()"> % if request.session.peek_flash(): <% flash = request.session.pop_flash() %> % for message in flash:
× ${message.split(";")[1]}
% endfor % endif <%def>

I am using Bootstrap from Twitter for css and javascripts with jQuery


Viewing all articles
Browse latest Browse all 9

Trending Articles