Skip to content

Commit

Permalink
Added conditional use of class interfaces to configure widget attribu…
Browse files Browse the repository at this point in the history
…tes ('widget' directive). In some cases, a widget class can be a function (used in double-dispatch patterns, e.g. vocab widgets).

In cases where a function is specified as the 'class' attribute, additional widget paramters (e.g. width, height, etc.) are silently ignored.
  • Loading branch information
Garrett Smith committed Aug 5, 2004
1 parent 8ccf2e6 commit 701b5a3
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions browser/metaconfigure.py
Expand Up @@ -64,16 +64,16 @@ def __init__(self, _context, **kwargs):

def widget(self, _context, field, class_, **kw):
attrs = kw
ifaces = implementedBy(class_)
# Try to do better than accepting the string value by looking through
# the interfaces and trying to find the field, so that we can use
# 'fromUnicode()'
for name, value in kw.items():
for iface in ifaces:
if name in iface:
attrs[name] = iface[name].fromUnicode(value)
break

if isinstance(class_, type):
ifaces = implementedBy(class_)
for name, value in kw.items():
for iface in ifaces:
if name in iface:
attrs[name] = iface[name].fromUnicode(value)
break
self._widgets[field+'_widget'] = CustomWidgetFactory(class_, **attrs)

def _processWidgets(self):
Expand Down

0 comments on commit 701b5a3

Please sign in to comment.