You can customize the flash *HTML* by setting flash.static_template, but
this is rarely needed. To customize the *CSS*, you just have to add css
rules for "#flash" and maybe different rules for "#flash .info", "#flash
.warning" and "#flash .error" classes etc. as you like.
> It works great...except for when flash messages are created by the
> predicates. Unfortunately, the predicate.has_permission() function,
> does not accept a real flash object, so it must be creating it
> somewhere along the way with a hard-coded value.
Yes, the repoze.what authorization errors are hardcoded with 'error' or
'warning' status class. Other authorization errors use the status
attribute of the erros instance.
-- Christoph
Right, that would be a good reason to change the template. But usually
in such cases I just add the button via JavaScript. This has the
advantage that if JavaScript is not activated, not button appears as it
would be nonfunctional anyway.
> I also have a new notification called "information" that
> isn't built into TG. Does passing the second argument to flash() just
> pass that right along as the css class?
Exactly. You can name it whatever you like.
-- Christoph
--
You received this message because you are subscribed to the Google Groups "TurboGears" group.
To view this discussion on the web visit https://groups.google.com/d/msg/turbogears/-/UWw2OeNbdvcJ.
To post to this group, send email to turbo...@googlegroups.com.
To unsubscribe from this group, send email to turbogears+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/turbogears?hl=en.
Well, thinking about it, you have a few options.You can override the class, and set the static template. Nothing wrong with this, and could even be preferred, especially on higher traffic sites. It will only ever be handled once, and it's done.You can add your logic to your base controller (look at myproject.lib.base:BaseController). That method would work, but will incur an overhead on *every* request to your site. Small, but still there.You can continue as you have been, adding your logic to each controller method. Not very maintainable, and still incurs the penalty.You can re-check and make sure you actually need to be doing this. Most people, most of the time, should be able to get along with just updating their CSS files, resulting in no changes at all. This is the best, but is not always something that can be done. If you can, though, I would recommend it.That's really all the options I can come up with. I hope it helps somewhat.
On Fri, Jul 13, 2012 at 10:25 PM, Juparave <kan...@gmail.com> wrote:
Hello,
I wonder where exactly should I set flash.static_template.I want to change the template site-wide and so far what I manage to do is to add a declaration for flash.static_template in every controller.Should I override the class and set the static_template there?Thanks, I know is an old issue but so far google hasn't been my friend on this.
--
You received this message because you are subscribed to the Google Groups "TurboGears" group.
To view this discussion on the web visit https://groups.google.com/d/msg/turbogears/-/UWw2OeNbdvcJ.
To post to this group, send email to turbo...@googlegroups.com.
To unsubscribe from this group, send email to turbogears+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/turbogears?hl=en.
To view this discussion on the web visit https://groups.google.com/d/msg/turbogears/-/q3Ii_diIGQMJ.
To unsubscribe from this group, send email to turbogears+...@googlegroups.com.
Hello Michael,The patch needs some work, it was done in a hurry to test a possible solution.Maybe an option flag like as_list_items=True should return the alternate string.