[Zope-Checkins] SVN: Products.Five/trunk/ - made some Zope 3
formlib fixes available
Yvo Schubbe
y.2006_ at wcm-solutions.de
Wed Oct 25 08:01:36 EDT 2006
Log message for revision 70912:
- made some Zope 3 formlib fixes available
Changed:
U Products.Five/trunk/CHANGES.txt
UU Products.Five/trunk/formlib/configure.zcml
UU Products.Five/trunk/formlib/formbase.py
D Products.Five/trunk/formlib/pageform.pt
D Products.Five/trunk/formlib/subpageform.pt
-=-
Modified: Products.Five/trunk/CHANGES.txt
===================================================================
--- Products.Five/trunk/CHANGES.txt 2006-10-25 11:59:22 UTC (rev 70911)
+++ Products.Five/trunk/CHANGES.txt 2006-10-25 12:01:35 UTC (rev 70912)
@@ -3,8 +3,11 @@
============
Five 1.5.1 (unreleased)
-=====================
+=======================
+* formlib: Removed redundant subpageform.pt and pageform.pt. Added missing
+ error view configuration.
+
* Made the __call__ method of ViewMixinForAttributes have the same signature
as the original attribute. This aids some pathological request parameter
marshalling.
Modified: Products.Five/trunk/formlib/configure.zcml
===================================================================
--- Products.Five/trunk/formlib/configure.zcml 2006-10-25 11:59:22 UTC (rev 70911)
+++ Products.Five/trunk/formlib/configure.zcml 2006-10-25 12:01:35 UTC (rev 70912)
@@ -1,6 +1,17 @@
<configure
+ package="zope.formlib"
xmlns="http://namespaces.zope.org/zope"
- xmlns:zc="http://namespaces.zope.com/zc"
- i18n_domain="zope.formlib">
- <adapter factory="zope.formlib.form.render_submit_button" name="render" />
+ i18n_domain="zope">
+
+ <adapter
+ factory=".form.render_submit_button"
+ name="render"
+ />
+
+ <!-- Error view for 'Invalid' -->
+ <adapter
+ factory=".errors.InvalidErrorView"
+ permission="zope.Public"
+ />
+
</configure>
Property changes on: Products.Five/trunk/formlib/configure.zcml
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: Products.Five/trunk/formlib/formbase.py
===================================================================
--- Products.Five/trunk/formlib/formbase.py 2006-10-25 11:59:22 UTC (rev 70911)
+++ Products.Five/trunk/formlib/formbase.py 2006-10-25 12:01:35 UTC (rev 70912)
@@ -15,40 +15,50 @@
$Id$
"""
+import os.path
+
from datetime import datetime
import Acquisition
import zope.event
+import zope.formlib
import zope.lifecycleevent
from zope import interface
from zope.formlib import interfaces, form, namedtemplate
from zope.i18nmessageid import MessageFactory
_ = MessageFactory("zope")
-from Products.Five.browser.pagetemplatefile import ZopeTwoPageTemplateFile
+from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
from Products.Five.browser.decode import processInputs, setPageEncoding
+_FORMLIB_DIR = os.path.dirname(zope.formlib.__file__)
+_PAGEFORM_PATH = os.path.join(_FORMLIB_DIR, 'pageform.pt')
+_SUBPAGEFORM_PATH = os.path.join(_FORMLIB_DIR, 'subpageform.pt')
+
+
class FiveFormlibMixin(Acquisition.Explicit):
# Overrides the formlib.form.FormBase.template attributes implemented
# using NamedTemplates. NamedTemplates using ViewPageTemplateFile (like
# formlib does by default) cannot work in Zope2.
-
+
# XXX Maybe we need to have Five-compatible NamedTemplates?
-
- template = ZopeTwoPageTemplateFile('pageform.pt')
-
+
+ template = ViewPageTemplateFile(_PAGEFORM_PATH)
+
# Overrides formlib.form.FormBase.update. Make sure user input is
# decoded first and the page encoding is set before proceeding.
-
+
def update(self):
processInputs(self.request)
setPageEncoding(self.request)
super(FiveFormlibMixin, self).update()
+
class FormBase(FiveFormlibMixin, form.FormBase):
pass
-
+
+
class EditFormBase(FiveFormlibMixin, form.EditFormBase):
# Overrides formlib.form.EditFormBase.handle_edit_action, to remove
@@ -58,7 +68,7 @@
def handle_edit_action(self, action, data):
if form.applyChanges(
self.context, self.form_fields, data, self.adapters):
-
+
zope.event.notify(
zope.lifecycleevent.ObjectModifiedEvent(self.context)
)
@@ -69,51 +79,60 @@
)
else:
self.status = _('No changes')
-
+
+
class DisplayFormBase(FiveFormlibMixin, form.DisplayFormBase):
pass
+
class AddFormBase(FiveFormlibMixin, form.AddFormBase):
pass
-
+
+
class PageForm(FormBase):
interface.implements(interfaces.IPageForm)
Form = PageForm
+
class PageEditForm(EditFormBase):
interface.implements(interfaces.IPageForm)
EditForm = PageEditForm
+
class PageDisplayForm(DisplayFormBase):
interface.implements(interfaces.IPageForm)
DisplayForm = PageDisplayForm
+
class PageAddForm(AddFormBase):
interface.implements(interfaces.IPageForm)
AddForm = PageAddForm
+
class SubPageForm(FormBase):
- template = ZopeTwoPageTemplateFile('subpageform.pt')
-
+ template = ViewPageTemplateFile(_SUBPAGEFORM_PATH)
+
interface.implements(interfaces.ISubPageForm)
+
class SubPageEditForm(EditFormBase):
- template = ZopeTwoPageTemplateFile('subpageform.pt')
-
+ template = ViewPageTemplateFile(_SUBPAGEFORM_PATH)
+
interface.implements(interfaces.ISubPageForm)
+
class SubPageDisplayForm(DisplayFormBase):
- template = ZopeTwoPageTemplateFile('subpageform.pt')
-
+ template = ViewPageTemplateFile(_SUBPAGEFORM_PATH)
+
interface.implements(interfaces.ISubPageForm)
Property changes on: Products.Five/trunk/formlib/formbase.py
___________________________________________________________________
Name: svn:eol-style
+ native
Deleted: Products.Five/trunk/formlib/pageform.pt
===================================================================
--- Products.Five/trunk/formlib/pageform.pt 2006-10-25 11:59:22 UTC (rev 70911)
+++ Products.Five/trunk/formlib/pageform.pt 2006-10-25 12:01:35 UTC (rev 70912)
@@ -1,154 +0,0 @@
-<html xmlns="http://www.w3.org/1999/xhtml"
- xmlns:metal="http://xml.zope.org/namespaces/metal"
- xmlns:tal="http://xml.zope.org/namespaces/tal"
- xmlns:i18n="http://xml.zope.org/namespaces/i18n"
- metal:use-macro="context/@@standard_macros/page">
-<head>
-</head>
-
-<body>
-<div metal:fill-slot="body">
-
-<div metal:define-macro="form">
-
-<form action="." metal:define-macro="master"
- tal:attributes="action request/URL" method="post"
- class="edit-form" enctype="multipart/form-data"
- id="zc.page.browser_form">
-
-<script type="text/javascript"><!--
-
- function toggleFormFieldHelp(ob,state) {
- // ob is the label element
- var field = ob.form[ob.htmlFor];
- if (field) {
- var viz = state && 'hidden' || 'visible';
- if (field.length == null) {
- field.style.visibility = viz;
- }
- else {
- for (var i = 0; i < field.length; ++i) {
- var e = field.item(i);
- e.style.visibility = viz;
- }
- }
- var help = document.getElementById("field-help-for-" + field.name);
- if (help) {
- help.style.visibility = state && 'visible' || 'hidden';
- }
- }
- }
-
- //-->
-</script>
-
-<div id="viewspace" metal:define-slot="viewspace">
-
- <h1 i18n:translate=""
- tal:condition="view/label"
- tal:content="view/label"
- metal:define-slot="heading"
- >Do something</h1>
-
- <metal:block define-macro="header">
-
- <div class="form-status"
- tal:define="status view/status"
- tal:condition="status">
-
- <div class="summary"
- i18n:translate=""
- tal:content="view/status">
- Form status summary
- </div>
-
- <ul class="errors" tal:condition="view/errors">
- <li tal:repeat="error view/error_views">
- <span tal:replace="structure error">Error Type</span>
- </li>
- </ul>
- </div>
-
- </metal:block>
-
- <div metal:define-slot="extra_info" tal:replace="nothing">
- </div>
-
- <table class="form-fields">
- <tr class="row" metal:define-slot="extra_top" tal:replace="nothing">
- <td class="label">Extra top</td>
- <td class="label"><input type="text" /></td>
- </tr>
- <tbody metal:define-slot="formbody" tal:omit-tag="">
- <tr tal:repeat="widget view/widgets">
- <td class="label" tal:define="hint widget/hint"
- metal:define-macro="labelcell">
- <label tal:condition="python:hint"
- tal:attributes="for widget/name"
- onmousedown="toggleFormFieldHelp(this,1)"
- onmouseup="toggleFormFieldHelp(this,0)"
- onmouseout="toggleFormFieldHelp(this,0)"
- style="cursor: help">
- <span class="required" tal:condition="widget/required"
- >*</span><span i18n:translate=""
- tal:content="widget/label">label</span>
- </label>
- <label tal:condition="python:not hint"
- tal:attributes="for widget/name">
- <span class="required" tal:condition="widget/required"
- >*</span><span i18n:translate=""
- tal:content="widget/label">label</span>
- </label>
- </td>
- <td class="field" tal:define="hint widget/hint"
- metal:define-macro="widgetcell">
- <div class="form-fields-help"
- i18n:translate=""
- tal:content="hint"
- tal:condition="hint"
- tal:attributes="id string:field-help-for-${widget/name}"
- onclick="this.style.visibility='hidden';"
- style="visibility: hidden; position: absolute;"
- >Title of this content object.</div>
- <div class="widget" tal:content="structure widget">
- <input type="text" /></div>
- <div class="error"
- tal:condition="widget/error"
- >
- <!-- TODO Put this back, the Zope3 way.
- <img src="alert.gif" alt="Error"
- tal:replace="structure context/alert.gif" />
- -->
- <span tal:replace="structure widget/error">error</span>
- </div>
- </td>
- </tr>
- </tbody>
- <tr class="row" metal:define-slot="extra_bottom" tal:replace="nothing">
- <td class="label">Extra bottom</td>
- <td class="label"><input type="text" /></td>
- </tr>
- </table>
- <metal:block define-slot="above_buttons" />
-</div>
-<div id="actionsView">
- <span class="actionButtons"
- tal:condition="view/availableActions"
- metal:define-slot="bottom_buttons">
- <input tal:repeat="action view/actions"
- tal:replace="structure action/render"
- />
- </span>
-</div>
-
-</form>
-<script type="text/javascript" metal:define-slot="trackChanges">
- zc_trackChanges(document.getElementById('zc.page.browser_form'));
-</script>
-
-<script type="text/javascript"
- tal:define="extra_script view/extra_script | nothing"
- tal:condition="extra_script"
- tal:content="structure extra_script" />
-
-</div></div></body></html>
Deleted: Products.Five/trunk/formlib/subpageform.pt
===================================================================
--- Products.Five/trunk/formlib/subpageform.pt 2006-10-25 11:59:22 UTC (rev 70911)
+++ Products.Five/trunk/formlib/subpageform.pt 2006-10-25 12:01:35 UTC (rev 70912)
@@ -1,106 +0,0 @@
-<div metal:define-macro="form">
-
- <h1
- i18n:translate=""
- tal:condition="view/label"
- tal:content="view/label"
- metal:define-slot="heading"
- >Do something</h1>
-
- <div class="form-status"
- tal:define="status view/status"
- tal:condition="status">
-
- <div class="summary" tal:content="view/status" i18n:translate="">
- Form status summary
- </div>
-
- <ul class="errors" tal:condition="view/errors">
- <li tal:repeat="error view/error_views">
- <span tal:replace="structure error">Error Type</span>
- </li>
- </ul>
- </div>
-
- <div metal:define-slot="extra_info" tal:replace="nothing">
- </div>
-
-<!--
- <div class="form-controls" tal:condition="view/availableActions"
- metal:define-slot="top_buttons">
- <input tal:repeat="action view/actions"
- tal:replace="structure action/render"
- />
- </div>
--->
-
- <table class="form-fields">
- <tr class="row" metal:define-slot="extra_top" tal:replace="nothing">
- <td class="label">Extra top</td>
- <td class="label"><input type="text" /></td>
- </tr>
- <tbody metal:define-slot="formbody" tal:omit-tag="">
- <tr tal:repeat="widget view/widgets">
- <td class="label" tal:define="hint widget/hint"
- metal:define-macro="labelcell">
- <label tal:condition="python:hint"
- tal:attributes="for widget/name"
- onmousedown="toggleFormFieldHelp(this,1)"
- onmouseup="toggleFormFieldHelp(this,0)"
- onmouseout="toggleFormFieldHelp(this,0)"
- style="cursor: help">
- <span class="required" tal:condition="widget/required"
- >*</span><span i18n:translate=""
- tal:content="widget/label">label</span>
- </label>
- <label tal:condition="python:not hint"
- tal:attributes="for widget/name">
- <span class="required" tal:condition="widget/required"
- >*</span><span i18n:translate=""
- tal:content="widget/label">label</span>
- </label>
- </td>
- <td class="field" tal:define="hint widget/hint"
- metal:define-macro="widgetcell">
- <div class="form-fields-help"
- tal:content="hint"
- tal:condition="hint"
- tal:attributes="id string:field-help-for-${widget/name}"
- onclick="this.style.visibility='hidden';"
- i18n:translate=""
- style="visibility: hidden; position: absolute;"
- >Title of this content object.</div>
- <div class="widget" tal:content="structure widget">
- <input type="text" /></div>
- <div class="error"
- define="error widget/error"
- tal:condition="widget/error"
- >
- <!-- TODO Put this back, the Zope3 way.
- <img src="alert.gif" alt="Error"
- tal:replace="structure context/alert.gif" />
- -->
- <span tal:replace="structure widget/error">error</span>
- </div>
- </td>
- </tr>
- </tbody>
- <tr class="row" metal:define-slot="extra_bottom" tal:replace="nothing">
- <td class="label">Extra bottom</td>
- <td class="label"><input type="text" /></td>
- </tr>
- </table>
-
- <div class="form-controls" tal:condition="view/availableActions"
- metal:define-slot="bottom_buttons">
- <input tal:repeat="action view/actions"
- tal:replace="structure action/render"
- />
- </div>
-
-<script type="text/javascript"
- tal:define="extra_script view/extra_script | nothing"
- tal:condition="extra_script"
- tal:content="structure extra_script" />
-
-</div>
More information about the Zope-Checkins
mailing list