Current

This document is valid for the current version of Plone.

Customize the ReadOnlyError Message

by Steve McMahon last modified Feb 03, 2011 10:10 PM
If you're putting Plone in read-only mode for maintenance, you may want to tell your users what's up.

It's a common maintenance procedure to make your Zope/Plone database read-only while performing maintenance or upgrades. If you do so, you may want to display a message to let users know.

The default error message template is an easy place to create such a message. All you need to do is detect the error created by an attempted database write and respond with a custom message.

The template for the standard error message is default_error_message.pt, which is in the plone_templates skin folder. You may customize this skin-layer template in an add-on product, or just create a temporary customization in the "custom" skin folder via the ZMI.

Just insert a message like:

<div tal:condition="python: err_type=='ReadOnlyError'">
  <p>Sorry! We're performing scheduled maintenance at this time, and it won't be possible to make any changes to your site content.</p>
  <p>Tell 'em where to contact the help staff with questions ...</p>
</div>

Checking for ReadOnlyError makes sure that the error message will only appear if the database is in read-only mode.

I've found it convenient to put this message right after the "We&#8217;re sorry, but there seems to be an error&hellip;" headline. You're welcome to put it elsewhere.

What about logins?

A Plone log in writes the login time to the last-login field in the member's record. That means that logging in provokes a ReadOnlyError. In this case, I think this is actually a convenience, since it will allow for warning your users before they try to do any real work.

 


Contribute

Something wrong or out of date? Anybody can edit or create a new article in the knowledge base. Simply create an account on this site, log in, and click the Edit button to contribute.