diff --git a/modules/miscutil/doc/hacking/miscutil-dateutils.webdoc b/modules/miscutil/doc/hacking/miscutil-dateutils.webdoc
index e539d3dd0..0e81cfa46 100644
--- a/modules/miscutil/doc/hacking/miscutil-dateutils.webdoc
+++ b/modules/miscutil/doc/hacking/miscutil-dateutils.webdoc
@@ -1,180 +1,179 @@
+## -*- mode: html; coding: utf-8; -*-
 ## $Id$
 ## This file is part of CDS Invenio.
 ## Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 CERN.
 ##
 ## CDS Invenio is free software; you can redistribute it and/or
 ## modify it under the terms of the GNU General Public License as
 ## published by the Free Software Foundation; either version 2 of the
 ## License, or (at your option) any later version.
 ##
 ## CDS Invenio is distributed in the hope that it will be useful, but
 ## WITHOUT ANY WARRANTY; without even the implied warranty of
 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 ## General Public License for more details.
 ##
 ## You should have received a copy of the GNU General Public License
 ## along with CDS Invenio; if not, write to the Free Software Foundation, Inc.,
 ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
 
 <!-- WebDoc-Page-Title: Date library -->
-<!-- WebDoc-Page-Navbar-Name:hacking-miscutil-dateutils -->
 <!-- WebDoc-Page-Navtrail: <a class="navtrail" href="<WEBURL>/help/hacking">Hacking CDS Invenio</a> &gt; <a class="navtrail" href="<WEBURL>/miscutil-internals">MiscUtil Internals</a> -->
