Show More
@@ -355,7 +355,41 b' def is_following_repo(repo_name, user_id' | |||
|
355 | 355 | from rhodecode.model.scm import ScmModel |
|
356 | 356 | return ScmModel().is_following_repo(repo_name, user_id) |
|
357 | 357 | |
|
358 | flash = _Flash() | |
|
358 | class _Message(object): | |
|
359 | """A message returned by ``Flash.pop_messages()``. | |
|
360 | ||
|
361 | Converting the message to a string returns the message text. Instances | |
|
362 | also have the following attributes: | |
|
363 | ||
|
364 | * ``message``: the message text. | |
|
365 | * ``category``: the category specified when the message was created. | |
|
366 | """ | |
|
367 | ||
|
368 | def __init__(self, category, message): | |
|
369 | self.category=category | |
|
370 | self.message=message | |
|
371 | ||
|
372 | def __str__(self): | |
|
373 | return self.message | |
|
374 | ||
|
375 | __unicode__ = __str__ | |
|
376 | ||
|
377 | def __html__(self): | |
|
378 | return escape(safe_unicode(self.message)) | |
|
379 | ||
|
380 | class Flash(_Flash): | |
|
381 | ||
|
382 | def pop_messages(self): | |
|
383 | """Return all accumulated messages and delete them from the session. | |
|
384 | ||
|
385 | The return value is a list of ``Message`` objects. | |
|
386 | """ | |
|
387 | from pylons import session | |
|
388 | messages = session.pop(self.session_key, []) | |
|
389 | session.save() | |
|
390 | return [_Message(*m) for m in messages] | |
|
391 | ||
|
392 | flash = Flash() | |
|
359 | 393 | |
|
360 | 394 | #============================================================================== |
|
361 | 395 | # SCM FILTERS available via h. |
General Comments 0
You need to be logged in to leave comments.
Login now