isapi package

Todo

  • Create docstrings for remaining module members

isapi.install

Installation utilities for Python ISAPI filters and extensions.

isapi.install.AddExtensionFiles(params, options)

Register the modules used by the filters/extensions as a trusted ‘extension module’ - required by the default IIS6 security settings.

isapi.install.AssignScriptMaps(script_maps, target, update='replace')

Updates IIS with the supplied script map information.

Parameters:
  • script_maps (List[ScriptMapParameter]) – A list of ScriptMapParameter objects

  • target – An IIS Virtual Directory to assign the script maps to

  • update (str) – Optional string indicating how to update the maps, one of (‘start’, ‘end’, or ‘replace’).

Raises:

isapi.install.ConfigurationError – If there is a configuration error

isapi.install.CheckLoaderModule(dll_name)
exception isapi.install.ConfigurationError

Bases: InstallationError

isapi.install.CreateDirectory(params, options)
isapi.install.CreateISAPIFilter(filterParams, options)
isapi.install.DeleteExtensionFileRecords(params, options)
isapi.install.DeleteISAPIFilter(filterParams, options)
class isapi.install.FilterParameters(**kw)

Bases: object

AddExtensionFile = True
AddExtensionFile_CanDelete = True
AddExtensionFile_Description = None
AddExtensionFile_Enabled = True
AddExtensionFile_GroupID = None
Description = None
Name = None
Path = None
Server = None
isapi.install.FindPath(options, server, name)
isapi.install.FindWebServer(options, server_desc)

Legacy function to allow options to define a .server property to override the other parameter. Use GetWebServer instead.

isapi.install.GetLoaderModuleName(mod_name, check_module=None)
isapi.install.GetWebServer(description=None)

