[Checkins] SVN: zope.app.form/trunk/ Reverted my change for the
object widget as discussed on the list.
Christian Theune
ct at gocept.com
Thu Sep 27 05:43:07 EDT 2007
Log message for revision 80211:
Reverted my change for the object widget as discussed on the list.
Cleaned up the change log formatting.
Changed:
U zope.app.form/trunk/CHANGES.txt
U zope.app.form/trunk/setup.py
U zope.app.form/trunk/src/zope/app/form/browser/configure.zcml
U zope.app.form/trunk/src/zope/app/form/browser/ftests/test_objectwidget.py
U zope.app.form/trunk/src/zope/app/form/browser/objectwidget.py
U zope.app.form/trunk/src/zope/app/form/browser/objectwidget.txt
U zope.app.form/trunk/src/zope/app/form/browser/tests/test_objectwidget.py
-=-
Modified: zope.app.form/trunk/CHANGES.txt
===================================================================
--- zope.app.form/trunk/CHANGES.txt 2007-09-27 09:39:48 UTC (rev 80210)
+++ zope.app.form/trunk/CHANGES.txt 2007-09-27 09:43:07 UTC (rev 80211)
@@ -2,17 +2,12 @@
Changes
=======
-Next Version
-------------
+3.4.0
+=====
+
- zope.app.form now supports Python2.5
-After 3.4.0b1
-=============
- - Provide a subscriber for the object field that sets up location information
- when an object is set. (#98287)
-
-
Before 3.4
==========
Modified: zope.app.form/trunk/setup.py
===================================================================
--- zope.app.form/trunk/setup.py 2007-09-27 09:39:48 UTC (rev 80210)
+++ zope.app.form/trunk/setup.py 2007-09-27 09:43:07 UTC (rev 80211)
@@ -25,7 +25,7 @@
"zope.interface",
"zope.proxy",
"zope.publisher",
- "zope.schema>=3.4.0b1dev-r77624",
+ "zope.schema",
"zope.security",
"zope.app.basicskin",
"zope.location>=3.4.0a1-1",
Modified: zope.app.form/trunk/src/zope/app/form/browser/configure.zcml
===================================================================
--- zope.app.form/trunk/src/zope/app/form/browser/configure.zcml 2007-09-27 09:39:48 UTC (rev 80210)
+++ zope.app.form/trunk/src/zope/app/form/browser/configure.zcml 2007-09-27 09:43:07 UTC (rev 80211)
@@ -584,8 +584,6 @@
permission="zope.Public"
/>
- <subscriber handler=".objectwidget.setup_object_location" />
-
<!-- Register the form documentation with the apidoc tool -->
<configure
xmlns:apidoc="http://namespaces.zope.org/apidoc"
Modified: zope.app.form/trunk/src/zope/app/form/browser/ftests/test_objectwidget.py
===================================================================
--- zope.app.form/trunk/src/zope/app/form/browser/ftests/test_objectwidget.py 2007-09-27 09:39:48 UTC (rev 80210)
+++ zope.app.form/trunk/src/zope/app/form/browser/ftests/test_objectwidget.py 2007-09-27 09:43:07 UTC (rev 80211)
@@ -1,6 +1,6 @@
##############################################################################
#
-# Copyright (c) 2001-2007 Zope Corporation and Contributors.
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
@@ -21,25 +21,20 @@
from zope.publisher.browser import TestRequest
from zope.schema import Object, TextLine
import zope.security.checker
-import zope.location.location
-
from zope.app.form.browser import ObjectWidget
from zope.app.testing.functional import BrowserTestCase
from zope.app.form.browser.tests import support
from zope.app.form.testing import AppFormLayer
-
class ITestContact(Interface):
name = TextLine()
email = TextLine()
-
-
+
class TestContact(object):
implements(ITestContact)
-
class Test(BrowserTestCase, support.VerifyResults):
-
+
def setUp(self):
BrowserTestCase.setUp(self)
self.field = Object(ITestContact, __name__=u'foo')
@@ -71,38 +66,6 @@
)
self.verifyResult(widget(), check_list)
- def test_location(self):
- # Objects that are managed through an object field are automatically.
- # This is done to make objects created through sub-forms compatible
- # with the Zope security policy which bases it's decisions on the
- # location of objects.
- context = zope.location.location.Location()
- value = TestContact()
- field = zope.schema.Object(Interface,
- __name__='test_object')
- field.set(context, value)
-
- self.assertEquals(context, context.test_object.__parent__)
- self.assertEquals('test_object', context.test_object.__name__)
-
- def test_location_wrapper(self):
- # Objects that do not implement the ILocation interface will be
- # wrapped with a location proxy.
- class Dummy(object):
- pass
- context = Dummy()
- value = TestContact()
- field = zope.schema.Object(Interface,
- __name__='test_object')
- field.set(context, value)
-
- self.failIf(zope.location.interfaces.ILocation.providedBy(value))
- self.failUnless(zope.location.interfaces.ILocation.providedBy(
- context.test_object))
- self.assertEquals(context, context.test_object.__parent__)
- self.assertEquals('test_object', context.test_object.__name__)
-
-
def test_suite():
suite = unittest.TestSuite()
Test.layer = AppFormLayer
@@ -111,3 +74,6 @@
if __name__=='__main__':
unittest.main(defaultTest='test_suite')
+
+
+
Modified: zope.app.form/trunk/src/zope/app/form/browser/objectwidget.py
===================================================================
--- zope.app.form/trunk/src/zope/app/form/browser/objectwidget.py 2007-09-27 09:39:48 UTC (rev 80210)
+++ zope.app.form/trunk/src/zope/app/form/browser/objectwidget.py 2007-09-27 09:43:07 UTC (rev 80211)
@@ -17,8 +17,6 @@
"""
__docformat__ = 'restructuredtext'
-import zope.location.interfaces
-import zope.location.location
from zope import component
from zope.interface import implements
from zope.schema import getFieldNamesInOrder
@@ -141,7 +139,7 @@
errors.append(e)
if self._error is None:
self._error = {}
-
+
if name not in self._error:
self._error[name] = e
@@ -150,22 +148,27 @@
return content
+
def applyChanges(self, content):
field = self.context
- obj = field.query(content, None)
- if obj is None:
- # The object doesn't exist yet, so we create a new one. Existing
- # objects are updated, not re-created.
- obj = self.factory()
+
+ # create our new object value
+ value = field.query(content, None)
+ if value is None:
# TODO: ObjectCreatedEvent here would be nice
- # Apply the actual changes to the object.
- changes = applyWidgetsChanges(self, field.schema, target=obj,
+ value = self.factory()
+
+ # apply sub changes, see if there *are* any changes
+ # TODO: ObjectModifiedEvent here would be nice
+ changes = applyWidgetsChanges(self, field.schema, target=value,
names=self.names)
+
+ # if there's changes, then store the new value on the content
if changes:
- # Store the object on the content. We do this both in the case of
- # newly created as well as updated objects because field.set runs
- # some more validation on the schema-conformance.
- field.set(content, obj)
+ field.set(content, value)
+ # TODO: If value implements ILocation, set name to field name and
+ # parent to content
+
return changes
def hasInput(self):
@@ -188,14 +191,3 @@
self._setUpEditWidgets()
for name in self.names:
self.getSubWidget(name).setRenderedValue(getattr(value, name, None))
-
-
- at component.adapter(zope.schema.interfaces.IBeforeObjectAssignedEvent)
-def setup_object_location(event):
- # Locate an object that was the new object
- obj = event.object
- if not zope.location.interfaces.ILocation.providedBy(obj):
- obj = zope.location.location.LocationProxy(obj)
- obj.__parent__ = event.context
- obj.__name__ = event.name
- event.object = obj
Modified: zope.app.form/trunk/src/zope/app/form/browser/objectwidget.txt
===================================================================
--- zope.app.form/trunk/src/zope/app/form/browser/objectwidget.txt 2007-09-27 09:39:48 UTC (rev 80210)
+++ zope.app.form/trunk/src/zope/app/form/browser/objectwidget.txt 2007-09-27 09:43:07 UTC (rev 80211)
@@ -74,7 +74,7 @@
>>> IPerson.providedBy(family.father)
True
-Let's define a dummy class which doesn't implement IPerson:
+Let's define a dummy class which doesn't implements IPerson:
>>> class Dummy(object):
... """Dummy class."""
@@ -147,5 +147,3 @@
So, now you know my mothers and fathers name. I hope it's also clear how to
use the Object field and the ObjectWidget.
-
-
Modified: zope.app.form/trunk/src/zope/app/form/browser/tests/test_objectwidget.py
===================================================================
--- zope.app.form/trunk/src/zope/app/form/browser/tests/test_objectwidget.py 2007-09-27 09:39:48 UTC (rev 80210)
+++ zope.app.form/trunk/src/zope/app/form/browser/tests/test_objectwidget.py 2007-09-27 09:43:07 UTC (rev 80211)
@@ -135,8 +135,7 @@
unittest.makeSuite(ObjectWidgetTest),
doctest.DocFileSuite('../objectwidget.txt',
setUp=setup.placelessSetUp,
- tearDown=setup.placelessTearDown,
- optionflags=doctest.ELLIPSIS),
+ tearDown=setup.placelessTearDown),
doctest.DocTestSuite(),
))
More information about the Checkins
mailing list