Issue Details (XML | Word | Printable)

Key: MODPYTHON-93
Type: Improvement Improvement
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Graham Dumpleton
Reporter: Jim Gallacher
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
mod_python

Improve util.FieldStorage efficiency

Created: 27/Nov/05 05:35 AM   Updated: 02/Apr/07 11:40 AM
Return to search
Issue 93 of 174 issue(s)
<< Previous | MODPYTHON-93 | Next >>
Component/s: core
Affects Version/s: 3.2.7
Fix Version/s: 3.3.1

Time Tracking:
Not Specified

File Attachments:
  Size
Text File Licensed for inclusion in ASF works modpython325_util_py_dict.patch 2005-12-02 03:47 PM Mike Looijmans 8 kB

Resolution Date: 22/Nov/06 11:18 AM


 Description  « Hide
Form fields are saved as a list in a FieldStorage class instance. The class implements a __getitem__ method to provide dict-like behaviour. This method iterates over the complete list for every call to __getitem__. Applications that need to access all the fields when processing the form will show O(n^2) behaviour where n == the number of form fields. This overhead could be avoided by creating a dict (to use as an index) when the FieldStorage instance is created.

Mike Looijmans has been investigating StringField and Field as well. It is probably reasonable to include information on his work in this issue as well, so that we can consider all of these efficiency issues in toto.

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Repository Revision Date User Message
ASF #387693 Wed Mar 22 02:53:48 UTC 2006 jgallacher FieldStorage efficiency improvement provided by
Mike Looijmans. Adapted FieldStorage documentation examples
from Barry Pearce.
(MODPYTHON-93)
Files Changed
MODIFY /httpd/mod_python/trunk/Doc/modpython4.tex
MODIFY /httpd/mod_python/trunk/lib/python/mod_python/util.py
MODIFY /httpd/mod_python/trunk/Doc/appendixc.tex

Repository Revision Date User Message
ASF #393781 Thu Apr 13 10:50:36 UTC 2006 grahamd Backported MODPYTHON-93 from trunk to branches/3.2.x.
Files Changed
MODIFY /httpd/mod_python/branches/3.2.x/lib/python/mod_python/__init__.py
MODIFY /httpd/mod_python/branches/3.2.x/Doc/appendixc.tex
MODIFY /httpd/mod_python/branches/3.2.x/src/include/mpversion.h
MODIFY /httpd/mod_python/branches/3.2.x/Doc/modpython4.tex
MODIFY /httpd/mod_python/branches/3.2.x/lib/python/mod_python/util.py

Repository Revision Date User Message
ASF #416548 Fri Jun 23 02:56:11 UTC 2006 jgallacher As part of the improvments to FieldStorage, the Field class __init__ method
was changed in trunk (3.3-dev) and backported to branches/3.2.x. Although
the documentation states that the Field class is for internal use by
FieldStorage, some software applications create Field instances directly.
This change in the __init__ signature causes those applications to fail.

The code committed here is a work around that maintains forward compatibilty
with the FieldStorage improvements, while maintaining backward compatiblitly
with applications that may be using the Field class directly. (MODPYTHON-93)
Files Changed
MODIFY /httpd/mod_python/branches/3.2.x/lib/python/mod_python/util.py

Repository Revision Date User Message
ASF #417021 Sun Jun 25 14:40:44 UTC 2006 jgallacher Rolled back changes to Field and FieldStorage for MODPYTHON-93.
These changes were meant to improve FieldStorage efficiency, but
cause problems for applications such as Trac that treated
FieldStorage as a dictionary, or modified FieldStorage.list.
There is nothing in the documentation or source code stating that list
is private, or FieldStorage should be considered immutable, so these
applications were not wrong in doing so, and our changes should be
considered as unacceptable.
Files Changed
MODIFY /httpd/mod_python/branches/3.2.x/Doc/appendixc.tex
MODIFY /httpd/mod_python/branches/3.2.x/lib/python/mod_python/util.py

