Permalink
Browse files

Document WebFlash

  • Loading branch information...
1 parent f284228 commit 70aac3e0f8cf5f09f397295d18cb72ae6a48fe3a @amol- amol- committed Apr 3, 2012
Showing with 70 additions and 0 deletions.
  1. +69 −0 docs/main/WebFlash.rst
  2. +1 −0 docs/tutorials.rst
View
@@ -0,0 +1,69 @@
+.. _webflash:
+
+=================================
+Displaying Flash/Notice Messages
+=================================
+
+TurboGears provides a way to display short messages inside the current
+or next page. This works by using the WebFlash module which stores
+short text messages inside a cookie so that it can be retrieved
+when needed.
+
+Default Setup
+================
+
+By Default the `master.html` of a quickstarted project provides a div
+where flash messages will be displayed, this is achieved with the
+following lines of code:
+
+.. code-block:: html+genshi
+
+ <py:with vars="flash=tg.flash_obj.render('flash', use_js=False)">
+ <div py:if="flash" py:replace="Markup(flash)" />
+ </py:with>
+
+The ``tg.flash_obj`` is the WebFlash object which is available inside
+any rendered template. This object permits to retrieve the current
+flash message and display it.
+
+Storing Flash Messages
+==========================
+
+Flash messages can be stored using the ``tg.flash`` command
+this allows to store a message with a status option to configure
+the flash style.
+
+.. code-block:: python
+
+ tg.flash('Message', 'status')
+
+If the method that called flash performs a redirect the flash
+will be visible inside the redirected page.
+If the method directly exposes a template the flash will be
+visible inside the template itself.
+
+Styling the Flash
+==========================
+
+By default `warning`, `error`, `info`, `ok` statuses
+provide a style. Any number of statuses can be configured
+using plain css:
+
+.. code-block:: css
+
+ #flash .ok {
+ background:#d8ecd8 url(../images/ok.png) no-repeat scroll 10px center;
+ }
+
+ #flash .warning {
+ background:#fff483 url(../images/warning.png) no-repeat scroll 10px center;
+ }
+
+ #flash .error {
+ background:#f9c5c1 url(../images/error.png) no-repeat scroll 10px center;
+ }
+
+ #flash .info {
+ background:#EEEEFF url(../images/info.png) no-repeat scroll 10px center;
+ }
+
View
@@ -20,6 +20,7 @@ to get start with your first real web application.
main/BasicMoves
TurboGears Book: 20 Minutes Wiki Tutorial <http://www.turbogears.org/book/part1/wiki20.html>
main/TwForms
+ main/WebFlash
==================
Advanced Tutorials

0 comments on commit 70aac3e

Please sign in to comment.