next up previous contents
Next: Output Restrictions and Requirements Up: Jython scripts Previous: Jython scripts   Contents


Modules

There are two types of modules that will be used from xbook scripts: xbook modules and Grid modules. A xbook module provides users with an interface to better utilize the xbook infrastructure. Currently, we provide 2 modules:

xbooks.archive
This module exports one xbook archiving method called archive(xbook, html, formValues, scriptOutput). This method is designed to be called within a doXXX method. The parameters are described below:

xbook
the xbook object passed in from the jython engine
html
the html string containing the form that triggered this method.
formValues
the hash table formValues passed into the doXXX routine.
scriptOutput
the output being returned to the client

xbooks.activity.handler
(note: the module name needs to be changed to just xbooks.handler). This module provides 2 classes which can be used as superclasses for a simple handler class. The classes are defined below:

Root
Defines a skeleton handler class for a xbook which just defines one method doXXX routine called 'doSubmit'.
__init__(self, workingDir)
Constructor which just stores the xbook path in a member variable called dir.
initialize(self, out)
Does nothing. It's a placeholder and should be overriden by subclass.
finalize(self, out)
Does nothing. It's a placeholder and should be overriden by subclass.
doSubmit(self, out, formValues)
Does nothing. It's a placeholder and should be overriden by subclass.
readFile(self, fileName)
Utility routine which reads in a file from the xbook directory and returns it as a string.

HTML
Defines a skeleton handler class for a xbook which reads in a html file and defines the handler in it for a doXXX routine called 'doSubmit'. This is a subclass of Root.
initialize(self, out)
Reads in a html called "index.html" located in the xbook directory and returns it to the client. (note this routine is currently broken; should just need to replace the line
  • content = self.readFile( xbook.getPath() + "/index.html" );
with
  • content = self.readFile( self.dir + "/index.html" );
doSubmit(self, out, formValues)
Echoes back the values of the formValues to the output stream out.
archive(self, out, formValues, xbook)
Archives a doXXX into a xbook page. The parameters are:
out
The string output of the doXXX being returned to the client.
formValues
the hash table formValues passed into the doXXX routine.
xbook
the xbook object passed in from the jython engine. This argument should be removed and replaced with the usage of self.dir.
Essentially, this function can be used to archive a simple xbook (i.e., create a subxbook). It utilizes the properties file to track the number and names of the subxbooks it has created. It stores the number in a instances tag and the names in subxbook tags as described in Section 2.3.0.2. It constructs the name of a new subxbook using the formula
		   subxbook_name = version + "." + str(instances++);

The second set of modules are Grid modules. Since jython allows for Java classes to be directly imported in the scripts, we can draw upon any Grid Java APIs. Examples of this include CoG[13], XMessages [24], XCAT [25], Chimera [26]. To use any of these modules, the user will need to ensure the paths to these jars are listed in the python.path in either the xbook manager jython_engine.cfg configuration file or the local xbook jython_engine.cfg configuration file.


next up previous contents
Next: Output Restrictions and Requirements Up: Jython scripts Previous: Jython scripts   Contents
Shava Smallen 2002-12-31