Repository Revision Date User Message
ASF #468187 Thu Oct 26 23:26:29 UTC 2006 grahamd (MODPYTHON-93) Fix up issues whereby quick lookup table onto list of form
fields isn't update when add_field() is used after first time that a lookup
of table is performed. The changes also allow direct changes to the list of
fields to be made with the lookup table being invalidated so that it will
be rebuilt the next time it is required.
Files Changed
MODIFY /httpd/mod_python/trunk/lib/python/mod_python/util.py
MODIFY /httpd/mod_python/trunk/lib/python/mod_python/__init__.py
MODIFY /httpd/mod_python/trunk/src/include/mpversion.h

Repository Revision Date User Message
ASF #468203 Fri Oct 27 00:18:08 UTC 2006 grahamd (MODPYTHON-93) Restored a level of backward compatibility for third party
packages which create instances of the Field class directly and insert them
direct into the list of form fields. This should mean that older versions
of Trac will still work.
Files Changed
MODIFY /httpd/mod_python/trunk/lib/python/mod_python/util.py

Repository Revision Date User Message
ASF #468211 Fri Oct 27 00:33:24 UTC 2006 grahamd (MODPYTHON-93) Logic check on when to trigger backwards compatibility mode
for Field class was wrong way around.
Files Changed
MODIFY /httpd/mod_python/trunk/lib/python/mod_python/util.py

Repository Revision Date User Message
ASF #468225 Fri Oct 27 01:44:03 UTC 2006 grahamd (MODPYTHON-93) Update documentation to list public interface of FieldStorage.
Files Changed
MODIFY /httpd/mod_python/trunk/Doc/modpython4.tex

Repository Revision Date User Message
ASF #468295 Fri Oct 27 06:32:07 UTC 2006 grahamd (MODPYTHON-93) No need to access keys of dictionary to determine len(), just
apply it to dictionary itself.
Files Changed
MODIFY /httpd/mod_python/trunk/lib/python/mod_python/util.py

Repository Revision Date User Message
ASF #468838 Sun Oct 29 06:17:06 UTC 2006 grahamd (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.
Files Changed
MODIFY /httpd/mod_python/trunk/Doc/modpython4.tex
MODIFY /httpd/mod_python/trunk/lib/python/mod_python/util.py
MODIFY /httpd/mod_python/trunk/lib/python/mod_python/__init__.py
MODIFY /httpd/mod_python/trunk/src/include/mpversion.h

Repository Revision Date User Message
ASF #468841 Sun Oct 29 07:31:39 UTC 2006 grahamd (MODPYTHON-93) The __delitem__() wasn't throwing a KeyError exception when
the field name didn't exist.
Files Changed
MODIFY /httpd/mod_python/trunk/lib/python/mod_python/util.py

Repository Revision Date User Message
ASF #468842 Sun Oct 29 07:46:25 UTC 2006 grahamd (MODPYTHON-93) Missing __iter__() method to support 'for k in form'.
Files Changed
MODIFY /httpd/mod_python/trunk/lib/python/mod_python/util.py

Repository Revision Date User Message
ASF #468843 Sun Oct 29 07:49:12 UTC 2006 grahamd (MODPYTHON-93) Missing an appropriate __repr__() method as well on
FieldStorage class.
Files Changed
MODIFY /httpd/mod_python/trunk/lib/python/mod_python/util.py

Repository Revision Date User Message
ASF #478129 Wed Nov 22 11:15:54 UTC 2006 grahamd (MODPYTHON-93) Made assignment using the subscript operator against the
FieldStorage class act like a dictionary. In other words, any existing values
against a field are replaced with a single value rather than an additional
value being added against the field.
Files Changed
MODIFY /httpd/mod_python/trunk/Doc/modpython4.tex
MODIFY /httpd/mod_python/trunk/lib/python/mod_python/util.py
MODIFY /httpd/mod_python/trunk/Doc/appendixc.tex