Update of /cvsroot/webware/Webware/WebKit/Docs
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15255/Docs
Modified Files:
RelNotes-X.Y.html
Log Message:
Refactored Page into Page and HTTPContent. Page inherits from HTTPContent
which inherits from HTTPServlet. HTTPContent is intended as a base class for
servlets which generate non-HTML output (i.e. images, etc.). Page should have
all methods it previously had; there should be no backward compatibility
issues.
Index: RelNotes-X.Y.html
===================================================================
RCS file: /cvsroot/webware/Webware/WebKit/Docs/RelNotes-X.Y.html,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** RelNotes-X.Y.html 1 Dec 2004 18:27:31 -0000 1.17
--- RelNotes-X.Y.html 1 Dec 2004 20:09:01 -0000 1.18
***************
*** 92,95 ****
--- 92,101 ----
Note that if the AppServer crashes a stale pid file will be left
around, which must be removed before the AppServer can be restarted.
+
+ <li> Page has been refactored into HTTPContent and Page. HTTPContent
+ can be used as a base class for servlets which generate non-HTML
+ content. As Page inherits from HTTPContent (which inherits from
+ HTTPServlet), Page still contains all the methods it previously did,
+ and this change should not require any changes to end-user code.
</ul>

Update of /cvsroot/webware/Webware/WebKit/Tests/Basic/MyContext
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32562/Basic/MyContext
Added Files:
Main.py __init__.py
Log Message:
Implemented a framework for testing WebKit end-to-end by using the
built-in http server. The module AppServerTest contains a TestCase base
class which starts/stops the appserver in a separate process, and allows
the test case to check whether certain output produced by the appserver.
(currently this has not been tweaked/tested to run on Win32, but this should
be straightforward).
Test cases will probably want to use a client-side web testing framework
(possibly webunit @ http://mechanicalcat.net/tech/webunit) for making
requests and testing responses.
--- NEW FILE: Main.py ---
from WebKit.Page import Page
class Main(Page):
def title(self):
return 'My Sample Context'
def writeContent(self):
self.writeln('<h1>Welcome to Webware!</h1>')
self.writeln('''
This is a sample context generated for you and has purposly been kept very simple
to give you something to play with to get yourself started. The code that implements
this page is located in <b>%s</b>.
''' % self.request().serverSidePath())
self.writeln('''
<p>
There are more examples and documentaion in the Webware distribution, which you
can get to from here:<p><ul>
''')
adapterName = self.request().adapterName()
ctxs = self.application().contexts().keys()
ctxs = filter(lambda ctx: ctx!='default', ctxs)
ctxs.sort()
for ctx in ctxs:
self.writeln('<li><a href="%s/%s/">%s</a>' % (adapterName, ctx, ctx))
self.writeln('</ul>')
--- NEW FILE: __init__.py ---
def contextInitialize(appServer, path):
# You could put initialization code here to be executed when
# the context is loaded into WebKit.
pass

Update of /cvsroot/webware/Webware/WebKit/Tests
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32562
Added Files:
.cvsignore AppServerTest.py FixPath.py README Test.py
__init__.py
Log Message:
Implemented a framework for testing WebKit end-to-end by using the
built-in http server. The module AppServerTest contains a TestCase base
class which starts/stops the appserver in a separate process, and allows
the test case to check whether certain output produced by the appserver.
(currently this has not been tweaked/tested to run on Win32, but this should
be straightforward).
Test cases will probably want to use a client-side web testing framework
(possibly webunit @ http://mechanicalcat.net/tech/webunit) for making
requests and testing responses.
--- NEW FILE: .cvsignore ---
*.pyc
--- NEW FILE: AppServerTest.py ---
import unittest
import os
import fcntl
import time
import signal
import re
class AppServerTest(unittest.TestCase):
def setUp(self):
# start the appserver
workdir = self.workDir()
dirname = os.path.dirname
webwaredir = dirname(dirname(dirname(workdir)))
launch = os.path.join(workdir, 'Launch.py')
cmd = "python %s --webware-path=%s --working-path=%s ThreadedAppServer http" % (launch, webwaredir, workdir)
#print cmd
dummy, self._output = os.popen4(cmd)
# set the output from the appserver to non-blocking mode, so we that we can
# test the output with waiting indefinitely. This is posix-specific, but there
# is probably a win32 equivalent
fcntl.fcntl(self._output.fileno(), fcntl.F_SETFL, os.O_NONBLOCK)
self.assertAppServerSays('^Ready', wait=10)
def assertAppServerSays(self, pattern, flags=re.MULTILINE, wait=5):
"""
Check that the appserver output contains the specified pattern. If the appserver
does not output the pattern within the given number of seconds, an assertion is
raised.
"""
if not self.waitForAppServer(pattern, flags, wait):
assert False, "Expected appserver to say '%s', but after waiting %d seconds it said: %s" % (pattern, wait, self._actualAppServerOutput)
def waitForAppServer(self, pattern, flags=re.MULTILINE, wait=5):
"""
Check that the appserver output contains the specified pattern.
Returns True or False depending on whether the pattern was seen.
"""
start = time.time()
data = ''
while 1:
data += self.getOutput()
if re.search(pattern, data, flags):
return True
time.sleep(1)
now = time.time()
if now - start > wait:
break
self._actualAppServerOutput = data
return False
def getOutput(self):
data = ''
try:
data = self._output.read()
except IOError, e:
pass
return data
def tearDown(self):
try:
pidfile = open(os.path.join(self.workDir(), 'appserverpid.txt'), 'r')
except:
pass
else:
pid = int(pidfile.read())
pidfile.close()
os.kill(pid, signal.SIGTERM)
self.assertAppServerSays('AppServer has been shutdown')
--- NEW FILE: FixPath.py ---
"""
FixPath.py
Enhance sys.path so that we're guaranteed to import the MiddleKit that
we reside in. This is particularly important for Webware developers
that might have more than one Webware source tree on their file system.
"""
# We're located at .../WebKit/Tests/FixPath.py.
import os, sys
if sys.path[0] not in ('', '.'):
sys.path.insert(0, '')
# now make the fix referenced in the doc string
if sys.path and sys.path[0]=='':
index = 1
else:
index = 0
sys.path.insert(index, os.path.abspath('../..'))
import WebKit
--- NEW FILE: README ---
This is a framework for testing WebKit end-to-end by using the built-in http
server. The module AppServerTest contains a TestCase base class which
starts/stops the appserver in a separate process, and allows the test case
to check whether certain output produced by the appserver (currently this has
not been tweaked/tested to run under Win32, but this should be straightforward).
Test cases will probably want to use a client-side web testing framework
(possibly webunit @ http://mechanicalcat.net/tech/webunit) for making requests and testing responses.
To run all tests:
$ python Test.py
To run specific test cases, pass one or more names of package/module names
on the command line which contain the test cases to be run.
$ python Test.py Basic.Test
testAppServerStarts (Basic.Test.TestBasicFunctionality) ... ok
----------------------------------------------------------------------
Ran 1 test in 3.036s
OK
--- NEW FILE: Test.py ---
#!/usr/bin/env python
import unittest
import FixPath
import sys
# list the tests explicitly, so that they can be order from most basic
# functionality to more complex.
suites = ['Basic.Test']
# To run specific test cases, pass one or more names of package/module names
# on the command line which contain the test cases to be run.
# If no arguments are given, all of the test cases are run.
if len(sys.argv) == 1:
testnames = suites
else:
testnames = sys.argv[1:]
tests = unittest.defaultTestLoader.loadTestsFromNames(testnames)
unittest.TextTestRunner(verbosity=2).run(tests)
--- NEW FILE: __init__.py ---

Update of /cvsroot/webware/Webware/WebKit/Tests/Basic/Cache
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32562/Basic/Cache
Added Files:
.cvsignore
Log Message:
Implemented a framework for testing WebKit end-to-end by using the
built-in http server. The module AppServerTest contains a TestCase base
class which starts/stops the appserver in a separate process, and allows
the test case to check whether certain output produced by the appserver.
(currently this has not been tweaked/tested to run on Win32, but this should
be straightforward).
Test cases will probably want to use a client-side web testing framework
(possibly webunit @ http://mechanicalcat.net/tech/webunit) for making
requests and testing responses.
--- NEW FILE: .cvsignore ---
*