[Zope3-checkins] CVS: Zope3/src/zope/app/browser/form - add.py:1.13
Tres Seaver
tseaver@zope.com
Tue, 25 Mar 2003 11:30:24 -0500
Update of /cvs-repository/Zope3/src/zope/app/browser/form
In directory cvs.zope.org:/tmp/cvs-serv8758/src/zope/app/browser/form
Modified Files:
add.py
Log Message:
- Adapt the new content object to our schema before writing "through"
the schema into the object.
=== Zope3/src/zope/app/browser/form/add.py 1.12 => 1.13 ===
--- Zope3/src/zope/app/browser/form/add.py:1.12 Tue Mar 25 07:21:09 2003
+++ Zope3/src/zope/app/browser/form/add.py Tue Mar 25 11:30:23 2003
@@ -26,6 +26,7 @@
from zope.configuration.action import Action
from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
from zope.security.checker import defineChecker, NamesChecker
+from zope.component import queryAdapter
from zope.component.view import provideView
from zope.publisher.interfaces.browser import IBrowserPresentation
from zope.app.pagetemplate.simpleviewclass import SimpleViewClass
@@ -89,13 +90,14 @@
kw[str(name)] = data[name]
content = self.create(*args, **kw)
+ adapted = queryAdapter(content, self.schema, content)
errors = []
for name in self._set_before_add:
if name in data:
try:
- setattr(content, name, data[name])
+ setattr(adapted, name, data[name])
except ValidationError:
errors.append(sys.exc_info()[1])
@@ -109,7 +111,7 @@
for name in self._set_after_add:
if name in data:
try:
- setattr(content, name, data[name])
+ setattr(adapted, name, data[name])
except ValidationError:
errors.append(sys.exc_info()[1])