AjaxStub.HTML is passed to the type keyword in the constructor of
the AjaxStub class. It is the default and provides limited functionality
for your application.
AjaxStub.JSON is passed to the type keyword in the constructor of
the AjaxStub class. It enables JSON communication packets.
AjaxStub.XML is passed to the type keyword in the constructor of the
AjaxStub class. It enables XML communication packets.
AjaxStub.COMMAND represents the CGI name used to pass the stub name
back to the server and can be used with the getCGIValue and
hasCGIKey methods.
AjaxStub.ARGUMENT represents the CGI name used to pass a stub variable
back to the server and can be used with the getCGIValue and
hasCGIKey methods.
AjaxStub.GET represents the GET CGI method and can be used with the
setCGIMethod method or with the register method in he second
half of the tuple (method object, AjaxStub.GET).
AjaxStub.POST represents the POST CGI method and can be used with
the setCGIMethod method or with the register method in he
second half of the tuple (method object, AjaxStub.POST).
The
constructor takes two keyword arguments type defaults to
the AjaxStubDispatch.HTML member object and methodClassInstance
defaults to None. The options that can be passed to the type
argument are AjaxStub.JSON, AjaxStub.XML, or AjaxStub.HTML.
The methodClassInstance argument is used to pass in the instantiated
object of your public API (stubs) class. Note: Methods and
functions representing your public API can be used concurrently or
individually. Methods do not need to be registered individually.
as = AjaxStub(AjaxStub.XML, MyPublicAPI())
getCGIValue(self, key)
Returns the raw value from
the CGI parameter list where key is either AjaxStub.COMMAND
or AjaxStub.ARGUMENT.
value = as.getCGIValue(AjaxStub.COMMAND)
hasCGIKey(self, key)
Returns True if the
CGI parameter name exists else returns False.
if as.hasCGIKey(AjaxStub.COMMAND):
...
register(self, *args)
Registers a comma separated
list of function objects all using a default CGI method or a comma
separated list of tuples of function objects and a CGI method. Note:
This method can optionally be used to add additional functions to
your public API. Class methods are automatically registered when passed
into the AjaxStub constructor.
def username(name):
...
def password(name, passwd):
...
as.register(username, (password, AjaxStub.POST))
In the example above username will use the default CGI mode
and password will use the POST method.
unregister(self, name)
Unregister any function added
with the register method. Note: Class methods can not be unregistered.
as.unregister("password")
getMethodMaps(self)
Returns a tuple of two internal
dictionaries the map of the class API and a map of the registered
functions.
methodMap, functionMap = as.getMethodMaps()
setCGIMethod(self, method)
Set the default CGI method
for your Public API. If no default is set AjaxStub defaults to the
GET method. Only two methods are available at this time GET and POST.
as.setCGIMethod(AjaxStub.POST)
getCGIMethod(self)
Gets the default CGI method.
cgiMethod = as.getCGIMethod()
getStubMethodNameList(self)
Gets a list of all the function
and method names.
stubList = as.getStubMethodNameList()
_exportAjaxStubArgsJS(self)
Return the two JavaScript
variables that need to be set prior to instantiating the JavaScript
AjaxStub class.
_exportStubsJS(self)
Create the stubs and return them
as a string.
_handleClientRequest(self)
Handle the request from
the client and execute the method/function requested from the client.
includeTraceback(self)
Enables the including of the
traceback in the error result.