You are viewing a plain text version of this content. The canonical link for it is here.
Posted to mod_python-commits@quetz.apache.org by gr...@apache.org on 2006/10/29 07:17:06 UTC

svn commit: r468838 - in /httpd/mod_python/trunk: Doc/modpython4.tex lib/python/mod_python/__init__.py lib/python/mod_python/util.py src/include/mpversion.h

Author: grahamd
Date: Sat Oct 28 23:17:06 2006
New Revision: 468838

URL: http://svn.apache.org/viewvc?view=rev&rev=468838
Log:
(MODPYTHON-93) Added clear(), __delitem__() and __setitem__() methods. The
__setitem__() method is an alias for add_field() and thus is additative
unlike a traditional dictionary.


Modified:
    httpd/mod_python/trunk/Doc/modpython4.tex
    httpd/mod_python/trunk/lib/python/mod_python/__init__.py
    httpd/mod_python/trunk/lib/python/mod_python/util.py
    httpd/mod_python/trunk/src/include/mpversion.h

Modified: httpd/mod_python/trunk/Doc/modpython4.tex
URL: http://svn.apache.org/viewvc/httpd/mod_python/trunk/Doc/modpython4.tex?view=diff&rev=468838&r1=468837&r2=468838
==============================================================================
--- httpd/mod_python/trunk/Doc/modpython4.tex (original)
+++ httpd/mod_python/trunk/Doc/modpython4.tex Sat Oct 28 23:17:06 2006
@@ -1756,10 +1756,12 @@
   the \member{file} attribute of a \class{Field} object.
 
   The \class{FieldStorage} class has a mapping object interface, i.e. it
-  can be treated like a dictionary in most instances, but is missing some
-  methods provided by dictionaries so is not completely compatible. When
-  used as a mapping, the keys are form input names, and the returned
-  dictionary value can be:
+  can be treated like a dictionary in most instances, but is not strictly
+  compatible as is it missing some methods provided by dictionaries and
+  some methods don't behave entirely like their counterparts, especially
+  when there is more than one value associated with a form field. When used
+  as a mapping, the keys are form input names, and the returned dictionary
+  value can be:
 
   \begin{itemize}
   \item
@@ -1801,6 +1803,13 @@
     will be added to the list of existing values for the form field.
     This method should be used for adding additional fields in
     preference to adding new fields direct to the list of fields.
+    When the subscript operator is used to update the form with new
+    fields, it is actually this method that is called.
+  \end{methoddesc}
+
+  \begin{methoddesc}[FieldStorage]{clear}{}
+    Removes all form fields. Individual form fields can be deleted
+    using the \code{del} operator.
   \end{methoddesc}
 
   \begin{methoddesc}[FieldStorage]{get}{name, default}

Modified: httpd/mod_python/trunk/lib/python/mod_python/__init__.py
URL: http://svn.apache.org/viewvc/httpd/mod_python/trunk/lib/python/mod_python/__init__.py?view=diff&rev=468838&r1=468837&r2=468838
==============================================================================
--- httpd/mod_python/trunk/lib/python/mod_python/__init__.py (original)
+++ httpd/mod_python/trunk/lib/python/mod_python/__init__.py Sat Oct 28 23:17:06 2006
@@ -20,5 +20,5 @@
 __all__ = ["apache", "cgihandler", "psp",
            "publisher", "util", "python22"]
 
-version = "3.3.0-dev-20061028"
+version = "3.3.0-dev-20061029"
 

Modified: httpd/mod_python/trunk/lib/python/mod_python/util.py
URL: http://svn.apache.org/viewvc/httpd/mod_python/trunk/lib/python/mod_python/util.py?view=diff&rev=468838&r1=468837&r2=468838
==============================================================================
--- httpd/mod_python/trunk/lib/python/mod_python/util.py (original)
+++ httpd/mod_python/trunk/lib/python/mod_python/util.py Sat Oct 28 23:17:06 2006
@@ -347,6 +347,8 @@
         item.name = key
         self.list.append(item)
 
+    __setitem__ = add_field
+
     def read_to_boundary(self, req, boundary, file):
         previous_delimiter = None
         while True:
@@ -442,6 +444,15 @@
         """Dictionary-style items(), except that items are returned in the same
         order as they were supplied in the form."""
         return [(item.name, item) for item in self.list]
+
+    def __delitem__(self, key):
+        table = self.list.table()
+        if key in table:
+            for value in table[key]:
+                self.list.remove(value)
+
+    def clear(self):
+        self.list = FieldList()
 
 
 def parse_header(line):

Modified: httpd/mod_python/trunk/src/include/mpversion.h
URL: http://svn.apache.org/viewvc/httpd/mod_python/trunk/src/include/mpversion.h?view=diff&rev=468838&r1=468837&r2=468838
==============================================================================
--- httpd/mod_python/trunk/src/include/mpversion.h (original)
+++ httpd/mod_python/trunk/src/include/mpversion.h Sat Oct 28 23:17:06 2006
@@ -1,5 +1,5 @@
 #define MPV_MAJOR 3
 #define MPV_MINOR 3
 #define MPV_PATCH 0
-#define MPV_BUILD 20061028
-#define MPV_STRING "3.3.0-dev-20061028"
+#define MPV_BUILD 20061029
+#define MPV_STRING "3.3.0-dev-20061029"