I'm upgrading an existing TG2 site and having problems. I put what you described in my master template but get the following error: http://beta.pylonshq.com/tracebacks/30c47ca627f51fffe2a56298936fd4db
Is there something I'm missing? cheers. -chris On Jan 18, 11:12 am, Alberto Valverde <[email protected]> wrote: > Jorge Vargas wrote: > >> If someone wants to cook a widget or something for this or add a config > >> option so TG can use one or the other or something the community will > >> appreciate it (hint, Jorge, hint ;) > > > Ok I will :) But I can't promise I could get some time before b3, it > > seems we are going to have b4 so I don't see this as a problem (nor a > > blocker), of course for this to work what you say below has to be > > implemented, which I'm +1 > > Nevermind, I already implemented a helper :) read below... > > > > > > >> One more thing: I'd finally like to change the DOM structure and CSS of > >> the quickstart template to match the structure generated by the JS > >> version. Mainly so both versions can be used interchangeably and because > >> the current one sucks ;) Why? Because: > > >> 1) The class of the message should be conveyed in a... class attribute. > >> The current implementation makes impossible to refer to the *unique* div > >> that holds theflashin a reliable way from JS code. The id should > >> remain static, the class should vary with the kind of message (not the > >> other way around) > > >> 2) If theflashmessage is wrapped in a div inside the "flash" div then > >> one can implement floating centered messages easily. > > >> To make it easy to visualize, the dom structure that the js code > >> generates is like this: > > >> <div id="some_id_of_your_liking"> > >> <div class="status_code">Message</div> > >> </div> > > >> So the CSS style this could be something like: > > >> #some_id_of_your_liking { > >> display: none; /* Recommended so a conditional can be avoided, the > >> JS code will make it visible */ > >> ... > >> } > > >> #some_id_of_your_liking .ok { ....} > >> #some_id_of_your_liking .warn { ....} > >> #some_id_of_your_liking .error { ....} > > >> Please strip the status_X prefix from the status code names, it is > >> redundant to say: > > >>flash("lalalala", status="status_ok") > >> much nicer (IMHO) and less typing (mathematically provable): > >>flash("lalala", status="ok") > > >> If no one object I'll implement these *slightly* breaking changes (for > >> existing users) tomorrow. Note that the default will still be non-js > >>flashmessages, I'm just proposing to change the dom structure and CSS > >> to keep both in sync so it is easy to change between them. > > Done in: > > http://trac.turbogears.org/changeset/6114http://trac.turbogears.org/changeset/6115http://trac.turbogears.org/changeset/6116http://trac.turbogears.org/changeset/6117 > > The quickstart template has been updated to the new DOM structure and > existing apps should continue working but show deprecation warnings. > > How to upgraded your existsing apps (the following instructions could be > copy and pasted somewhere in the CHANGELOG) > > 1) Theflashmessage is now rendered like this (in a genshi template) > > <py:with vars="flash=tg.flash_obj.render('flash', use_js=False)"> > <div py:if="flash" py:content="XML(flash)" /> > </py:with> > > Note that the tg.flash_obj.render() method returns a string so we need > to use the XML wrapper (not the HTML!) so genshi doesn't escape the html > entities. The conditional is so XML doesn't barf when there's noflash > (and we're not using JS) since render() will return an empty string. > > To enable JSflashmessages and be able to cache your pages just pass > use_js=True to the render() method > > 1.5) Using the helper in string based templates is easier, just do: > > ${tg.flash_obj.render('flash', use_js=False)} > > 2) Upgrade the your CSS to the new DOM structure, which is: > > <div ="$flash_id"> > <div class="$status">$message</div> > </div> > > The one in the quickstart template looks like: > > #flash{ > font-size:120%; > font-weight:bolder; > margin:0pt auto 0.5em; > width:680px;} > > #flashdiv { > padding:5px 15px 15px 55px;} > > #flash.ok { > background:#EEEEFF url(../images/ok.png) no-repeat scroll left center; > border:1px solid #CCCCEE;} > > #flash.warning { > background:#FF9999 url(../images/error.png) no-repeat scroll left center; > border:1px solid #FF3333;} > > #flash.alert { > background:#FFFF99 url(../images/info.png) no-repeat scroll left center; > border:1px solid #FFFF00; > > } > > 3) Change your code so the status string you pass toflash() does not > contain the "status_" prefix, eg: > > status_ok -> ok > status_warning -> warning > status_alert -> alert > > This step might not be needed if you use custom status codes > > The tg.flashand tg.flash_status variables in the template have been > deprecated, the equivalents are tg.flash_obj.status and > tg.flash_obj.message. Note that any access to these will remove the > cookie so do not access them if using JS to render the messages. > > Enjoy, > Alberto --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "TurboGears Trunk" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/turbogears-trunk?hl=en -~----------~----~----~----~------~----~------~--~---
