SVN: r26052 - in trunk/quixote: doc form

David Binger <dbinger-fVcApmY9cLvQ3/1i3zOLAti2O/[email protected]> Thu, 10 Feb 2005 16:18:58 -0500
Newsgroups gmane.comp.web.quixote.cvs
Message-ID <[email protected]>
Author: dbinger
Date: 2005-02-10 16:18:57 -0500 (Thu, 10 Feb 2005)
New Revision: 26052

Modified:
    trunk/quixote/doc/upgrading.txt
    trunk/quixote/form/compatibility.py
    trunk/quixote/form/form.py
Log:
Change 'action_url' to 'action' in Form2.


Modified: trunk/quixote/doc/upgrading.txt
===================================================================
--- trunk/quixote/doc/upgrading.txt	2005-02-10 17:10:15 UTC (rev 26051)
+++ trunk/quixote/doc/upgrading.txt	2005-02-10 21:18:57 UTC (rev 26052)
@@ -66,6 +66,8 @@
  code calls Form.__init__ with 'attrs=foo', you'll need to change it to
  '**foo'.  Form instances no longer have a name attribute.  If your code
  looks for form.name, you can find it with form.attrs.get('name').
+The Form.__init__ keyword parameter (and attribute) 'action_url' is now
+named 'action'.

  Changes from 0.6.1 to 1.0
  -------------------------

Modified: trunk/quixote/form/compatibility.py
===================================================================
--- trunk/quixote/form/compatibility.py	2005-02-10 17:10:15 UTC (rev 
26051)
+++ trunk/quixote/form/compatibility.py	2005-02-10 21:18:57 UTC (rev 
26052)
@@ -31,9 +31,10 @@


  class Form(_Form):
-    def __init__(self, *args, **kwargs):
-        _Form.__init__(self, *args, **kwargs)
+    def __init__(self, *args, action_url=None, **kwargs):
+        _Form.__init__(self, *args, action=action_url, **kwargs)
          self.cancel_url = None
+        self.action_url = self.action

      def add_widget(self, widget_class, name, value=None,
                     title=None, hint=None, required=False, **kwargs):

Modified: trunk/quixote/form/form.py
===================================================================
--- trunk/quixote/form/form.py	2005-02-10 17:10:15 UTC (rev 26051)
+++ trunk/quixote/form/form.py	2005-02-10 21:18:57 UTC (rev 26052)
@@ -71,7 +71,7 @@

      def __init__(self,
                   method="post",
-                 action_url=None,
+                 action=None,
                   enctype=None,
                   use_tokens=True,
                   **attrs):
@@ -80,7 +80,7 @@
              raise ValueError("Form method must be 'post' or 'get', "
                               "not %r" % method)
          self.method = method
-        self.action_url = action_url or self._get_default_action_url()
+        self.action = action or self._get_default_action()
          if 'class' not in attrs:
              attrs['class'] = 'quixote'
          self.attrs = attrs
@@ -103,13 +103,12 @@
                  # attacks and prevents a form from being submitted 
twice
                  self.add(FormTokenWidget, self.TOKEN_NAME, value=None)

-    def _get_default_action_url(self):
-        request = get_request()
-        action_url = url_quote(request.get_path())
-        query = request.get_query()
+    def _get_default_action(self):
+        query = get_request().get_query()
          if query:
-            action_url += "?" + query
-        return action_url
+            return "?" + query
+        else:
+            return ""

      # -- Form data access methods 
--------------------------------------

@@ -295,7 +294,7 @@
      def _render_start(self):
          r = TemplateIO(html=True)
          r += htmltag('form', method=self.method,
-                     enctype=self.enctype, action=self.action_url,
+                     enctype=self.enctype, action=self.action,
                       **self.attrs)
          r += self._render_hidden_widgets()
          return r.getvalue()