[Zope-CVS] CVS: Packages/FunctionalTests/FunctionalTests - Request.py:1.4
Tres Seaver
tseaver@zope.com
Fri, 30 May 2003 21:18:15 -0400
Update of /cvs-repository/Packages/FunctionalTests/FunctionalTests
In directory cvs.zope.org:/tmp/cvs-serv10474/FunctionalTests
Modified Files:
Request.py
Log Message:
- FunctionalTests/Request.py:
o Factor out the "pluggable function" bits from ZEORequest, to enable
reuse for things like payload verification.
- doc/CHANGES.txt:
o Summarize changes since 0.4 release.
=== Packages/FunctionalTests/FunctionalTests/Request.py 1.3 => 1.4 ===
--- Packages/FunctionalTests/FunctionalTests/Request.py:1.3 Sat May 24 18:46:15 2003
+++ Packages/FunctionalTests/FunctionalTests/Request.py Fri May 30 21:17:44 2003
@@ -17,6 +17,41 @@
pass
+class PluginFunction:
+
+ """ Represent a function loadable from a separate file.
+
+ o This file must be available at runtime in the test environment.
+ """
+ def __init__( self, filename, function ):
+
+ self._filename = filename
+ self._function = function
+
+ #
+ # Accessors
+ #
+ def getFileName( self ):
+
+ """ Return the name of the file containing our function.
+ """
+ return self._filename
+
+ def getFunctionName( self ):
+
+ """ Return the name of our function.
+ """
+ return self._function
+
+ def getFunction( self ):
+
+ """ Return a function object.
+ """
+ g = {} # faux globals
+ execfile( self.getFileName(), g )
+ return g[ self.getFunctionName() ]
+
+
class _RequestBase: # XXX scarecrow me?
""" Common base class for requests.
@@ -53,6 +88,8 @@
def getOption( self, key, default=None ):
""" Return the value for the given option.
+
+ o Return 'default' if no such option exists.
"""
return self._options.get( key, default )
@@ -76,6 +113,7 @@
"""
if clear:
self._options.clear()
+
for option in cp.options( section ):
self._options[ option ] = cp.get( section, option )
@@ -440,31 +478,7 @@
_RequestBase.__init__( self, name )
- self._filename = filename
- self._function = function
-
- #
- # Accessors
- #
- def getFileName( self ):
-
- """ Return the name of the file containing our function.
- """
- return self._filename
-
- def getFunctionName( self ):
-
- """ Return the name of our function.
- """
- return self._function
-
- def getFunction( self ):
-
- """ Return a function object.
- """
- g = {} # faux globals
- execfile( self.getFileName(), g )
- return g[ self.getFunctionName() ]
+ self._plugin = PluginFunction( filename, function )
#
# Request invocation
@@ -478,7 +492,7 @@
app._p_jar.sync() # Ensure that we catch up to any other commits.
defaults = result.getDefaults()
- func = self.getFunction()
+ func = self._plugin.getFunction()
if result.timeRequests():
invocation.beginRequest()