[Zope3-checkins]
SVN: Zope3/branches/isarsprint-dav-work/src/zope/app/dav/propfind.py
Slightly refactor the widget setup code;
more readable for me this way (now
Martijn Pieters
mj at zopatista.com
Thu Oct 14 07:18:49 EDT 2004
Log message for revision 28159:
Slightly refactor the widget setup code; more readable for me this way (now
that I understand this code) and also fixes a potential bug (where
field.missing_value is not None).
Changed:
U Zope3/branches/isarsprint-dav-work/src/zope/app/dav/propfind.py
-=-
Modified: Zope3/branches/isarsprint-dav-work/src/zope/app/dav/propfind.py
===================================================================
--- Zope3/branches/isarsprint-dav-work/src/zope/app/dav/propfind.py 2004-10-14 11:09:59 UTC (rev 28158)
+++ Zope3/branches/isarsprint-dav-work/src/zope/app/dav/propfind.py 2004-10-14 11:18:48 UTC (rev 28159)
@@ -16,7 +16,7 @@
__docformat__ = 'restructuredtext'
from xml.dom import minidom
-from zope.schema import getFieldNamesInOrder
+from zope.schema import getFieldNamesInOrder, getFields
from zope.app import zapi
from zope.app.container.interfaces import IReadContainer
from zope.app.form.utility import setUpWidgets
@@ -220,21 +220,19 @@
# The registered namespace case
initial = {}
- adapter = iface(self.context, None)
- for name in avail.get(ns):
- value = getattr(adapter, name, None)
- if value is not None:
+ for name, field in getFields(iface).items():
+ value = field.get(iface(self.context))
+ if value is not field.missing_value:
initial[name] = value
- setUpWidgets(self, iface, IDAVWidget,
- ignoreStickyValues=True, initial=initial,
- names=avail.get(ns))
+ setUpWidgets(self, iface, IDAVWidget, ignoreStickyValues=True,
+ initial=initial, names=avail[ns])
for p in avail.get(ns):
el = resp.createElement('%s' % p )
if ns is not None and ns != self.default_ns:
el.setAttribute('xmlns', attr_name)
prop.appendChild(el)
- value = getattr(self, p+'_widget')()
+ value = getattr(self, p + '_widget')()
if isinstance(value, (unicode, str)):
# Get the widget value here
@@ -244,7 +242,7 @@
el.appendChild(value)
else:
# Try to string-ify
- value = str(getattr(self, p+'_widget'))
+ value = str(getattr(self, p + '_widget'))
# Get the widget value here
el.appendChild(resp.createTextNode(value))
More information about the Zope3-Checkins
mailing list