SVN: r23228 - trunk/quixote/form2
Neil Schemenauer <nascheme-fVcApmY9cLvQ3/1i3zOLAti2O/[email protected]> Mon, 24 Nov 2003 10:53:40 -0500
| Newsgroups | gmane.comp.web.quixote.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: nascheme
Date: 2003-11-24 10:53:40 -0500 (Mon, 24 Nov 2003)
New Revision: 23228
Modified:
trunk/quixote/form2/form.py
Log:
Rename Form.WIDGET_ROW_CLASS to COMPONENT_CLASS, since that's
what it really is. Make it an instance attribute as well as a
class attribute, so it can be overridden at form construction
time.
Modified: trunk/quixote/form2/form.py
===================================================================
--- trunk/quixote/form2/form.py 2003-11-24 14:42:44 UTC (rev 23227)
+++ trunk/quixote/form2/form.py 2003-11-24 15:53:40 UTC (rev 23228)
@@ -240,10 +240,15 @@
TOKEN_NAME = "_form_id" # name of hidden token widget
- WIDGET_ROW_CLASS = WidgetRow
+ COMPONENT_CLASS = WidgetRow
- def __init__(self, name=None, method="post", action_url=None,
- enctype=None, use_tokens=True):
+ def __init__(self,
+ name=None,
+ method="post",
+ action_url=None,
+ enctype=None,
+ use_tokens=True,
+ component_class=None):
if method not in ("post", "get"):
raise ValueError("Form method must be 'post' or 'get', "
@@ -272,6 +277,8 @@
self.add_hidden(self.TOKEN_NAME, None, FormTokenWidget)
self.use_form_tokens = True
+ self.component_class = component_class or self.COMPONENT_CLASS
+
def _get_default_action_url(self):
request = get_request()
action_url = url_quote(request.get_path())
@@ -377,7 +384,7 @@
"""
if issubclass(klass, HiddenWidget):
raise TypeError, "use add_hidden() to add hidden widgets"
- self.add_component(self.WIDGET_ROW_CLASS, name, klass, value,
+ self.add_component(self.component_class, name, klass, value,
title, hint, required, **kwargs)