2.4.1 SchemeHandler interface

SchemeHandler ()

SchemeHandlers are used by Sablotron to resolve URLs that use other schemes than the builtin file: and arg:(eg. http: or ftp:). An example scheme handler that uses the standard python module urllib.py is provided in the file urlhandler.py.

Aside from the example file urlhandler.py there is no class or type in Sablot that implements SchemeHandler. This is an interface that must be implemented by the user in some class. A class instance of this implementation is then passed to regHandler().

In the C level interface to Sablotrons, SchemeHandlers return an error code to Sablotron. Because the return code of the methods below is used for other values, the error code must be passed in a different way. Sab-pyth defines the exception SchemeHandlerError for this. By calling raise SchemeHandlerError, code from within a handler method, you pass code to the C level Sablotron API.

getAll (scheme, rest)
getAll: open the URI and return the whole string

scheme = URI scheme (e.g. "http")

rest = the rest of the URI (without colon)

open (scheme, rest)
open: open the URI and return a handle

scheme = URI scheme (e.g. "http")

rest = the rest of the URI (without colon)

get (handle, bytecount)
get: retrieve data from the URI

handle = the handle assigned on open

byteCount = number of bytes to read (the number actually read is returned here)

put (handle, string)
put: save data to the URI (if possible)

handle = the handle assigned on open

string = the data

close (handle)
close: close the URI with the given handle

handle = the handle assigned on open


Send comments to guenter@ubka.uni-karlsruhe.de.