[Zope3-checkins] CVS: Zope3/src/zope/app/browser/container -
adding.py:1.16
Garrett Smith
garrett at mojave-corp.com
Fri Aug 15 16:41:49 EDT 2003
Update of /cvs-repository/Zope3/src/zope/app/browser/container
In directory cvs.zope.org:/tmp/cvs-serv4937/src/zope/app/browser/container
Modified Files:
adding.py
Log Message:
Fixed a problem that prevented the use of Adding with the id field. Added a test for the expected behavior.
=== Zope3/src/zope/app/browser/container/adding.py 1.15 => 1.16 ===
--- Zope3/src/zope/app/browser/container/adding.py:1.15 Fri Aug 15 12:38:30 2003
+++ Zope3/src/zope/app/browser/container/adding.py Fri Aug 15 15:41:14 2003
@@ -45,6 +45,8 @@
def add(self, content):
"""See zope.app.interfaces.container.IAdding"""
+ if not self.contentName:
+ raise ValueError("contentName is not set")
container = zapi.getAdapter(self.context, IZopeContainer)
name = container.setObject(self.contentName, content)
return container[name]
@@ -103,11 +105,11 @@
self.request.response.redirect(url)
return
- if not id:
- raise UserError(_(u"You must specify an id"))
-
- self.contentName = id
-
+ if self.namesAccepted():
+ if not id:
+ raise UserError(_(u"You must specify an id"))
+ self.contentName = id
+
content = zapi.createObject(self, type_name)
publish(self.context, ObjectCreatedEvent(content))
More information about the Zope3-Checkins
mailing list