Show More
@@ -406,6 +406,25 b' class _Message(object):' | |||
|
406 | 406 | |
|
407 | 407 | class Flash(_Flash): |
|
408 | 408 | |
|
409 | def __call__(self, message, category=None, ignore_duplicate=False, logf=None): | |
|
410 | """ | |
|
411 | Show a message to the user _and_ log it through the specified function | |
|
412 | ||
|
413 | category: notice (default), warning, error, success | |
|
414 | logf: a custom log function - such as log.debug | |
|
415 | ||
|
416 | logf defaults to log.info, unless category equals 'success', in which | |
|
417 | case logf defaults to log.debug. | |
|
418 | """ | |
|
419 | if logf is None: | |
|
420 | logf = log.info | |
|
421 | if category == 'success': | |
|
422 | logf = log.debug | |
|
423 | ||
|
424 | logf('Flash %s: %s', category, message) | |
|
425 | ||
|
426 | super(Flash, self).__call__(message, category, ignore_duplicate) | |
|
427 | ||
|
409 | 428 | def pop_messages(self): |
|
410 | 429 | """Return all accumulated messages and delete them from the session. |
|
411 | 430 |
General Comments 0
You need to be logged in to leave comments.
Login now