Newbie and Page Re-Loading

mosscliffe mcl.office at googlemail.com
Sat May 5 04:50:46 EDT 2007


Miki,

Thank you very much for your helpful reply.  A simple example is the
best way of getting started, I have found.

I have no excuses now - to not get it working.  I recently tried
Visual Studio with Visual Basic.  Nice for five minutes, but then all
the helping bits got in the way, so then you try to do it all yourself
and the logic behind 'viewstate' just seemed to do different things at
different times and my silver surfing brain, just wants to do things,
rather than learn all sorts of exceptions, which I will not remember
tomorrow, never mind the next week or month.

I will try the local server, after I get forms working.

A question for the future.  I am creating several spreadsheets on
google which contain data, I need to search and display on my web
page.  The data is quite large so I need to filter it as opposed to
just looking at the spreadsheet.  Am I right in thinking there is
something called an 'atom' feed, which will supply me the data from
google as a 'cursor' (think it is an SQL term) and I can read the rows
as records in python ?

Thanks again

Richard



On May 4, 10:10 pm, Miki <miki.teb... at gmail.com> wrote:
> Hello Richard,
>
> > I do not want to run a framework yet.  I would like to understand
> > python at script level, before adding more aspects to learn, like
> > frameworks.
>
> The way CGI works is that your script is called every time the
> corresponding HTML is loaded. You can access all the parameters sent
> to the script using cgi.FieldStorage.
>
> > I think I get your idea about hidden fields and how to alter them.
>
> Note that hidden fields are passed in plain text format from/to the
> server, don't send anything sensitive in them.
>
> > My single page script should work something like this
>
> > DisplayHTMLHeaderandBodyHeader
> > Check if this is a Re-Load (HiddenField would not exist first time I
> > am assuming)
>
> It could be None: cgi.FieldStorage().getvalue("hidden_attribute") ==
> None
>
> > Display SearchSection with previous SearchRequest
> > If SearchRequest is True: Get and Display Results
> > Display TrailerHTMLandTrailerBody
>
> > ......... Wait for NewSearch or NextPage
>
> In CGI you don't wait, the script exists and called again when use
> hits a button/refresh ...
>
> > Does the above make sense or is there a better way ?
>
> There are many other ways (AJAX, Web frameworks, FastCGI ...). However
> I'd recommend you start with plain CGI which is *simple*.
> Here is a small example:
> #!/usr/local/bin/python
>
> import cgitb; cgitb.enable() # Show errors in HTML output
> from cgi import FieldStorage
>
> FUNNY = [ "mickey", "donald", "daisy", "minnie", "goofy" ]
>
> def main():
>     print "Content-Type: text/html"
>     print
>
>     form = FieldStorage()
>     query = form.getvalue("query", "")
>
>     print '''<html><body>
>     <h1>Disney Search</h1>
>
>     <form>
>     <input type="text" name="query" value="%s">
>     <input type="submit" value="search">
>     ''' % query
>
>     if query:
>         for someone in FUNNY:
>             if query in someone:
>                 print "<br />%s" % someone
>
>     print "</form></body></html>"
>
> if __name__ == "__main__":
>     main()
>
> > How do I get the directory of my modules into the Python Path
>
> import sys
 > sys.path.append("/path/to/my/modules")
>
> Note that your script directory is automatically added to the path.
>
> > Is there a lightweight Https Server I could run locally (WINXP), which
> > would run .py scripts, without lots of installation modifications ?
>
> http://lighttpd.net.
> Make sure "mod_cgi" is uncommented, set your document root and set
> right python interpreter in cgi.assign
>
> HTH,
> --
> Miki <miki.teb... at gmail.com>http://pythonwise.blogspot.com





More information about the Python-list mailing list