Web Framework

modelr.web

This module contains the Web specific parts of modelr.

modelr.web.server

Main program to strat a web server.

Created on Apr 30, 2012

@author: sean

class modelr.web.server.MyHandler(request, client_address, server)[source]

Handles a single request.

do_GET()[source]

handle a get request.

eval_script(script)[source]

Evaluate a script in the scripts directory.

get_available_scripts()[source]

Returns a list of all the scripts in the scripts directory.

run_script(script, script_main, add_arguments, short_description, parameters)[source]

Run a script

Parameters:
  • script_main – the main method of the script
  • add_arguments – poplate an argument parser
  • short_description – a short description of the script
  • parameters – the parameters from the get request
send_script_error(msg)[source]

Send an error related to the script.

terminate()[source]

shut down the application

modelr.web.server.main()[source]

Main method starts a server and exits on

modelr.web.urlparse

class modelr.web.urlargparse.Argument(name, required=False, default=None, type=<type 'str'>, action='store', help='', choices=None)[source]

A place holder for a url argument.

exception modelr.web.urlargparse.ArgumentError[source]

Exception to be called when arguments are not as expected by the parser.

exception modelr.web.urlargparse.SendHelp(html)[source]

Exception to be called when the help argument is found.

class modelr.web.urlargparse.URLArgumentParser(description)[source]

Parse a key=value arguments in a url string.

Modeled after http://docs.python.org/dev/library/argparse.html

add_argument(name, required=False, default=None, type=<type 'str'>, action='store', help='', choices=None)[source]

add an argument

parse_params(params)[source]

parse the arguments gotten by urlparse.parse_qs

parse_ulr(path)[source]

parse a url into its argument.

modelr.web.urlargparse.reflectivity_type(str_input)[source]

To be used as the ‘type’ value in an Argument.

Takes a string as input and returns an arbitrary value.

Example:

parser.add_argument('reflectivity_model',
type=reflectivity_type, help='... ', default='zoeppritz',
choices=MODELS.keys())
modelr.web.urlargparse.wavelet_type(str_input)[source]

To be used as the ‘type’ value in an Argument.

Takes a string as input and returns an arbitrary value.

Example:

parser.add_argument('wavelet', type=wavelet_type, help='... ',
                    default='ricker', choices=WAVELETS.keys())

Table Of Contents

Previous topic

Getting Started

Next topic

Models and Calculations

This Page