CGI FieldStorage instances?

Discussion in 'Python' started by Gnarlodious, Nov 21, 2010.

  1. Gnarlodious

    Gnarlodious Guest

    I'm having a hard time understanding this, can someone explain?

    Running a CGI with query string:

    ?action=Find&page=Data

    Script includes these lines:

    form=cgi.FieldStorage(keep_blank_values=1)
    print("Content-type:text/html\n\n")
    print(cgi.print_form(form))

    Output:

    Form Contents:

    action: <class 'cgi.MiniFieldStorage'>
    MiniFieldStorage('action', 'Find')
    page: <class 'cgi.MiniFieldStorage'>
    MiniFieldStorage('page', 'Data')


    It looks like every variable in the query string instantiates a
    MiniFieldStorage with that value, is that the case? And if so, what
    sort of cool tricks could I do with that feature? Because so far I am
    doing CGI and it is a big old mess. Intercepting every variable is
    complicated and confusing. Is there an easier way?

    -- Gnarlie
     
    Gnarlodious, Nov 21, 2010
    #1
    1. Advertising

  2. Gnarlodious

    Gnarlodious Guest

    Let me rephrase the question. Say I have a query string like this:

    ?view=Data&item=9875

    What I want to do is simply invoke process "view" with variable
    "Data". This would replace my existing query string mess which looks
    like this:

    if 'view' in form and 'item' in form:
    HTML=view(Data, item(9875))

    so it just seems like it would be easier to encode the process in the
    query rather than filtering the query string.

    -- Gnarlie
     
    Gnarlodious, Nov 23, 2010
    #2
    1. Advertising

  3. On Mon, 22 Nov 2010 20:40:44 -0800 (PST), Gnarlodious
    <> declaimed the following in
    gmane.comp.python.general:

    > Let me rephrase the question. Say I have a query string like this:
    >
    > ?view=Data&item=9875
    >
    > What I want to do is simply invoke process "view" with variable
    > "Data". This would replace my existing query string mess which looks
    > like this:
    >

    So... Can you make "view" a "page" (CGI program) with one query
    item...

    .../view/?item=9875

    Or upgrade to some modernistic framework wherein the application is
    a monolithic program and the "name/" portion maps to methods/functions
    within the application...


    --
    Wulfraed Dennis Lee Bieber AF6VN
    HTTP://wlfraed.home.netcom.com/
     
    Dennis Lee Bieber, Nov 23, 2010
    #3
  4. Gnarlodious

    Gnarlodious Guest

    On Nov 22, 11:32 pm, Dennis Lee Bieber wrote:

    >         Or upgrade to some modernistic framework wherein the application is
    > a monolithic program and the "name/" portion maps to methods/functions
    > within the application...


    Yes, that describes what I am looking for! Is there such a modernistic
    framework? Links?

    -- Gnarlie, K5ZN
     
    Gnarlodious, Nov 24, 2010
    #4
  5. Gnarlodious

    Ian Kelly Guest

    On 11/23/2010 7:01 PM, Gnarlodious wrote:
    > On Nov 22, 11:32 pm, Dennis Lee Bieber wrote:
    >
    >> Or upgrade to some modernistic framework wherein the application is
    >> a monolithic program and the "name/" portion maps to methods/functions
    >> within the application...

    >
    > Yes, that describes what I am looking for! Is there such a modernistic
    > framework? Links?


    Try Django[1] or TurboGears[2].

    [1] http://www.djangoproject.com/
    [2] http://www.turbogears.org/

    Cheers,
    Ian
     
    Ian Kelly, Nov 24, 2010
    #5
  6. Gnarlodious

    Gnarlodious Guest

    On Nov 23, 7:22 pm, Ian Kelly wrote:

    > Try Django[1] or TurboGears[2].
    >
    > [1]http://www.djangoproject.com/
    > [2]http://www.turbogears.org/


    Thanks, never understood what those programs were for.

    -- Gnarlie
     
    Gnarlodious, Nov 24, 2010
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Al Stoltz
    Replies:
    1
    Views:
    1,075
    Andrew Clover
    Jan 23, 2004
  2. Fred Murray

    Odd cgi.FieldStorage behavior

    Fred Murray, Mar 2, 2004, in forum: Python
    Replies:
    1
    Views:
    324
    Tim Roberts
    Mar 4, 2004
  3. python user

    libapreq2 and cgi.FieldStorage

    python user, Jul 9, 2004, in forum: Python
    Replies:
    0
    Views:
    364
    python user
    Jul 9, 2004
  4. Austyn Bontrager

    cgi.FieldStorage and REDIRECT_REQUEST_METHOD

    Austyn Bontrager, Jul 28, 2004, in forum: Python
    Replies:
    1
    Views:
    506
    Lee Harr
    Jul 28, 2004
  5. Ames Andreas (MPA/DF)
    Replies:
    0
    Views:
    317
    Ames Andreas (MPA/DF)
    Aug 5, 2004
Loading...

Share This Page