-<!-- WebDoc-Page-Navbar-Select: hacking-miscutil-dateutils> -->
 <!-- WebDoc-Page-Revision: $Id$-->
 
 <p>These are the functions and methodologies for date handling in CDS Invenio.</p>
 
 
 <h2>Contents</h2>
 <ol>
 <li><a href="#overview">Overview</a></li>
 <li><a href="#converting">Converting dates</a></li>
 <li><a href="#i18n">Internationalizing parts of dates</a></li>
 <li><a href="#generating">Generating GUI elements</a></li>
 </ol>
 
 
 <h2>1. <a name="overview">Overview</a></h2>
 
 Three ways of representing dates  are handled by this library:
 
 <dl>
     <dt><b>datetext:</b></dt>
     <dd>textual format =&gt; <code>'YEAR-MONTH-DAY HOUR:MINUTE:SECOND'</code><br />
         e.g. <code>'2005-11-16 15:11:44'</code><br />
         default value: <code>'0000-00-00 00:00:00'</code><br />
         This format is the the one used by current Database for storing dates.
     </dd>
 
     <dt><b>datestruct:</b></dt>
     <dd>
         tuple format =&gt; see <a href="http://docs.python.org/lib/module-time.html">Python reference</a> <br />
         <code>(YEAR, MONTH, DAY, HOUR, MINUTE, SECOND, WEEKDAY, YEARDAY, DAYLIGHT)</code><br />
         e.g. <code>(2005, 11, 16, 15, 11, 44, 2, 320, 0)</code><br />
         default value: <code>(0, 0, 0, 0, 0, 0, 0, 0, 0)</code><br />
         This format is the one used by python. Time module provides methods for
         calculations.
     </dd>
 
     <dt><b>dategui:</b></dt>
     <dd>
         textual format for output =&gt; <code>'DAY MONTH YEAR, HOUR:MINUTE'</code><br />
         e.g. <code>'16 nov 2005, 15:11'</code>
         default value: <code>&#95;("N/A")</code>
     </dd>
 </dl>
 <p>The dateutils python module provides ways of converting between these formats.
 The default value is used whenever a date is non-valid (for python, dates before
 epoch are unvalid!).</p>
 
 <h2>2. <a name="converting">Converting dates</a></h2>
 The functions for conversion are listed below.
 <dl>
     <dt><b><code>convert&#95;datestruct&#95;to&#95;dategui(datestruct, ln=cdslang)</code></b></dt>
     <dd>
         <code>(2005, 11, 16, 15, 11, 44, 2, 320, 0) =&gt; '16 nov 2005, 15:11'</code><br/>
         Month is internationalized
     </dd>
     <dt><b><code>convert&#95;datestruct&#95;to&#95;datetext(datestruct)</code></b></dt>
     <dd>
         <code>(2005, 11, 16, 15, 11, 44, 2, 320, 0) =&gt; '2005-11-16 15:11:57'</code>
     </dd>
 
     <dt><b><code>convert&#95;datetext&#95;to&#95;dategui(datetext, ln=cdslang)</code></b></dt>
     <dd>
         <code>'2005-11-16 15:11:57' =&gt; '16 nov 2005, 15:11'</code><br />
         Month is internationalized
     </dd>
 
     <dt><b><code>convert&#95;datetext&#95;to&#95;datestruct(datetext)</code></b></dt>
     <dd>
         <code>'2005-11-16 15:11:57' =&gt; (2005, 11, 16, 15, 11, 44, 2, 320, 0)</code>
     </dd>
 
     <dt><b><code>get&#95;datestruct(year, month, day)</code></b></dt>
     <dd>
         <code>year=2005, month=11, day=16 =&gt; (2005, 11, 16, 0, 0, 0, 2, 320, -1)</code>
     </dd>
 
     <dt><b><code>get&#95;datetext(year, month, day)</code></b></dt>
     <dd>
         <code>year=2005, month=11, day=16 =&gt; '2005-11-16 00:00:00'</code>
     </dd>
 </dl>
 
 <h2>3. <a name="i18n">Internationalizing parts of dates</a></h2>
 
 The following functions provide means of internationalizing part of dates.
 
 <dl>
     <dt>
       <b><code>get&#95;i18n&#95;day&#95;name(day&#95;nb, display='short', ln=cdslang)</code></b>
     </dt>
     <dd>
         get the string representation of a weekday, internationalized<br />
         <code>
 @param day&#95;nb: number of weekday UNIX like. =&gt; 0=Sunday<br />
 @param ln: language for output<br />
 @return the string representation of the day
         </code>
     </dd>
     <dt>
         <b><code>get&#95;i18n&#95;month&#95;name(month&#95;nb, display='short', ln=cdslang)</code></b>
     </dt>
     <dd>
         get a non-numeric representation of a month, internationalized.<br />
         <code>
 @param month&#95;nb: number of month, (1 based!) =&gt; 1=jan,..,12=dec<br />
 @param ln: language for output<br />
 @return the string representation of month
         </code>
     </dd>
 </dl>
 
 <h2>4. <a name="generating">Generating GUI elements</a></h2>
 
 The following functions create HTML fields for date selection:
 <dl>
 
 <dt>
     <b><code>create&#95;day&#95;selectbox(name, selected&#95;day=0, ln=cdslang)</code></b>
 </dt>
 <dd>Creates an HTML menu for day selection. (<code>0..31</code> values).<br />
 <code>@param name: name of the control (i.e. name of the var you'll get)<br />
 @param selected&#95;day: preselect a day. Use 0 for the label 'Day'<br />
 @param ln: language of the menu<br />
 @return html as string
 </code>
 </dd>
 <dt>
     <b><code>create&#95;month&#95;selectbox(name, selected&#95;month=0, ln=cdslang)</code></b>
 </dt>
 <dd>Creates an HTML menu for month selection. Value of selected field is numeric<br />
 <code>@param name: name of the control (your form will be sent with name=value...)<br />
 @param selected&#95;month: preselect a month. use 0 for the Label 'Month'<br />
 @param ln: language of the menu<br />
 @return html as string
 </code>
 </dd>
 <dt>
     <b><code>create&#95;year&#95;inputbox(name, value=0)</code></b>
 </dt>
 <dd>
 Creates an HTML field (simple input) for year selection.<br />
 <code>@param name: name of the control (i.e. name of the variable you'll get)<br />
 @param value: prefilled value (int)<br />
 @return html as string
 </code>
 <dt>
     <b><code>create&#95;year&#95;selectbox(name, from&#95;year=-1, length=10, selected&#95;year=0, ln=cdslang)</code></b>
 </dt>
 <dd>
 Creates an HTML menu (dropdownbox) for year selection.<br />
 <code>@param name: name of control( i.e. name of the variable you'll get)<br />
 @param from&#95;year: year on which to begin. if <0 assume it is current year<br />
 @param length: number of items in menu<br />
 @param selected&#95;year: initial selected year (if in range), else: label is selected<br />
 @param ln: language<br />
 @return html as string
 </code>
 </dl>
diff --git a/modules/miscutil/doc/hacking/miscutil-dbquery.webdoc b/modules/miscutil/doc/hacking/miscutil-dbquery.webdoc
index 04e7b2836..4fccadf5a 100644
--- a/modules/miscutil/doc/hacking/miscutil-dbquery.webdoc
+++ b/modules/miscutil/doc/hacking/miscutil-dbquery.webdoc
@@ -1,177 +1,176 @@
+## -*- mode: html; coding: utf-8; -*-
 ## $Id$
 ## This file is part of CDS Invenio.
 ## Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 CERN.
 ##
 ## CDS Invenio is free software; you can redistribute it and/or
 ## modify it under the terms of the GNU General Public License as
 ## published by the Free Software Foundation; either version 2 of the
 ## License, or (at your option) any later version.
 ##
 ## CDS Invenio is distributed in the hope that it will be useful, but
 ## WITHOUT ANY WARRANTY; without even the implied warranty of
 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 ## General Public License for more details.
 ##
 ## You should have received a copy of the GNU General Public License
 ## along with CDS Invenio; if not, write to the Free Software Foundation, Inc.,
 ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
 
 
 <!-- WebDoc-Page-Title: Database access API -->
-<!-- WebDoc-Page-Navbar-Name: hacking-miscutil -->
 <!-- WebDoc-Page-Navtrail: <a class="navtrail" href="<WEBURL>/help/hacking">Hacking CDS Invenio</a> &gt;  <a class="navtrail" href="miscutil-internals">MiscUtil Internals</a> -->
 <!-- WebDoc-Page-Navbar-Select: hacking-miscutil-dbquery -->
 
-
 <p>dbquery module handles automatically connection (and reconnection)
 to the database and provides the <code>run_sql()</code> function to
 perform SQL queries and <code>run_sql_cached()</code> for rarely
 changing SELECT queries.  It also exports DB exceptions for the client
 code to use (see below).
 </p>
 
 <h3><code>run_sql()</code> API</h3>
 
 <p><code>run_sql()</code> signature:
 
 <blockquote>
 <pre>
 def run_sql(sql, param=None, n=0, with_desc=0):
     """Run SQL on the server with PARAM and return result.
 
         @param param: tuple of string params to insert in the query
                       (see notes below)
         @param n: number of tuples in result (0 for unbounded)
         @param with_desc: if true, will return a
                           DB API 7-tuple describing columns in query
         @return: if SELECT, SHOW, DESCRIBE statements: tuples of data, followed
                                                        by description if parameter
                                                        provided
                  if INSERT: last row id.
                  else: SQL result as provided by database
 
        When the site is closed for maintenance (as governed by the
        config variable CFG_ACCESS_CONTROL_LEVEL_SITE), do not attempt
        to run any SQL queries but return empty list immediately.
        Useful to be able to have the website up while MySQL database
        is down for maintenance, hot copies, table repairs, etc.
 
        In case of problems, exceptions are returned according to the
        Python DB API 2.0.  The client code can import them from this
        file and catch them.
     """
 </pre>
 </blockquote>
 </p>
 
 <p><code>run_sql()</code> normally escapes its parameters if you
 pass them in a tuple.  Usually the params must use the string format (<code>%s<code>):
 
 <blockquote>
 <pre>
 from invenio.dbquery import run_sql
 [...]
 res = run_sql("SELECT id FROM collection WHERE name=%s", (c,))
 if res:
     colID = res[0][0]
 </pre>
 </blockquote>
 
 If you want to escape the parameters yourself in the client code, you
 could in principle import and make use of the
 function <code>escape_string()</code>:
 
 <blockquote>
 <pre>
 from invenio.dbquery import run_sql, escape_string
 [...]
 res = run_sql("SELECT id FROM collection WHERE name='%s'" % escape_string(c), None)
 if res:
     colID = res[0][0]
 </pre>
 </blockquote>
 
 but beware, this function is not UTF-8 safe!  So better do not use it.
 </p>
 
 <p>The <code>run_sql()</code> raises Python DB API 2.0 exceptions that
 the client code should catch and handle.  An example:
 
 <blockquote>
 <pre>
 from invenio.dbquery import run_sql, OperationalError
 [...]
 query = "select citation_data from rnkCITATIONDATA"
 try:
     compressed_citation_dic = run_sql(query)
 except OperationalError:
     compressed_citation_dic = []
 </pre>
 </blockquote>
 </p>
 
 <p>For the list of all exceptions and the conditions when they are
 raised, see <a href="http://www.python.org/dev/peps/pep-0249/">PEP 249</a>.
 
 <h3>Note for handling date types</h3>
 <p>There is an incompatibility in handling date types between MySQLdb 0.9 and MySQLdb 1.2 (while using Python 2.2 or 2.3).  If a date field is in the received tuple, its format will be:</p>
 <ul>
 <li>string with MySQLdb 0.9</li>
 <li>datetime with MySQLdb 1.2</li>
 </ul>
 <p>As Python 2.2 doesn't provide <code>datetime</code> class, handling of this
 problem should be done for backwards compatibility reasons. The
 solution is to force MySQL to convert date to a textual format:</p>
 <pre>
     SELECT DATE&#95;FORMAT(date&#95;field,'%%Y-%%m-%%d %%H:%%i:%%s') FROM table
 </pre>
 <p>This conversion will return a datetext format as described in <a href="miscutil-dateutils">dateutils library</a><code>(YEAR-MONTH-DAY HOUR:MINUTE:SECOND)</code>.</p>
 
 <h3><code>run_sql_cached()</code> API</h3>
 
 <p> If you execute a certain SELECT query often, you can
 use <code>run_sql_cached()</code> that will cache its result in memory
 and return it faster next time.  The function signature and usage is
 similar to the one known from <code>run_sql()</code>:
 
 <blockquote>
 <pre>
 def run_sql_cached(sql, param=None, n=0, with_desc=0, affected_tables=[]):
     """
     Run the SQL query and cache the SQL command for later reuse.
 
     @param param: tuple of string params to insert in the query
     (see notes below)
 
     @param n: number of tuples in result (0 for unbounded)
 
     @param with_desc: if true, will return a
     DB API 7-tuple describing columns in query
 
     @param affected_tables is a list of tablenames of affected tables,
     used to decide whether we should update the cache or whether we
     can return cached result, depending on the last modification time
     for corresponding tables.  If empty, and if the cached result is
     present in the cache, always return the cached result without
     recomputing it.  (This is useful to speed up queries that operate
     on objects that virtually never change, e.g. list of defined
     logical fields, that remain usually constant in between Apache
     restarts.  Note that this may be a bit dangerous as a default for
     any query.)
 
     @return the result as provided by run_sql
 
     Note that it is pointless and even wrong to use this function with
     SQL commands different from SELECT.
     """
 </pre>
 </blockquote>
 </p>
 
 <h3>Logging SQL Queries</h3>
 
 <p>If you want to investigate some DB related problems, note that you
 can uncomment some lines in <code>dbquery.py</code> to obtain detailed
 log of every SQL query and its parameters.  Look for
 string <code>log_sql_query</code> to know more.
 </p>
diff --git a/modules/miscutil/doc/hacking/miscutil-errorlib.webdoc b/modules/miscutil/doc/hacking/miscutil-errorlib.webdoc
index c4e1da57c..9ccc2a251 100644
--- a/modules/miscutil/doc/hacking/miscutil-errorlib.webdoc
+++ b/modules/miscutil/doc/hacking/miscutil-errorlib.webdoc
@@ -1,320 +1,319 @@
+## -*- mode: html; coding: utf-8; -*-
 ## $Id$
 ## This file is part of CDS Invenio.
 ## Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 CERN.
 ##
 ## CDS Invenio is free software; you can redistribute it and/or
 ## modify it under the terms of the GNU General Public License as
 ## published by the Free Software Foundation; either version 2 of the
 ## License, or (at your option) any later version.
 ##
 ## CDS Invenio is distributed in the hope that it will be useful, but
 ## WITHOUT ANY WARRANTY; without even the implied warranty of
 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 ## General Public License for more details.
 ##
 ## You should have received a copy of the GNU General Public License
 ## along with CDS Invenio; if not, write to the Free Software Foundation, Inc.,
 ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
 
 <!-- WebDoc-Page-Title: Error Library -->
-<!-- WebDoc-Page-Navbar-Name: hacking-miscutil -->
 <!-- WebDoc-Page-Navtrail: <a class="navtrail" href="<WEBURL>/help/hacking">Hacking CDS Invenio</a> &gt; <a class="navtrail" href="miscutil-internals">MiscUtil Internals</a> -->
-<!-- WebDoc-Page-Navbar-Select: hacking-miscutil-error-management -->
 <!-- WebDoc-Page-Revision: $Id$-->
 
 <p>
 These are the functions and methodologies for error handling in CDS Invenio.
 </p>
 
 <h2>Contents</h2>
 <ol>
 <li><a href="#overview">Overview</a></li>
 <li><a href="#creating">Creating errors</a></li>
 <li><a href="#using">Using error library</a></li>
 <li><a href="#troubleshooting">Troubleshooting</a></li>
 </ol>
 
 <h2>1. <a name="overview">Overview</a></h2>
 
 <p>This API handles two concepts: Errors and Warnings.
 
 <p>An error is an unexpected behavior that leads to the stopping of current process.
 Discussing of web pages, errors should be displayed by instead of the
 requested page. Errors are logged into <code>cds-invenio/var/log/cds-invenio.err</code>.
 Errors can be logged with client information and a tracestack.</p>
 
 <p>A warning is an unexpected behavior that can be ignored. Warnings are logged into
 <code>cds-invenio/var/log/cds-invenio.log</code> with just the warning message.</p>
 
 <p>Errors and warnings should be internationalized (see <a href="#i18n">below</a>).</p>
 
 
 <h2>2. <a name="creating">Creating errors</a></h2>
 <h3>2.1 Configuration file</h3>
 <p>Every module should create a file containing error definitions, warning
 definitions, variables avoiding &quot;magic&quot; number or strings, etc.</p>
 
 <p>This file has to be named against a convention:</p>
 <pre>
     &lt;module-name&gt;&#95;config.py
 </pre>
 <p>e.g. <code>webmessage&#95;config.py</code> for the WebMessage module.</p>
 <h3>2.2 Dictionaries of errors</h3>
 <p>Errors and warnings are eventually stored into dictionaries. The dictionaries
 are to be named against the following convention:</p>
 <pre>
     CFG&#95;&lt;MODULENAME&gt;&#95;ERROR&#95;MESSAGES and
     CFG&#95;&lt;MODULENAME&gt;&#95;WARNING&#95;MESSAGES
 </pre>
 <p>These two dictionaries (one can choose to implement only one if he doesn&apos;t
 need warnings, for example) contain an error-name -&gt; displayable message
 association.</p>
 
 <p>Errors are to be named against the following convention:</p>
 <pre>
     ERR&#95;&lt;MODULE-NAME&gt;&#95;ERROR&#95;NAME
 </pre>
 <p>Please note the use of uppercase.</p>
 
 <p>Warnings can also be named as errors if convenient, and so have to
 follow one of these rules:</p>
 <pre>
     WRN&#95;&lt;MODULE-NAME&gt;&#95;WARNING&#95;NAME or
     ERR&#95;&lt;MODULE-NAME&gt;&#95;WARNING&#95;NAME
 </pre>
 <p>The associated message can obviously contain substituted variables like <code>%s</code>, <code>%d</code>...
 
 <h3><a name="i18n">Internationalization</a></h3>
 <p>Errors should also be internationalized. As the config file cannot receive
 parameters, this is done by the error handling library. The convenient way that has
 been chosen is to nest the classical <code>&#95;()</code> function inside the string.</p>
 <p>An internationalized error message should look like this:</p>
 <pre>
     '&#95;("Internationalized error (%s) message")'
 </pre>
 <p>A complete example of correct dictionary is given below:</p>
 <pre>
     CFG&#95;WEBCOMMENT&#95;ERROR&#95;MESSAGES =
     {   'ERR&#95;WEBCOMMENT&#95;RECID&#95;INVALID'       :  '&#95;("%i is an invalid record ID")',
         'ERR&#95;WEBCOMMENT&#95;RECID&#95;NAN'           :  '&#95;("Record ID %i is not a number")',
         'ERR&#95;WEBCOMMENT&#95;UID&#95;INVALID'         :  '&#95;("%i is an invalid user ID")'
     }
 </pre>
 
 <h2>3. <a name="using">Using error library</a></h2>
 
 <h3>3.1 From a web interface</h3>
 <p>When displaying a page, the <code>modules/webstyle/lib/webpage.py</code> python module should
 be used. This module provides a <code>page()</code> function, convenient for webpage output,
 which can handle errors (display and log).<br />
 A call to this function should use the following arguments, assuming that language
 information is stored in a variable called <code>ln</code>, and request information
 are stored in req (will be used for IP logging, for example):</p>
 <pre>
     page(...,
          req=req,
          language=ln,
          errors=error&#95;list,
          warnings=warnings&#95;list,
          ...)
 </pre>
 <p>list of errors and warnings are behaving the same way. They are lists of tuples:</p>
 <pre>
     [(error&#95;name, param1, ..., paramN), ...]
 </pre>
 <p>The params are used to represent substitued values in messages. For example if
 you want to throw one of the errors above, error&#95;list should look like this:</p>
 <pre>
     error&#95;list = [('ERR&#95;WEBCOMMENT&#95;RECID&#95;INVALID', 123456)]
 </pre>
 <h4>Example</h4>
 <p>Business logic should be separated from web interface. We consider three files in the
 following (real) example:
 <ol>
 <li><code>webmessage_webinterface.py</code>, which is the page as viewed by a browser,</li>
 <li><code>webmessage.py</code>, which contains the business logic,</li>
 <li><code>webmessage&#95;config</code>, which contains error definitions</li>
 </ol>
 <p>In this example, a user tries to read a message. We must ensure he doesn't
 read another message, and that this message really exist in the system. For
 a more convenient reading, some (non error-related) parts of code have been suppressed.</p>
 <h5>webmessage&#95;config.py</h5>
 <pre>
 &#35; error messages. (should not happen, except in case of reload, or url altering)
 CFG&#95;WEBMESSAGE&#95;ERROR&#95;MESSAGES = \
 {   'ERR&#95;WEBMESSAGE&#95;NOTOWNER':  '&#95;("This message is not in your mailbox")',
     'ERR&#95;WEBMESSAGE&#95;NONICKNAME':'&#95;("No nickname or user for uid #%s")',
     'ERR&#95;WEBMESSAGE&#95;NOMESSAGE': '&#95;("This message doesn\'t exist")'
 }
 </pre>
 
 <h5>webmessage.py: business logic</h5>
 <pre>
 from invenio.webmessage&#95;config import CFG&#95;WEBMESSAGE&#95;ERROR&#95;MESSAGES
 
 def perform&#95;request&#95;display&#95;msg(uid, msgid, ln=cdslang):
     uid   = wash&#95;url&#95;argument(uid, 'int')
     msgid = wash&#95;url&#95;argument(msgid, 'int')
     ln    = wash&#95;language(ln)
     errors = []
     warnings = []
     body = ""
     if (check&#95;user&#95;owns&#95;message(uid, msgid) == 0):
         &#35; The user doesn't own this message
         errors.append(('ERR&#95;WEBMESSAGE&#95;NOTOWNER',))
     else:
         (msg&#95;id, ...) = get&#95;message(uid, msgid)
         if (msg&#95;id == ""):
 	    &#35; The message exists in table user&#95;msgMESSAGE
 	    &#35; but not in table msgMESSAGE => table inconsistency
             errors.append(('ERR&#95;WEBMESSAGE&#95;NOMESSAGE',))
         else:
             body = webmessage&#95;templates.tmpl&#95;display&#95;msg( ... )
     return (body, errors, warnings)
 </pre>
 
 <h5>webmessage_webinterface.py: web interface</h5>
 <pre>
 from invenio.webpage import page
 from invenio.webmessage import perform&#95;request&#95;display&#95;msg
 
 def display&#95;msg(req, msgid=-1, ln=cdslang):
     &#95; = gettext&#95;set&#95;language(ln)
     # Generate content
     (body, errors, warnings) = perform&#95;request&#95;display&#95;msg(uid, msgid, ln)
     title = &#95;("Read a message")
     return page(title       = title,
                 body        = body,
                 navtrail    = get&#95;navtrail(ln, title),
                 uid         = uid,
                 lastupdated = &#95;&#95;lastupdated&#95;&#95;,
                 req         = req,
                 language    = ln,
                 errors      = errors,
                 warnings    = warnings)
 
 </pre>
 
 <h3>3.2 From a command line interface</h3>
 
 <p>The following functions can be useful (see source code for other functions):</p>
 <pre>
    get&#95;msgs&#95;for&#95;code&#95;list(code&#95;list, stream='error', ln=cdslang)
         Returns formatted strings for the given errors
         @param code&#95;list: list of tuples  [(err&#95;name, arg1, ..., argN), ...]
         @param stream: 'error' or 'warning'
         @return list of tuples of length 2 [('ERR&#95;...', err&#95;msg), ...]
                 if code&#95;list empty, will return None.
                 if errors retrieving error messages, will append an error to
                 the list
 
     register&#95;errors(errors&#95;or&#95;warnings&#95;list, stream, req=None)
         log errors to invenio.err and warnings to invenio.log
         errors will be logged with client information (if req is given)
         and a tracestack
         warnings will be logged with just the warning message
         @param errors&#95;or&#95;warnings&#95;list: list of tuples (err&#95;name, err&#95;msg)
         @param stream: 'error' or 'warning'
         @param req = mod&#95;python request
         @return integer 1 if successfully wrote to stream, integer 0 if not
                 will append another error to errors&#95;list if unsuccessful
 
     send&#95;error&#95;report&#95;to&#95;admin(header, url, time, browser, client,
                                error, sys&#95;error, traceback)
         Sends an email to the admin with client info and tracestack
 </pre>
 <h4>Example</h4>
 <p>In the following example, two files are used:</p>
 <ol>
 <li><code>webmessage&#95;config</code>, containing error messages</li>
 <li><code>webmessage&#95;example&#95;bin.py</code>, containing business logic</li>
 </ol>
 <p>Scenario: a function receives an error and wants to register it only if it is not a
 messaging error</p>
 <h5>webmessage&#95;config.py</h5>
 <pre>
 &#35; error messages. (should not happen, except in case of reload, or url altering)
 CFG&#95;WEBMESSAGE&#95;ERROR&#95;MESSAGES = \
 {   'ERR&#95;WEBMESSAGE&#95;NOTOWNER':  '&#95;("This message is not in your mailbox")',
     'ERR&#95;WEBMESSAGE&#95;NONICKNAME':'&#95;("No nickname or user for uid #%s")',
     'ERR&#95;WEBMESSAGE&#95;NOMESSAGE': '&#95;("This message doesn\'t exist")'
 }
 </pre>
 
 <h5>webmessage&#95;example&#95;bin.py</h5>
 <pre>
 from invenio.webmessage&#95;config import CFG&#95;WEBMESSAGE&#95;ERROR&#95;MESSAGES
 from invenio.errorlib import get&#95;msgs&#95;for&#95;code&#95;list, register&#95;errors
 
 def handle&#95;error(error):
     errorlist = get&#95;msgs&#95;for&#95;code&#95;list([error])
 
     &#35; error is a tuple of error name, arguments => we only need the name
     if CFG&#95;WEBMESSAGE&#95;ERROR&#95;MESSAGES[error[0]]:
         print("Error in webmessage: %s" % errorlist[0][1])
     else:
         for error in errorlist:
             print("Error: %s" % error[1])
         register&#95;errors(errorlist, 'error')
 </pre>
 <h2>4. <a name="troubleshooting">Troubleshooting</a></h2>
 
 <p>MiscUtil can generate errors. See miscutil&#95;config.py for a complete list.
 One can see below some usual errors and their solutions:</p>
 <dl>
 <dt><b><code>ERR&#95;MISCUTIL&#95;IMPORT&#95;ERROR</code></b></dt>
 <dd>The <code>&lt;module-name&gt;&#95;config.py</code> file has not been found. Check it
 has the correct name and is deployed.<br />
 Check that the error is named following this pattern:
 <pre>
     WRN&#95;&lt;MODULE-NAME&gt;&#95;WARNING&#95;NAME or
     ERR&#95;&lt;MODULE-NAME&gt;&#95;WARNING&#95;NAME
 </pre>
 </dd>
 
 <dt><b><code>ERR&#95;MISCUTIL&#95;NO&#95;DICT</code></b></dt>
 <dd>No dictionary could be found in <code>&lt;module-name&gt;&#95;config.py</code>. Check
 that your dictionary is correctly named:
 <pre>
     CFG&#95;&LT;MODULENAME&GT;&#95;ERROR&#95;MESSAGES
 </pre>
 You could also have inverted errors and warnings if only one dictionary was provided.<br/>
 This can also happen when using direct API if the <code>stream</code> argument is misspelled.
 </dd>
 
 <dt><b><code>ERR&#95;MISCUTIL&#95;NO&#95;MESSAGE&#95;IN&#95;DICT</code></b></dt>
 <dd>A dictionary was found but not the error in it. You probably misspelled
 <code>error&#95;name</code>, or inverted errors and warnings dictionaries.
 </dd>
 
 <dt><b><code>ERR&#95;MISCUTIL&#95;UNDEFINED&#95;ERROR</code></b></dt>
 <dd>The library couldn't guess the name of module. Check that the error name is beginning
 with <code>ERR&#95;MODULE-NAME&#95;</code> or <code>WRN&#95;MODULE-NAME&#95;</code>. This library uses
 underscores as separators to guess module name.
 </dd>
 
 <dt><b><code>ERR&#95;MISCUTIL&#95;TOO&#95;MANY&#95;ARGUMENT</code></b></dt>
 <dd>As the library was rendering the display of error, a surnumerous text substitute was
 found (surnumerous are ignored for final rendering, and this error is appened to list of errors):
 <pre>
     # Module knights:
     'ERR&#95;KNIGHTS': '&#95;("We are the knights who say %s!")'
     errors = ('ERR&#95;KNIGHTS', 'ni', 'ni')
 </pre>
 </dd>
 
 <dt><b><code>ERR&#95;MISCUTIL&#95;TOO&#95;FEW&#95;ARGUMENT</code></b></dt>
 <dd>Not enough arguments (text substitutes) were given for an error. Missing ones are
 replaced by <code>'???'</code>:
 <pre>
     # Module knights
     'ERR&#95;KNIGHTS': '&#95;("We are the knights who say %s! We demand a %s")'
     errors = ('ERR&#95;KNIGHTS', 'ni') # so, where is the shrubbery??
 </pre>
 </dd>
 
 <dt><b><code>ERR&#95;MISCUTIL&#95;BAD&#95;ARGUMENT&#95;TYPE</code></b></dt>
 <dd>Your arguments (text substitutes) did not match with the error declaration<br />
 e.g. inversion between integer (<code>%i</code>) and string (<code>%s</code>)
 </dd>
 </dl>
diff --git a/modules/miscutil/doc/hacking/miscutil-internals.webdoc b/modules/miscutil/doc/hacking/miscutil-internals.webdoc
index 46650776d..99d3cd98b 100644
--- a/modules/miscutil/doc/hacking/miscutil-internals.webdoc
+++ b/modules/miscutil/doc/hacking/miscutil-internals.webdoc
@@ -1,39 +1,39 @@
+## -*- mode: html; coding: utf-8; -*-
 ## $Id$
 
 ## This file is part of CDS Invenio.
 ## Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 CERN.
 ##
 ## CDS Invenio is free software; you can redistribute it and/or
 ## modify it under the terms of the GNU General Public License as
 ## published by the Free Software Foundation; either version 2 of the
 ## License, or (at your option) any later version.
 ##
 ## CDS Invenio is distributed in the hope that it will be useful, but
 ## WITHOUT ANY WARRANTY; without even the implied warranty of
 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 ## General Public License for more details.
 ##
 ## You should have received a copy of the GNU General Public License
 ## along with CDS Invenio; if not, write to the Free Software Foundation, Inc.,
 ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
 
 <!-- WebDoc-Page-Title: MiscUtil Internals -->
-<!-- WebDoc-Page-Navbar-Name: hacking-miscutil -->
 <!-- WebDoc-Page-Navtrail: <a class="navtrail" href="<WEBURL>/help/hacking">Hacking CDS Invenio</a> -->
-<!-- WebDoc-Page-Navbar-Select: hacking-miscutil-index -->
+<!-- WebDoc-Page-Revision: $Id$-->
 
 This page summarizes all the information suitable to dig inside
 the MiscUtil internals.
 
 <blockquote>
  <dl>
   <dt><a href="miscutil-dbquery">Database access API</a> </dt>
   <dd>Explains how to access CDS Invenio database from your Python programs.</dd>
 
   <dt><a href="miscutil-errorlib">Error handling library</a> </dt>
   <dd>Explains how to create errors and warnings and how to manage them.</dd>
 
   <dt><a href="miscutil-dateutils">Date handling library</a> </dt>
   <dd>Explains how to handle dates in CDS Invenio. All mentioned functions are represented with signature and additional explanations.</dd>
  </dl>
 </blockquote>