[Checkins] SVN: z3ext.layoutform/trunk/ - Show all form errors

Nikolay Kim fafhrd at datacom.kz
Tue Oct 7 15:42:39 EDT 2008


Log message for revision 91880:
  - Show all form errors
  
  

Changed:
  U   z3ext.layoutform/trunk/CHANGES.txt
  U   z3ext.layoutform/trunk/src/z3ext/layoutform/add.py
  U   z3ext.layoutform/trunk/src/z3ext/layoutform/browser/configure.zcml
  D   z3ext.layoutform/trunk/src/z3ext/layoutform/browser/form.css
  A   z3ext.layoutform/trunk/src/z3ext/layoutform/browser/message.pt
  A   z3ext.layoutform/trunk/src/z3ext/layoutform/browser/message.py
  A   z3ext.layoutform/trunk/src/z3ext/layoutform/browser/styles.css
  U   z3ext.layoutform/trunk/src/z3ext/layoutform/configure.zcml
  U   z3ext.layoutform/trunk/src/z3ext/layoutform/edit.py
  A   z3ext.layoutform/trunk/src/z3ext/layoutform/error.py
  U   z3ext.layoutform/trunk/src/z3ext/layoutform/interfaces.py

-=-
Modified: z3ext.layoutform/trunk/CHANGES.txt
===================================================================
--- z3ext.layoutform/trunk/CHANGES.txt	2008-10-07 19:25:16 UTC (rev 91879)
+++ z3ext.layoutform/trunk/CHANGES.txt	2008-10-07 19:42:39 UTC (rev 91880)
@@ -2,6 +2,12 @@
 CHANGES
 =======
 
+1.2.1 (2008-10-08)
+------------------
+
+- Show all form errors
+
+
 1.2.0 (2008-10-06)
 ------------------
 

Modified: z3ext.layoutform/trunk/src/z3ext/layoutform/add.py
===================================================================
--- z3ext.layoutform/trunk/src/z3ext/layoutform/add.py	2008-10-07 19:25:16 UTC (rev 91879)
+++ z3ext.layoutform/trunk/src/z3ext/layoutform/add.py	2008-10-07 19:42:39 UTC (rev 91880)
@@ -27,7 +27,9 @@
 from form import PageletForm
 from interfaces import _, IPageletAddForm, IAddButton, ICancelButton
 
+from zope.proxy import removeAllProxies
 
+
 class PageletAddForm(form.AddForm, PageletForm):
     interface.implements(IPageletAddForm)
 
@@ -43,7 +45,8 @@
         data, errors = self.extractData()
 
         if errors:
-            IStatusMessage(self.request).add(self.formErrorsMessage, 'warning')
+            IStatusMessage(self.request).add(
+                (self.formErrorsMessage,) + errors, 'formError')
         else:
             obj = self.createAndAdd(data)
 
@@ -52,7 +55,8 @@
                 self._finishedAdd = True
                 self.redirect(self.nextURL())
 
-    @button.buttonAndHandler(_(u'Cancel'), name='cancel', provides=ICancelButton)
+    @button.buttonAndHandler(
+        _(u'Cancel'), name='cancel', provides=ICancelButton)
     def handleCancel(self, action):
         self._finishedAdd = True
         self.redirect(self.cancelURL())

Modified: z3ext.layoutform/trunk/src/z3ext/layoutform/browser/configure.zcml
===================================================================
--- z3ext.layoutform/trunk/src/z3ext/layoutform/browser/configure.zcml	2008-10-07 19:25:16 UTC (rev 91879)
+++ z3ext.layoutform/trunk/src/z3ext/layoutform/browser/configure.zcml	2008-10-07 19:42:39 UTC (rev 91880)
@@ -114,12 +114,15 @@
      layer="..interfaces.ILayoutFormLayer"
      permission="zope.Public" />
 
+  <!-- status message -->
+  <adapter factory=".message.Message" />
+
   <!-- styles -->
   <z3ext:resourceinclude
      name="z3ext-layoutform.css"
      library="z3ext"
      type="stylesheet"
-     file="form.css" filetype="zrt" />
+     file="styles.css" filetype="zrt" />
 
   <z3ext:resource
      file="required.gif"

