On 7/9/07, Thomas Guettler <[EMAIL PROTECTED]> wrote: > Messages should be stored with sessions. > > I would like to enhance the message system by a loglevel: > > debug, info, error. > > This way you could display important messages different.
There was some discussion on this a while back, and my main concern with that, is whether or not those are sufficient for everybody. For instance, many projects would probably benefit more from "success" and "failure" info than the ones you mention. I'm not sure there's a way to make everybody (or even a majority) happy on this. It's worth trying, but I'm not holding my breath. > Since session based messages have no database model. Adding > a loglevel would not brake old code: > > create_message(self, message, level="info") > > get_and_delete_messages(self, withlevel=False) > > If you pass withlevel=True you would get tuples: > [("info", "..."), ("error", "...") ...] Doing it this way seems problematic to me. This would require views and templates to be a bit too in-sync for my taste. For instance, if a template is written to expect just a string for each message, the developer can't add the level information without having a designer modify the template to match it. Instead, I would suggest using a Message class that could encapsulate that functionality. Essentially, rather than assigning a string to session.messages, you would create Message('message', level='debug'). That way, the Message class could have a __str__ that simply returns the message itself, allowing templates to not worry about the fact that it's a class, or whether the level is included or not. {{ message }} would work just fine, while {{ message.level }} would also work. And with that, I would think that levels would always be included, rather than your "withlevel" argument. All in all though, I think this still needs a considerable amount of discussion to figure out how it should proceed, in addition to a good bit of work to make it more useful. -Gul --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-developers?hl=en -~----------~----~----~----~------~----~------~--~---