:-)

On Fri, Apr 17, 2009 at 9:47 PM, Iceberg <iceb...@21cn.com> wrote:

>
> Well, I don't like hardcoded magic numbers either. :-)
>
> My original proposal is purposely simple, only one file is invoked, so
> I hope to impress Massimo to make it official. :-P   If Massimo adapts
> your proposal, it is definitely better. :-)
>
> On Apr18, 5:32am, Yarko Tymciurak <yark...@gmail.com> wrote:
> > Is there any reason these colors need to be hardcoded "magic numbers"
> > (literal constants), rather than symbolic & programmatic?
> > For example:
> >
> >        {{if isinstance(response.flash,dict):}}
> >          <div class="flash" style="{{="color:"+flash.color}}";
> > background:{{={
> >            'info':flash.info, #light green by default 0.py
> >            'warn':flash.warn, #light yellow by default
> >            'error':flash.error, #light pink - blech! make that red by
> > default ;-)
> >            }.get(response.flash.keys()[0],flash.some_var_to_hold
> > this_last_ugly_constant) # what is this? #FFC')}}">
> >          {{=response.flash.values()[0]}}</div>
> >        {{elif response.flash:}}
> >          <div class="flash">{{=response.flash}}</div>
> >        {{pass}}
> >
> > (you get the idea that I dislike "magic number" constants ;-)).
> >
> > There is probably some better way than this, but getting the constants
> under
> > application control is what I'm trying to suggest.
> >
> > Regards,
> > -Yarko
> >
> > On Fri, Apr 17, 2009 at 3:54 PM, mdipierro <mdipie...@cs.depaul.edu>
> wrote:
> >
> > > I like it. This may not be compatible with this
> > >http://www.web2py.com/events/default/index
> > > but we can find a combination of the two that works.
> >
> > > On Apr 17, 1:49 pm, Iceberg <iceb...@21cn.com> wrote:
> > > > 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to