Skip to content

mxm, IT's mad science

Sections
Personal tools
You are here: Home » Products » Open Source » IIS utilities for Python
Downloads
You can download mxm products here.

Due to it's technical and international nature, this section is in english.

Max M Has a blog too.

og er glad for mad

 

IIS utilities for Python

A small collection of utilities, "winFieldStorage" & "request", that makes it easier to work on Microsofts IIS webserver using the Python programming language.

They make it easier for programmers comming from an .asp background, but they also makes it possible to use Pythons fieldStorage under the iis server.

The request object

Takes a IIS Request object and returns a normal python dictionary with the same values. Per default it will only return values of Form and QueryString. Cookies and ServerVariables can be included in the same dict if needed. set "keep_blank_values=1" if keys with empty ('') values should be in the resulting dictionary.

Small examples (done in the .asp page):

        # Using the request function from an asp page

        from iisUtils import request
        req = request(Request) # pass the iis Request object as parameter

        # getting simple value
        value = req['value']
        Response.Write('%s<br>' % value)

        # getting list of values (values with same name makes a list)
        values = req['values']
        for value in values:
            Response.Write('%s<br>' % value)

        # Checking for checkbox value
        # (checkboxes only gets passed if they are checked)
        checkValue = req.has_key('checkValue')
        if checkValue:
            "Do stuff"

        # Getting value with default value if non-existing key.
        checkValue = int(req.get('checkValue', 'unchecked'))
        if checkValue == 'checked':

winFieldStorage

The main advantage of using the winFieldStorage instead of the request object, is that you can upload files from a form without any extra components.

Se the Python docs for more info in the fieldstorage object. 11.2 cgi -- Common Gateway Interface support.

Simple usage:

        fReq = winFieldStorage(Request)
        Response.Write(fReq['someVar'].value)

You can get the file here. It is a small module and the documentation is also in the source.

License: GPL

Created by maxm
Contributors : Max M
Last modified 2004-02-26 09:49 AM