Deleted: z3ext.layoutform/trunk/src/z3ext/layoutform/browser/form.css
===================================================================
--- z3ext.layoutform/trunk/src/z3ext/layoutform/browser/form.css	2008-10-07 19:25:16 UTC (rev 91879)
+++ z3ext.layoutform/trunk/src/z3ext/layoutform/browser/form.css	2008-10-07 19:42:39 UTC (rev 91880)
@@ -1,187 +0,0 @@
-/* zrt-cssregistry: */
-
- at media all {
-
-  .z-form {
-  }
-
-  .z-page .z-form-add,
-  .z-page .z-form-edit,
-  .page .z-form-add,
-  .page .z-form-edit {
-    border: borderWidth borderStyle globalExtraBorderColor;
-    margin-top: 0em;
-    padding: 1em;
-    background: contentBackgroundColor;
-  }
-  
-  .z-frame .z-form-edit,
-  .z-frame .z-form-standard,
-  .z-topframe .z-form-standard,
-  .frame .z-form-edit,
-  .frame .z-form-standard,
-  .topframe .z-form-standard,
-  #z-context-view .z-form-edit,
-  #z-context-view .z-form-standard {
-    border: none;
-    padding: 0em;
-  }
-
-  .z-add-form {
-    padding: 1em;
-  }
-
-  .z-form-description { 
-    color: discreetColor;
-    margin-bottom: 1.5em;
-    font-size: 90%;
-  }
-  
-  .z-form-field .z-form-description {
-    color: discreetColor;
-    font-size: fontSmallSize;
-    font-weight: normal;
-    margin-bottom: 1.5em;
-  }
-  
-  .z-form-fieldset {
-    margin-bottom: 1em;
-    color: fontColor !important;
-    background-color: backgroundColor;
-    padding: 0.5em 1em 0.5em 1em;
-  }
-  
-  .z-form-fieldset.last {
-    margin-bottom: 0em;
-  }
-  
-  .z-form form:first-child > .z-form-fieldset {
-    margin-top: 0em;
-  }
-  
-  .z-form-fieldset ul a {
-    text-decoration: none;
-    border-bottom: borderWidth dotted discreetColor;
-  }
-  
-  .z-form-fieldset label {
-    font-weight: normal;
-  }
-  
-  .z-form-fieldset h2 { 
-    font-weight: bold;
-  }
-  
-  .z-form-fieldset .header {
-    border-bottom: borderWidth borderStyle globalBorderColor;
-  }
-  
-  /* The edit form elements */
-  .z-form-field {
-    margin: 0 1em 1em 0;
-  }
-  
-  .z-form-field .z-form-field {
-    margin: 1em 0 0 0;
-  }
-  
-  .z-form-field label {
-    font-size: 100%;
-  }
-  
-  .z-form-fieldRequired {
-    background: url(z3ext-layoutform-required.gif) center left no-repeat;
-    padding: 0 0 0 8px;
-    color: backgroundColor;
-  }
-  
-  .z-form-fieldUploadFile {
-    text-align: right; 
-    margin-right: 0.75em;
-    display: none;
-  }
-  
-  .z-form-fieldTextFormat {
-    text-align: right;
-    margin-right: 0.75em
-  }
-  
-  .z-form-help {
-    font-size: fontSmallSize;
-    color: discreetColor;
-    margin: 0 0 0.2em 0;
-  }
-  
-  .z-form-help:hover {
-    color: fontColor;
-    cursor: default;
-  }
-  
-  .z-form-field.error {
-    /* Class for error indication in forms */
-    background-color: notifyBackgroundColor;
-    border: borderWidth borderStyle notifyBorderColor;
-    padding: 1em;
-    margin: 0 0 1em 0;
-    width: 95%;
-  }
-  
-  .z-form-field.error .x-form-fieldRequired {
-    color: notifyBackgroundColor;
-  }
-  
-  .z-form-controls {
-    clear: both;
-    margin-top: 1em;
-  }
-  
-  
-  .z-form-button {
-    background: transparent url(z3ext-layoutform-linkTransparent.gif) no-repeat;
-    background-position: 5px center;
-    cursor: pointer;
-    font-size: fontSmallSize;
-    padding: 1px 1px 1px 14px;
-  }
-  
-  .z-form-standalonebtn {
-    background: globalBackgroundColor url(z3ext-layoutform-linkOpaque.gif) no-repeat;
-    background-position: 5px center;
-    cursor: pointer;
-    font-size: fontSmallSize;
-    padding: 1px 1px 1px 14px;
-  }
-  
-  .z-form-addbutton {
-    background: transparent url(z3ext-layoutform-linkTransparent.gif) no-repeat;
-    background-position: 5px center;
-    cursor: pointer;
-    font-size: fontSmallSize;
-    padding: 1px 1px 1px 14px;
-  }
-  
-  .z-form-savebutton {
-    background: transparent url(z3ext-layoutform-linkTransparent.gif) no-repeat;
-    background-position: 5px center;
-    cursor: pointer;
-    font-size: fontSmallSize;
-    padding: 1px 1px 1px 14px;
-  }
-  
-  .z-form-cancelbutton {
-    background: globalBackgroundColor url(z3ext-layoutform-linkOpaque.gif) no-repeat;
-    background-position: 5px center;
-    cursor: pointer;
-    font-size: fontSmallSize;
-    padding: 1px 1px 1px 14px;
-  }
-  
-  .z-form-removebutton {
-    background: globalBackgroundColor url(z3ext-layoutform-linkOpaque.gif) no-repeat;
-    background-position: 5px center;
-    cursor: pointer;
-    font-size: fontSmallSize;
-    padding: 1px 1px 1px 14px;
-  }
-
-}
\ No newline at end of file

