Ñò üù¼Ic @sÝddkZddklZlZddklZyddkZWnej oddkZnXdgZ dei jZ ee ƒZ defd„ƒYZhdd6d d 6d d 6d d6dd6Zd„Zd„ZdS(iÿÿÿÿN(tquotetunquote(t getLoggertFlashtWEBFLASH_DEBUGcBs³eZdZdZdZdZddddded„Zd„Z d„Z e e e ƒZ dddd„Z d „Zd „Zeddd „Zd „Zd „Zddd„ZRS(s§ A flash message creator. *Parameters (all optional):* `cookie_name` The name of the cookie that will be used as transport `default_status` The CSS class that will be added to the flash container when it is not passed explicitly when calling the Flash instance. `get_response` A callable that will provide the response object of the framework if no explicit response is passed when calling the Flash instance. `js_path` Shall you want to override the JS code that will display the flash message then pass the path to where the file lives. Note that this is a path within the file-system, not a URL `debug` Should the JS code be provided in an uncompressed form (provided that js_path has not been overriden) and reloaded every time a page is rendered? Flash needs a Reponse object with a `set_cookie` method, like WebOb's :class:`webob.Response`. We'll mock one for demonstration purposes:: >>> class MyResponse(object): ... def set_cookie(self, name, value): ... pass The :class:`Flash` object could be instantiated once for the lifetime of an application and be kept at module scope (or a request-local object if the framework provides one). A :meth:`get_response` callable is useful in this case if the framework provides a global response to avoid passing the response object around on every call to the :class:`Flash` instance:: >>> flash = Flash(get_response=lambda: MyResponse()) Displaying the flash message is done by calling the Flash instance from your controller/view code:: >>> flash("All your data has been erased and your identity destroyed") >>> flash("Stuff broke", status="error") To insert the JavaScript code needed for Flash to work you need to insert the result of the :meth:`render` method on every page you might want to display flash messages (normally all of them, so you might want to include the call in a base template):: >>> _ = flash.render("flash-container") sq
sJ
%(message)s
twebflashtokcCsu||_|pd„|_|pd„|_||_|p t|ƒ|_|pt|iƒiƒ|_ndS(NcSsdS(N(tNone(((s5/usr/lib/python2.6/site-packages/webflash/__init__.pytYscSsdS(N(R(((s5/usr/lib/python2.6/site-packages/webflash/__init__.pyRZs( tdefault_statust get_responset get_requestt cookie_namet _get_js_pathtjs_pathtopentreadtjs_code(tselfR R R R Rtdebug((s5/usr/lib/python2.6/site-packages/webflash/__init__.pyt__init__Us  cCs|ipt|iƒiƒS(N(t_js_codeRRR(R((s5/usr/lib/python2.6/site-packages/webflash/__init__.pyt _get_js_codeascCs ||_dS(N(R(Rtvalue((s5/usr/lib/python2.6/site-packages/webflash/__init__.pyt _set_js_codecscKsÃ|p |iƒ}|djotdƒ‚n|id|d|p|i|}|p |iƒ}|dj o*||ids<tR;RtobjectRRFR3R (((s5/usr/lib/python2.6/site-packages/webflash/__init__.pyts$   ®