The OneShot adapter is a simple CGI that loads the entire AppServer, responds to the request, and then shuts down. Developers edit many of their Python modules and other file resources during development, so they find using OneShot convenient because it guarantees that everything is loaded fresh.
Docs are provided in the WebKit Install Guide which you can read on-line.
-- ChuckEsterbrook - 30 Oct 2001
I find OneShot.cgi to be too slow for testing, perhaps because I have a relatively slow machine. In any case, I modified WebKit.cgi (which is run on every request) to first look for changes in my source tree, and restart the appserver if there were any changes made. That way I have a delay on the first request after making a change, but for subsequent pages it's almost as fast as WebKit.
I had to allow the www-data user (under which cgi runs on my machine) write permissions to my app directory, so that it can create a timestamp and write to the log file.
Here's the source, hope it's useful:
#!/usr/bin/env python # If the Webware installation is located somewhere else, # then set the WebwareDir variable to point to it. # For example, WebwareDir = '/Servers/Webware' WebwareDir = '/home/jdhildeb/projects/Webware' # If you used the MakeAppWorkDir.py script to make a separate # application working directory, specify it here. AppWorkDir = '/home/jdhildeb/projects/mobile/app' try: import os, sys # my mod starts here file = os.popen("cd %s ; find . -name '*.py' -newer timestamp" % ( AppWorkDir ) , "r" ) output = file.readlines() file.close() if len(output) > 0: os.system("cd %s; kill `cat appserverpid.txt` ; touch timestamp; sleep 1 ; ./AppServer &>appserver.log &" % AppWorkDir ) # my mod ends here if WebwareDir: sys.path.insert(1, WebwareDir) else: WebwareDir = os.path.dirname(os.getcwd()) webKitDir = os.path.join(WebwareDir, 'WebKit') if AppWorkDir is None: AppWorkDir = webKitDir else: sys.path.insert(1, AppWorkDir) import WebKit.CGIAdapter WebKit.CGIAdapter.main(AppWorkDir) except: import string, sys, traceback from time import asctime, localtime, time sys.stderr.write('[%s] [error] WebKit: Error in adapter\n' % asctime(localtime(time()))) sys.stderr.write('Error while executing script\n') traceback.print_exc(file=sys.stderr) output = apply(traceback.format_exception, sys.exc_info()) output = string.join(output, '') output = string.replace(output, '&', '&') output = string.replace(output, '<', '<') output = string.replace(output, '>', '>') output = string.replace(output, '"', '"') sys.stdout.write('''Content-type: text/html <html><body> <p>ERROR <p><pre>%s</pre> </body></html>\n''' % output)
-- JasonHildebrand - 17 Jan 2002