[wwwsearch-commits] r18291 - wwwsearch/ClientForm/trunk
jjlee at codespeak.net
jjlee at codespeak.net
Sat Oct 8 19:00:54 CEST 2005
Author: jjlee
Date: Sat Oct 8 19:00:54 2005
New Revision: 18291
Modified:
wwwsearch/ClientForm/trunk/ClientForm.py
Log:
Make Items append themselves to control.items
Modified: wwwsearch/ClientForm/trunk/ClientForm.py
==============================================================================
--- wwwsearch/ClientForm/trunk/ClientForm.py (original)
+++ wwwsearch/ClientForm/trunk/ClientForm.py Sat Oct 8 19:00:54 2005
@@ -1380,6 +1380,7 @@
"_selected": False,
"id": attrs.get("id"),
})
+ control.items.append(self)
def get_labels(self):
"""Return all labels (Label instances) for this item.
@@ -1432,15 +1433,6 @@
" ".join(["%s=%r" % (k, v) for k, v in attrs])
)
-# XXX sort this out (and assertions about items and controls being in exactly
-# one container)
-# how to remove items from a list container: delete them as usual
-# ("del control.items[:]", for instance).
-# how to add items to a list container: instantiate Item with control, and add
-# to list ("control.items.append(Item(control, {...attrs...}))", for instance).
-# You never want an item to have an incorrect reference to its control (and
-# thus you never want an item to be in more than one control).
-
def disambiguate(items, nr, name, label):
msg = "name=%r label=%r" % (name, label)
if not items:
@@ -1549,6 +1541,7 @@
# control. Each merged-in Control instance corresponds to a single
# list item: see ListControl.__doc__.
self.items = []
+ self._form = None
self._select_default = select_default
self._clicked = False
@@ -1757,6 +1750,8 @@
return self._get(name, by_label, nr).attrs
def add_to_form(self, form):
+ assert self._form is None or form == self._form, (
+ "can't add control to more than one form")
self._form = form
try:
control = form.find_control(self.name, self.type)
@@ -2005,7 +2000,6 @@
self.__dict__["multiple"] = False
o = Item(self, attrs)
o.__dict__["_selected"] = attrs.has_key("checked")
- self.items.append(o)
def fixup(self):
ListControl.fixup(self)
@@ -2039,7 +2033,6 @@
self.__dict__["multiple"] = True
o = Item(self, attrs)
o.__dict__["_selected"] = attrs.has_key("checked")
- self.items.append(o)
def get_labels(self):
return []
@@ -2132,7 +2125,6 @@
o._labels.append(Label({"__text": contents}))
elif contents:
o._labels.append(Label({"__text": contents}))
- self.items.append(o)
def fixup(self):
ListControl.fixup(self)
More information about the wwwsearch-commits
mailing list