Added: z3ext.layoutform/trunk/src/z3ext/layoutform/browser/message.pt
===================================================================
--- z3ext.layoutform/trunk/src/z3ext/layoutform/browser/message.pt	                        (rev 0)
+++ z3ext.layoutform/trunk/src/z3ext/layoutform/browser/message.pt	2008-10-07 19:42:39 UTC (rev 91880)
@@ -0,0 +1,11 @@
+<div class="statusWarningMessage">
+  <tal:block content="context/message" />
+  <tal:block condition="context/errors">
+    <br />
+    <ul>
+      <li tal:repeat="err context/errors"
+	  tal:content="structure err/render">
+      </li>
+    </ul>
+  </tal:block>
+</div>

Added: z3ext.layoutform/trunk/src/z3ext/layoutform/browser/message.py
===================================================================
--- z3ext.layoutform/trunk/src/z3ext/layoutform/browser/message.py	                        (rev 0)
+++ z3ext.layoutform/trunk/src/z3ext/layoutform/browser/message.py	2008-10-07 19:42:39 UTC (rev 91880)
@@ -0,0 +1,35 @@
+##############################################################################
+#
+# Copyright (c) 2008 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+""" 
+
+$Id:  2007-12-12 12:27:02Z fafhrd $
+"""
+from zope import component, interface
+from zope.app.pagetemplate import ViewPageTemplateFile
+from z3ext.statusmessage.interfaces import IMessageView
+from z3ext.layoutform.interfaces import IFormErrorStatusMessage
+
+
+class Message(object):
+    interface.implements(IMessageView)
+    component.adapts(IFormErrorStatusMessage, interface.Interface)
+
+    index = ViewPageTemplateFile('message.pt')
+
+    def __init__(self, context, request):
+        self.context = context
+        self.request = request
+
+    def render(self):
+        return self.index()

Copied: z3ext.layoutform/trunk/src/z3ext/layoutform/browser/styles.css (from rev 91853, z3ext.layoutform/trunk/src/z3ext/layoutform/browser/form.css)
===================================================================
--- z3ext.layoutform/trunk/src/z3ext/layoutform/browser/styles.css	                        (rev 0)
+++ z3ext.layoutform/trunk/src/z3ext/layoutform/browser/styles.css	2008-10-07 19:42:39 UTC (rev 91880)
@@ -0,0 +1,187 @@
+/* zrt-cssregistry: */
+
+ at media all {
+
+  .z-form {
+  }
+
+  .z-page .z-form-add,
+  .z-page .z-form-edit,
+  .page .z-form-add,
+  .page .z-form-edit {
+    border: borderWidth borderStyle globalExtraBorderColor;
+    margin-top: 0em;
+    padding: 1em;
+    background: contentBackgroundColor;
+  }
+  
+  .z-frame .z-form-edit,
+  .z-frame .z-form-standard,
+  .z-topframe .z-form-standard,
+  .frame .z-form-edit,
+  .frame .z-form-standard,
+  .topframe .z-form-standard,
+  #z-context-view .z-form-edit,
+  #z-context-view .z-form-standard {
+    border: none;
+    padding: 0em;
+  }
+
+  .z-add-form {
+    padding: 1em;
+  }
+
+  .z-form-description { 
+    color: discreetColor;
+    margin-bottom: 1.5em;
+    font-size: 90%;
+  }
+  
+  .z-form-field .z-form-description {
+    color: discreetColor;
+    font-size: fontSmallSize;
+    font-weight: normal;
+    margin-bottom: 1.5em;
+  }
+  
+  .z-form-fieldset {
+    margin-bottom: 1em;
+    color: fontColor !important;
+    background-color: backgroundColor;
+    padding: 0.5em 1em 0.5em 1em;
+  }
+  
+  .z-form-fieldset.last {
+    margin-bottom: 0em;
+  }
+  
+  .z-form form:first-child > .z-form-fieldset {
+    margin-top: 0em;
+  }
+  
+  .z-form-fieldset ul a {
+    text-decoration: none;
+    border-bottom: borderWidth dotted discreetColor;
+  }
+  
+  .z-form-fieldset label {
+    font-weight: normal;
+  }
+  
+  .z-form-fieldset h2 { 
+    font-weight: bold;
+  }
+  
+  .z-form-fieldset .header {
+    border-bottom: borderWidth borderStyle globalBorderColor;
+  }
+  
+  /* The edit form elements */
+  .z-form-field {
+    margin: 0 1em 1em 0;
+  }
+  
+  .z-form-field .z-form-field {
+    margin: 1em 0 0 0;
+  }
+  
+  .z-form-field label {
+    font-size: 100%;
+  }
+  
+  .z-form-fieldRequired {
+    background: url(z3ext-layoutform-required.gif) center left no-repeat;
+    padding: 0 0 0 8px;
+    color: backgroundColor;
+  }
+  
+  .z-form-fieldUploadFile {
+    text-align: right; 
+    margin-right: 0.75em;
+    display: none;
+  }
+  
+  .z-form-fieldTextFormat {
+    text-align: right;
+    margin-right: 0.75em
+  }
+  
+  .z-form-help {
+    font-size: fontSmallSize;
+    color: discreetColor;
+    margin: 0 0 0.2em 0;
+  }
+  
+  .z-form-help:hover {
+    color: fontColor;
+    cursor: default;
+  }
+  
+  .z-form-field.error {
+    /* Class for error indication in forms */
+    background-color: notifyBackgroundColor;
+    border: borderWidth borderStyle notifyBorderColor;
+    padding: 1em;
+    margin: 0 0 1em 0;
+    width: 95%;
+  }
+  
+  .z-form-field.error .x-form-fieldRequired {
+    color: notifyBackgroundColor;
+  }
+  
+  .z-form-controls {
+    clear: both;
+    margin-top: 1em;
+  }
+  
+  
+  .z-form-button {
+    background: transparent url(z3ext-layoutform-linkTransparent.gif) no-repeat;
+    background-position: 5px center;
+    cursor: pointer;
+    font-size: fontSmallSize;
+    padding: 1px 1px 1px 14px;
+  }
+  
+  .z-form-standalonebtn {
+    background: globalBackgroundColor url(z3ext-layoutform-linkOpaque.gif) no-repeat;
+    background-position: 5px center;
+    cursor: pointer;
+    font-size: fontSmallSize;
+    padding: 1px 1px 1px 14px;
+  }
+  
+  .z-form-addbutton {
+    background: transparent url(z3ext-layoutform-linkTransparent.gif) no-repeat;
+    background-position: 5px center;
+    cursor: pointer;
+    font-size: fontSmallSize;
+    padding: 1px 1px 1px 14px;
+  }
+  
+  .z-form-savebutton {
+    background: transparent url(z3ext-layoutform-linkTransparent.gif) no-repeat;
+    background-position: 5px center;
+    cursor: pointer;
+    font-size: fontSmallSize;
+    padding: 1px 1px 1px 14px;
+  }
+  
+  .z-form-cancelbutton {
+    background: globalBackgroundColor url(z3ext-layoutform-linkOpaque.gif) no-repeat;
+    background-position: 5px center;
+    cursor: pointer;
+    font-size: fontSmallSize;
+    padding: 1px 1px 1px 14px;
+  }
+  
+  .z-form-removebutton {
+    background: globalBackgroundColor url(z3ext-layoutform-linkOpaque.gif) no-repeat;
+    background-position: 5px center;
+    cursor: pointer;
+    font-size: fontSmallSize;
+    padding: 1px 1px 1px 14px;
+  }
+
+}
\ No newline at end of file

Modified: z3ext.layoutform/trunk/src/z3ext/layoutform/configure.zcml
===================================================================
--- z3ext.layoutform/trunk/src/z3ext/layoutform/configure.zcml	2008-10-07 19:25:16 UTC (rev 91879)
+++ z3ext.layoutform/trunk/src/z3ext/layoutform/configure.zcml	2008-10-07 19:42:39 UTC (rev 91880)
@@ -4,6 +4,16 @@
 
   <includeDependencies package="z3ext.layoutform" />
 
+  <!-- form error status message -->
+  <utility
+     name="formError"
+     provides="z3ext.statusmessage.interfaces.IMessageFactory"
+     component=".error.FormErrorStatusMessage" />
+
+  <class class=".error.FormErrorStatusMessage">
+    <allow interface=".interfaces.IFormErrorStatusMessage" />
+  </class>
+
   <include package=".browser" />
 
 </configure>

Modified: z3ext.layoutform/trunk/src/z3ext/layoutform/edit.py
===================================================================
--- z3ext.layoutform/trunk/src/z3ext/layoutform/edit.py	2008-10-07 19:25:16 UTC (rev 91879)
+++ z3ext.layoutform/trunk/src/z3ext/layoutform/edit.py	2008-10-07 19:42:39 UTC (rev 91880)
@@ -39,7 +39,8 @@
     def handleApply(self, action):
         data, errors = self.extractData()
         if errors:
-            IStatusMessage(self.request).add(self.formErrorsMessage, 'warning')
+            IStatusMessage(self.request).add(
+                (self.formErrorsMessage,) + errors, 'formError')
         else:
             changes = self.applyChanges(data)
             if changes:

Added: z3ext.layoutform/trunk/src/z3ext/layoutform/error.py
===================================================================
--- z3ext.layoutform/trunk/src/z3ext/layoutform/error.py	                        (rev 0)
+++ z3ext.layoutform/trunk/src/z3ext/layoutform/error.py	2008-10-07 19:42:39 UTC (rev 91880)
@@ -0,0 +1,29 @@
+##############################################################################
+#
+# Copyright (c) 2008 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+""" 
+
+$Id:  2007-12-12 12:27:02Z fafhrd $
+"""
+from zope import interface
+from z3ext.statusmessage.message import Message
+
+from interfaces import IFormErrorStatusMessage
+
+
+class FormErrorStatusMessage(Message):
+    interface.implements(IFormErrorStatusMessage)
+
+    def __init__(self, message):
+        self.message = message[0]
+        self.errors = [err for err in message[1:] if err.widget is None]

Modified: z3ext.layoutform/trunk/src/z3ext/layoutform/interfaces.py
===================================================================
--- z3ext.layoutform/trunk/src/z3ext/layoutform/interfaces.py	2008-10-07 19:25:16 UTC (rev 91879)
+++ z3ext.layoutform/trunk/src/z3ext/layoutform/interfaces.py	2008-10-07 19:42:39 UTC (rev 91880)
@@ -19,6 +19,7 @@
 from zope.i18nmessageid import MessageFactory
 from z3c.form.interfaces import IFormLayer
 from z3ext.layout.interfaces import IPagelet
+from z3ext.statusmessage.interfaces import IMessage
 
 _ = MessageFactory('z3ext')
 
@@ -71,3 +72,7 @@
 
 class ICancelButton(interface.Interface):
     """ cancel button """
+
+
+class IFormErrorStatusMessage(IMessage):
+    """ form error status message """



More information about the Checkins mailing list