Em Ter, 2008-01-08 às 16:59 -0800, vandevel escreveu:
> This is just a simple question about displaying messages. I am
> wondering if there is a standard way to propagate error messages to
> the ui in cases where validation does not occur using the form encode
> validators(i.e. complex business rules validation that is performed in
> the body of a controller method). My initial thought is to use the
> flash function however, it does not appear that a message status type
> can be specified and I don't necessarily want to display all messages
> with the same format/style. Any advice would be appreciated!
I will do a Simple resolution here, note about I am using Genshi as
template engine.
create your own function in an util module like folows:
---
def flash_information(message):
flash(dict(message=message, status='information'))
def flash_error(message):
flash(dict(message=message, status='error'))
---
then use these functions instead of flash from tg.
in your template do something like this:
<div py:with="f = eval(tg_flash)" id="status_block" py:if="tg_flash"
class="flash_${f['status']}" py:content="f['message']"></div>
Now for flash_information you will have the flash_information class at
message box and for flash_error you will get the flash_error class.
I am not sure if it is secure, but is a simple solution for this problem
if somebody have some objection about this, please let me know
--
Alexandre da Silva
Analista de Sistemas - Bacharel em Sistemas de Informação (2003-2007)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" 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?hl=en
-~----------~----~----~----~------~----~------~--~---