Wiking branch, master, updated. 3902e7fcb79b88b151864c82b90b93fe6670caed

Milan Zamazal pdm at devel.brailcom.org
Fri Oct 22 13:43:07 CEST 2010


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Wiking".

The branch, master has been updated
       via  3902e7fcb79b88b151864c82b90b93fe6670caed (commit)
      from  23ea6555685fe03b74908c1776cf9a76360390d2 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 3902e7fcb79b88b151864c82b90b93fe6670caed
Author: Milan Zamazal <pdm at brailcom.org>
Date:   Fri Oct 22 13:40:17 2010 +0200

    Add extra form headings to document titles

-----------------------------------------------------------------------

Summary of changes:
 lib/wiking/db.py      |   19 +++++++++++++++++--
 lib/wiking/request.py |   30 +++++++++++++++++++++++-------
 2 files changed, 40 insertions(+), 9 deletions(-)

diff --git a/lib/wiking/db.py b/lib/wiking/db.py
index 11d1d74..cc05944 100644
--- a/lib/wiking/db.py
+++ b/lib/wiking/db.py
@@ -16,6 +16,8 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
+import string
+
 from wiking import *
 
 _ = lcg.TranslatableTextFactory('wiking')
@@ -498,6 +500,10 @@ class PytisModule(Module, ActionHandler):
                     title = fw.arg('title') +' :: '+ title
                 else:
                     title = fw.arg('title')
+        messages = req.messages(heading=True)
+        if messages:
+            extra_title = string.join([m[0] for m in messages], '; ')
+            title = '%s (%s)' % (title, extra_title,)
         return title
         
     def _document(self, req, content, record=None, lang=None, err=None, msg=None, **kwargs):
@@ -1108,6 +1114,11 @@ class PytisModule(Module, ActionHandler):
             if self._ACTION_MENU_LAST:
                 content.append(action_menu) 
         return content
+
+    def _add_form_messages(self, req, form):
+        message = form.heading_info()
+        if message:
+            req.message(message, req.HEADING)
     
     def _transaction(self):
         """Create a new transaction and return it as 'pd.DBTransactionDefault' instance."""
@@ -1178,8 +1189,7 @@ class PytisModule(Module, ActionHandler):
         'action_delete()' handler.
 
         """
-        return None
-            
+        return None            
     
     # ===== Methods which modify the database =====
     
@@ -1310,6 +1320,7 @@ class PytisModule(Module, ActionHandler):
                           condition=self._condition(req, lang=lang),
                           arguments=self._arguments(req),
                           filters=self._filters(req))
+        self._add_form_messages(req, form)
         content = self._list_form_content(req, form)
         return self._document(req, content, lang=lang)
 
@@ -1349,6 +1360,7 @@ class PytisModule(Module, ActionHandler):
         if action_menu:
             content.append(action_menu)
         content.extend(self._related_content(req, record))
+        self._add_form_messages(req, form)
         return self._document(req, content, record, err=err, msg=msg)
 
     # ===== Action handlers which modify the database =====
@@ -1387,6 +1399,7 @@ class PytisModule(Module, ActionHandler):
         form = self._form(pw.EditForm, req, new=True, action=action,
                           prefill=prefill, layout=layout, errors=errors,
                           submit=self._submit_buttons(req, action))
+        self._add_form_messages(req, form)
         return self._document(req, form, subtitle=self._action_subtitle(req, action))
             
     def action_update(self, req, record, action='update'):
@@ -1408,6 +1421,7 @@ class PytisModule(Module, ActionHandler):
         form = self._form(pw.EditForm, req, record=record, action=action, layout=layout,
                           submit=self._submit_buttons(req, action, record),
                           prefill=self._form_field_prefill(req), errors=errors)
+        self._add_form_messages(req, form)
         return self._document(req, form, record,
                               subtitle=self._action_subtitle(req, action, record=record))
 
@@ -1427,6 +1441,7 @@ class PytisModule(Module, ActionHandler):
                    # Translators: Back button label. Standard computer terminology.
                    Action(_("Back"), 'view'))
         action_menu = self._action_menu(req, record, actions)
+        self._add_form_messages(req, form)
         return self._document(req, [form, action_menu], record,
                               subtitle=self._action_subtitle(req, 'delete', record))
         
diff --git a/lib/wiking/request.py b/lib/wiking/request.py
index 7e242c0..c51f930 100644
--- a/lib/wiking/request.py
+++ b/lib/wiking/request.py
@@ -469,7 +469,9 @@ class WikingRequest(Request):
     """Message type constant for warning messages."""
     ERROR = 'ERROR'
     """Message type constant for error messages."""
-    _MESSAGE_TYPES = (INFO, WARNING, ERROR)
+    HEADING = 'HEADING'
+    """Message type constant for messages to be put into document heading."""
+    _MESSAGE_TYPES = (INFO, WARNING, ERROR, HEADING,)
 
     def __init__(self, req, application, **kwargs):
         super(WikingRequest, self).__init__(req, **kwargs)
@@ -834,8 +836,8 @@ class WikingRequest(Request):
 
         Arguments:
           message -- message text as a string.
-          type -- message text as one of INFO, WARNING, ERROR constatns of the class.  If None, the
-            default is INFO.
+          type -- message text as one of INFO, WARNING, ERROR, HEADING constants
+            of the class.  If None, the default is INFO.
 
         The stacked messages can be later retrieved using the 'messages()' method.
 
@@ -843,10 +845,24 @@ class WikingRequest(Request):
         assert type is None or type in self._MESSAGE_TYPES
         self._messages.append((message, type or self.INFO))
 
-    def messages(self):
-        """Return the current stack of messages as a tuple of pairs (MESSAGE, TYPE)."""
-        return tuple(self._messages)
-    
+    def messages(self, heading=False):
+        """Return the current stack of messages as a tuple of pairs (MESSAGE, TYPE).
+
+        Arguments:
+
+          heading -- if 'None', return all messages; if 'False', return all
+            messages except for heading messages; if 'True', return only
+            heading messages
+
+        """
+        if heading is None:
+            messages = tuple(self._messages)
+        elif heading:
+            messages = [m for m in self._messages if m[1] == self.HEADING]
+        else:
+            messages = [m for m in self._messages if m[1] != self.HEADING]
+        return tuple(messages)
+
 
 class User(object):
     """Representation of the logged in user.


hooks/post-receive
-- 
Wiking



More information about the Wiking-cvs mailing list