On Apr17, 2:37am, Iceberg <iceb...@21cn.com> wrote: > On Apr16, 3:05pm, Fran <francisb...@googlemail.com> wrote: > > > On Apr 16, 3:13 am, Iceberg <iceb...@21cn.com> wrote: > > > > Currently I think most of us use response.flash as a resort to give > > > all kinds of feedback. > > > I have this in my model: > > > def shn_sessions(f): > > ... > > > My layout.html contains: > > ... > > > My CSS: > > ... > > Glad to have Fran and Jason's feedback. Fran's example is more > intuitive, although he forgot to mention similar modification is > needed in web2py_ajax.html, by the way I use the name response.info > instead of response.confirmation. >
Further improvement for Fran's work. Now I don't need to modify model or style.css or web2py_ajax.html, just put this little patch into the layout.html to replace the original flash part: {{if isinstance(response.flash,dict):}} <div class="flash" style="color:#070; background:{{={ 'info':'#E5FFE5', #light green 'warn':'#FFC', #light yellow 'error':'#FFE5E5', #light pink }.get(response.flash.keys()[0],'#FFC')}}"> {{=response.flash.values()[0]}}</div> {{elif response.flash:}} <div class="flash">{{=response.flash}}</div> {{pass}} Now you can use these convention in your controller: response.flash={'warn':'your input is unusual, but anyway the data is accepted'} or: response.flash={'info':'ok, data is accepted'} or: response.flash={'error':'Something is wrong'} and the best thing is, it is still backward compatible, you can still use old response.flash='appear in an orange bar' To Massimo: Hope you like it enough so that you will include this inside the out-of-box web2py. :-) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---