Why is CGI module so complicated?

Michael P. Reilly arcege at shore.net
Thu Aug 12 18:28:20 CEST 1999


Magnus L. Hetland <mlh at idt.ntnu.no> wrote:
: "Michael P. Reilly" <arcege at shore.net> writes:

:> Ian Clarke <I.Clarke at strs.co.uk> wrote:
: [...]

:> 
:> What would be _really_ good (IMO) is to have a "toDict" method that
:> does this.

: Why not just a factory function in the cgi module?

Because (IMO):

a.  It would probably be better to have only one interface; especially
when that interface(s) is to instantiate the cgi input only once,
during a program.  Remember that POST methods don't allow you to
recreate the form data a second time (it assumes standard input, which
is unseekable).  This is a lamer reason than below, but clearer-cut
interfaces are part of what makes Python better than some other
languages (when it's set up like that :).

b.  The method is more usable than a factory function called instead of
FieldStorage.  You mention being able to use this with TemplateDocument
classes (in another article);  what if you want to get access to ALL
the data, but also want to give a dictionary representation to some
other interface as well?  The factory function returns the dict and
throws away the rest of the data, whereas creating the class preserves
all the data you need, keeping it available in your app, but also can
give the dictionary you need at other times.

BTW, I also like the idea of adding the __str__ method to
FieldStorage.

:   Magnus              Making no sound / Yet smouldering with passion
:   Lie          The firefly is still sadder / Than the moaning insect
:   Hetland                                       : Minamoto Shigeyuki

  -Arcege





More information about the Python-list mailing list