[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/Forms/Browser - add.pt:1.1.2.1 add.py:1.1.2.2
Jim Fulton
jim@zope.com
Thu, 12 Dec 2002 14:24:30 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/Forms/Browser
In directory cvs.zope.org:/tmp/cvs-serv25140/Browser
Modified Files:
Tag: AdapterAndView-branch
add.py
Added Files:
Tag: AdapterAndView-branch
add.pt
Log Message:
Debugged the generic add view and form:add directives in practical use.
=== Added File Zope3/lib/python/Zope/App/Forms/Browser/add.pt ===
<html metal:use-macro="views/standard_macros/page">
<body>
<div metal:fill-slot="body">
<div metal:define-macro="body">
<form action="." tal:attributes="action request/URL" method="POST"
enctype="multipart/form-data"
>
<div metal:define-macro="formbody">
<h3 tal:condition="view/label"
tal:content="view/label"
metal:define-slot="heading"
>Edit something</h3>
<p tal:define="status view/update"
tal:condition="status"
tal:content="status" />
<div tal:condition="view/errors">
<ul>
<li tal:repeat="error view/errors">
<strong tal:content="error/__class__">
Error Type</strong>:
<span tal:content="error">Error text</span>
</li>
</ul>
</div>
<div metal:define-slot="extra_info" tal:replace="nothing">
</div>
<table width="100%" border="0">
<tr metal:define-slot="extra_top" tal:replace="nothing">
<td>Extra top</td>
<td><input type="text" style="width:100%" /></td>
</tr>
<tr metal:define-macro="widget_rows" tal:repeat="widget view/widgets"
tal:content="structure widget/row">
<td>Name</td>
<td><input type="text" style="width:100%" /></td>
</tr>
<tr metal:define-slot="extra_bottom" tal:replace="nothing">
<td>Extra bottom</td>
<td><input type="text" style="width:100%" /></td>
</tr>
</table>
</div>
<input type="submit" value="Refresh" />
<input type="submit" name="UPDATE_SUBMIT" value="Save Changes" />
</form>
</div>
</div>
</body>
</html>
=== Zope3/lib/python/Zope/App/Forms/Browser/add.py 1.1.2.1 => 1.1.2.2 ===
--- Zope3/lib/python/Zope/App/Forms/Browser/add.py:1.1.2.1 Thu Dec 12 13:33:54 2002
+++ Zope3/lib/python/Zope/App/Forms/Browser/add.py Thu Dec 12 14:24:29 2002
@@ -15,6 +15,7 @@
$Id$
"""
+import sys
from Zope.Event import publish
from Zope.Event.ObjectEvent import ObjectCreatedEvent
from Zope.App.Forms.Exceptions import WidgetsError
@@ -55,19 +56,21 @@
kw = {}
for name in self._keyword_arguments:
- kw[name] = data[name]
+ if name in data:
+ kw[str(name)] = data[name]
content = self._factory(*args, **kw)
errors = []
for name in self._set_before_add:
- try:
- setattr(content, name, data[name])
- except:
- # Yes, I want a bare except here to catch all errors and
- # include them in the error list
- errors.append(sys.exc_info()[1])
+ if name in data:
+ try:
+ setattr(content, name, data[name])
+ except:
+ # Yes, I want a bare except here to catch all errors and
+ # include them in the error list
+ errors.append(sys.exc_info()[1])
if errors:
raise WidgetsError(*errors)
@@ -82,12 +85,13 @@
for name in self._set_after_add:
- try:
- setattr(content, name, data[name])
- except:
- # Yes, I want a bare except here to catch all errors and
- # include them in the error list
- errors.append(sys.exc_info()[1])
+ if name in data:
+ try:
+ setattr(content, name, data[name])
+ except:
+ # Yes, I want a bare except here to catch all errors and
+ # include them in the error list
+ errors.append(sys.exc_info()[1])
if errors:
raise WidgetsError(*errors)
@@ -191,7 +195,11 @@
missing)
leftover = [n for n in leftover if n not in set_after_add]
- set_after_add += leftover
+ set_after_add += leftover
+
+ else:
+
+ set_after_add = leftover
return [
Action(