Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython
INSTALL>
pypm install z3ext.statusmessage

How to install z3ext.statusmessage

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install z3ext.statusmessage
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
1.4.0 Available View build log
Windows (64-bit)
1.4.0 Available View build log
Mac OS X (10.5+)
1.4.0 Available View build log
Linux (32-bit)
1.4.0 Available View build log
Linux (64-bit)
1.4.0 Available View build log
Web
 
Author
License
ZPL 2.1
Lastest release
version 1.4.0 on Jan 5th, 2011

Portal status message

Instead include notification messages directly to template, developer can use messaging service.

Main interface is IStatusMessage, it is adapter for IBrowserRequest so we can have different implementations, for example cookie based or session.

By default only session based service implemented.

>>> from zope import interface, component
>>> from zope.interface.verify import verifyClass
>>> from z3ext.statusmessage import interfaces, session, message
>>> verifyClass(interfaces.IStatusMessage, session.MessageService)
True
>>> component.provideAdapter(session.getMessageService)
>>> from zope.publisher.browser import TestRequest
>>> request = TestRequest()
>>> service = interfaces.IStatusMessage(request)
>>> bool(service)
False
>>> service.add('Test message')
Traceback (most recent call last):
...
ComponentLookupError: ...
>>> service.clear()
()

Before we can use message service we need register message type.

>>> component.provideAdapter(message.InformationMessage, name='info')
>>> msg = component.getAdapter(request, interfaces.IMessage, 'info')
>>> print msg.render('Test message')
<div class="statusMessage">Test message</div>

Now we can add messages.

>>> service.add('Test message')
>>> bool(service)
True
>>> for msg in service.messages():
...     print msg
<div class="statusMessage">Test message</div>

Let's register another message type.

>>> component.provideAdapter(message.WarningMessage, name='warning')
>>> service.add('Warning message', 'warning')
>>> for msg in service.messages():
...     print msg
<div class="statusMessage">Test message</div>
<div class="statusWarningMessage">Warning message</div>

Error message, we can add exception object

>>> component.provideAdapter(message.ErrorMessage, name='error')
>>> service.add(Exception('Error message'), 'error')

or text message

>>> service.add('Error message', 'error')
>>> for msg in service.messages():
...     print msg
<div class="statusMessage">Test message</div>
<div class="statusWarningMessage">Warning message</div>
<div class="statusStopMessage">Exception: Error message</div>
<div class="statusStopMessage">Error message</div>

Serive will oppress duplicated messages:

>>> service.add('Error message', 'error')
>>> for msg in service.messages():
...     print msg
<div class="statusMessage">Test message</div>
<div class="statusWarningMessage">Warning message</div>
<div class="statusStopMessage">Exception: Error message</div>
<div class="statusStopMessage">Error message</div>
Clearing service

clear() method return all messages and clear service.

>>> for msg in service.clear():
...     print msg
<div class="statusMessage">Test message</div>
<div class="statusWarningMessage">Warning message</div>
<div class="statusStopMessage">Exception: Error message</div>
<div class="statusStopMessage">Error message</div>
>>> bool(service)
False

CHANGES

1.4.0 (2009-08-11)
  • Use AfterCallEvent from z3ext.cacheheaders package
1.3.9 (2009-07-15)
  • Oppress duplicated messages
1.3.8 (2009-06-23)
  • Better checks for session service availability
1.3.7 (2009-06-04)
  • Added null status message service
1.3.6 (2009-06-01)
  • Fix publication afterCall handler
1.3.5 (2009-04-15)
  • Do not use z3c.autoinclude
1.3.4 (2009-03-12)
  • Added default css styles
1.3.3 (2008-11-27)
  • Handle error if session is not available
1.3.2 (2008-11-23)
  • Fixed tests agains zope3.4
1.3.1 (2008-11-21)
  • Fixed UnicodeEncodeError
1.3.0 (2008-11-20)
  • API refactored
  • Allow add messages at any stage of page processing
1.2.1 (2008-05-14)
  • Replace 'autoinclude' with 'includeDependendcies'
1.2.0 (2008-03-21)
  • rename to z3ext.statusmessage
  • moved to svn.zope.org
1.1.0 (2008-03-18)
  • Use z3c.autoinclude
  • Code cleanup
1.0.0 (2007-12-08)
  • Initial release.

Subscribe to package updates

Last updated Jan 5th, 2011

Download Stats

Last month:1

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.