Load the web server instance (COM object) for a given instance or description. If None is specified, the default website is retrieved (indicated by the identifier 1.

isapi.install.HandleCommandLine(params, argv=None, conf_module_name=None, default_arg='install', opt_parser=None, custom_arg_handlers={})

Perform installation or removal of an ISAPI filter or extension.

This module handles standard command-line options and configuration information, and installs, removes or updates the configuration of an ISAPI filter or extension.

You must pass your configuration information in params - all other arguments are optional, and allow you to configure the installation process.

class isapi.install.ISAPIParameters(**kw)

Bases: object

Filters = []
ServerName = 'Default Web Site'
VirtualDirs = []
isapi.install.Install(params, options)
isapi.install.InstallModule(conf_module_name, params, options, log=<function <lambda>>)

Install the extension.

Parameters:
  • conf_module_name – Loader module name

  • params – Patch parameters

  • options – Uninstall options

  • log (? or None) – Some args for a lambda function

Raises:

isapi.install.ConfigurationError – If there is a configuration error

exception isapi.install.InstallationError

Bases: Exception

exception isapi.install.ItemNotFound

Bases: InstallationError

isapi.install.LoadWebServer(path)
isapi.install.LocateWebServerPath(description)

Find an IIS web server whose name or comment matches the provided description.

Parameters:

description (str) – IIS web server name or comment (case-insensitive)

Raises:

isapi.install.ItemNotFound – If no sites match the description

Returns:

IIS site path

Return type:

?

Examples:

>>> LocateWebServerPath('Default Web Site') 

or

>>> LocateWebServerPath('1') 
isapi.install.MergeStandardOptions(options, params)

Take an options object generated by the command line and merge the values into the IISParameters object.

isapi.install.RemoveDirectory(params, options)
isapi.install.RemoveScriptMaps(vd_params, options)

Remove script maps from the already installed virtual directory.

Parameters:
class isapi.install.ScriptMapParams(**kw)

Bases: object

AddExtensionFile = True
AddExtensionFile_CanDelete = True
AddExtensionFile_Description = None
AddExtensionFile_Enabled = True
AddExtensionFile_GroupID = None
Extension = None
Flags = 5
Module = None
Verbs = ''
isapi.install.Uninstall(params, options)
isapi.install.UninstallModule(conf_module_name, params, options, log=<function <lambda>>)

Remove the extension.

Parameters:
  • conf_module_name – Loader module name

  • params – Patch parameters

  • options – Uninstall options

  • log (? or None) – Some args for a lambda function

class isapi.install.VirtualDirParameters(**kw)

Bases: object

AccessExecute = True
AccessRead = False
AccessScript = False
AccessWrite = False
AppProtection = 2
ContentIndexed = False
DefaultDoc = None
Description = None
EnableDefaultDoc = False
EnableDirBrowsing = False
Headers = 'X-Powered-By: Python'
Name = None
Path = None
ScriptMapUpdate = 'end'
ScriptMaps = []
Server = None
Type = 'IIsWebVirtualDir'
is_root()

This virtual directory is a root directory if parent and name are blank

split_path()
isapi.install.build_usage(handler_map)
isapi.install.get_unique_items(sequence, reference)

Return items in sequence that cannot be found in reference.

Parameters:
  • sequence – A sequence?

  • reference – A reference?

Returns:

The unique items

Return type:

Tuple[obj]

isapi.install.log(level, what)
isapi.install.split_path(path)

Get the parent path and basename.

>>> split_path('/')
['', '']
>>> split_path('')
['', '']
>>> split_path('foo')
['', 'foo']
>>> split_path('/foo')
['', 'foo']
>>> split_path('/foo/bar')
['/foo', 'bar']
>>> split_path('foo/bar')
['/foo', 'bar']

isapi.isapicon

Constants needed by ISAPI filters and extensions.

isapi.simple

Simple base-classes for extensions and filters.

None of the filter and extension functions are considered ‘optional’ by the framework. These base-classes provide simple implementations for the Initialize and Terminate functions, allowing you to omit them,

It is not necessary to use these base-classes - but if you don’t, you must ensure each of the required methods are implemented.

class isapi.simple.SimpleExtension

Bases: object

Base class for a a simple ISAPI filter.

GetExtensionVersion(vi)

Called by the ISAPI framework to get the extension version

The default implementation uses the classes docstring to set the extension description.

HttpExtensionProc(control_block)

Called by the ISAPI framework for each extension request.

sub-classes must provide an implementation for this method.

TerminateExtension(status)

Called by the ISAPI framework as the extension terminates.

class isapi.simple.SimpleFilter

Bases: object

Base class for a a simple ISAPI filter

GetFilterVersion(fv)

Called by the ISAPI framework to get the extension version

The default implementation uses the classes docstring to set the extension description, and uses the classes filter_flags attribute to set the ISAPI filter flags - you must specify filter_flags in your class.

HttpFilterProc(fc)

Called by the ISAPI framework for each filter request.

sub-classes must provide an implementation for this method.

TerminateFilter(status)

Called by the ISAPI framework as the filter terminates.

filter_flags = None

isapi.threaded_extension

An ISAPI extension base class implemented using a thread-pool.

class isapi.threaded_extension.ThreadPoolExtension

Bases: SimpleExtension

Base class for an ISAPI extension based around a thread-pool

Dispatch(ecb)

Overridden by the sub-class to handle connection requests.

This class creates a thread-pool using a Windows completion port, and dispatches requests via this port. Sub-classes can generally implement each connection request using blocking reads and writes, and the thread-pool will still provide decent response to the end user.

The sub-class can set a max_workers attribute (default is 20). Note that this generally does not mean 20 threads will all be concurrently running, via the magic of Windows completion ports.

There is no default implementation - sub-classes must implement this.

DispatchConnection(errCode, bytes, key, overlapped)
GetExtensionVersion(vi)

Called by the ISAPI framework to get the extension version

The default implementation uses the classes docstring to set the extension description.

HandleDispatchError(ecb)

Handles errors in the Dispatch method.

When a Dispatch method call fails, this method is called to handle the exception. The default implementation formats the traceback in the browser.

HttpExtensionProc(control_block)

Called by the ISAPI framework for each extension request.

sub-classes must provide an implementation for this method.

TerminateExtension(status)

Called by the ISAPI framework as the extension terminates.

max_workers = 20
worker_shutdown_wait = 15000
class isapi.threaded_extension.WorkerThread(extension, io_req_port)

Bases: Thread

call_handler(cblock)
run()

Method representing the thread’s activity.

You may override this method in a subclass. The standard run() method invokes the callable object passed to the object’s constructor as the target argument, if any, with sequential and keyword arguments taken from the args and kwargs arguments, respectively.

isapi Exceptions

exception isapi.ISAPIError(errno, strerror=None, funcname=None)

Bases: Exception

exception isapi.FilterError(errno, strerror=None, funcname=None)

Bases: ISAPIError

exception isapi.ExtensionError(errno, strerror=None, funcname=None)

Bases: ISAPIError

exception isapi.InternalReloadException

Bases: Exception