Author: chrisz
Date: Fri Apr 20 03:00:54 2007
New Revision: 6485
Modified:
Webware/trunk/CGIWrapper/CGIWrapper.py
Webware/trunk/DocSupport/PySummary.py
Webware/trunk/MiddleKit/Run/MSSQLObjectStore.py
Webware/trunk/MiddleKit/Run/MiddleObject.py
Webware/trunk/MiddleKit/Run/SQLObjectStore.py
Webware/trunk/MiscUtils/PickleRPC.py
Webware/trunk/MiscUtils/pydoc.py
Webware/trunk/WebKit/Adapters/ModPythonAdapter.py
Webware/trunk/WebKit/HTTPContent.py
Webware/trunk/WebKit/HTTPRequest.py
Webware/trunk/WebUtils/HTMLForException.py
Log:
Replaced apply function by using extended call syntax (which is available since Python 2.0).
Modified: Webware/trunk/CGIWrapper/CGIWrapper.py
==============================================================================
--- Webware/trunk/CGIWrapper/CGIWrapper.py (original)
+++ Webware/trunk/CGIWrapper/CGIWrapper.py Fri Apr 20 03:00:54 2007
@@ -623,7 +623,7 @@
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 = traceback.format_exception(*sys.exc_info())
output = ''.join(output)
output = output.replace('&', '&').replace('<', '<').replace('>', '>')
stdout.write('''Content-type: text/html
Modified: Webware/trunk/DocSupport/PySummary.py
==============================================================================
--- Webware/trunk/DocSupport/PySummary.py (original)
+++ Webware/trunk/DocSupport/PySummary.py Fri Apr 20 03:00:54 2007
@@ -100,7 +100,7 @@
res.append(settings[type][0])
if span:
res.append('<span class="line_%s">' % type)
- res.append(apply(getattr(line, format))) # e.g., line.format()
+ res.append(getattr(line, format)()) # e.g., line.format()
if span:
res.append('</span>')
res.append('\n')
Modified: Webware/trunk/MiddleKit/Run/MSSQLObjectStore.py
==============================================================================
--- Webware/trunk/MiddleKit/Run/MSSQLObjectStore.py (original)
+++ Webware/trunk/MiddleKit/Run/MSSQLObjectStore.py Fri Apr 20 03:00:54 2007
@@ -48,7 +48,7 @@
if you want it off, do not send any arg for clear_auto_commit or set it to 1
# self._db = ODBC.Windows.Connect(dsn='myDSN',clear_auto_commit=0)
"""
- return apply(ODBC.Windows.Connect, (), self._dbArgs)
+ return ODBC.Windows.Connect(**self._dbArgs)
def retrieveLastInsertId(self, conn, cur):
conn, cur = self.executeSQL('select @@IDENTITY', conn)
Modified: Webware/trunk/MiddleKit/Run/MiddleObject.py
==============================================================================
--- Webware/trunk/MiddleKit/Run/MiddleObject.py (original)
+++ Webware/trunk/MiddleKit/Run/MiddleObject.py Fri Apr 20 03:00:54 2007
@@ -516,12 +516,12 @@
if copymode == 'deep' and isinstance(attr, ObjRefAttr):
# clone the value of an attribute from the source object,
# and set it in the attribute of the dest object
- value = apply(getattr(source, attr.pyGetName()), ())
+ value = getattr(source, attr.pyGetName())()
if value:
clonedvalue = value.clone(memo, depthAttr)
else:
clonedvalue = None
- retvalue = apply(getattr(dest, attr.pySetName()), (clonedvalue,))
+ retvalue = getattr(dest, attr.pySetName())(clonedvalue)
elif copymode == 'none':
# Shouldn't set to attribute to None explicitly since attribute may have
# isRequired=1
@@ -531,8 +531,8 @@
# copy the value of an attribute from the source object
# to the dest object
# print 'copying value of ' + attr.name()
- value = apply(getattr(source, attr.pyGetName()), ())
- retvalue = apply(getattr(dest, attr.pySetName()), (value,))
+ value = getattr(source, attr.pyGetName())()
+ retvalue = getattr(dest, attr.pySetName())(value)
if memo is None:
# print 'Initializing memo'
@@ -551,7 +551,7 @@
# iterate over our persistent attributes
for attr in self.klass().allDataAttrs():
if isinstance(attr, ListAttr):
- valuelist = apply(getattr(self, attr.pyGetName()), ())
+ valuelist = getattr(self, attr.pyGetName())()
setmethodname = "addTo" + attr.name()[0].upper() + attr.name()[1:]
setmethod = getattr(copy, setmethodname)
@@ -570,10 +570,10 @@
# set the value's back ref to point to self
setrefmethod = getattr(valcopy, setrefname)
backrefattr = valcopy.klass().lookupAttr(backrefname)
- apply(setrefmethod, (None,))
+ setrefmethod(None)
# add the value to the list
- retval = apply(setmethod, (valcopy,))
+ retval = setmethod(valcopy)
elif attr['Copy'] == 'none':
# leave the list empty
pass
Modified: Webware/trunk/MiddleKit/Run/SQLObjectStore.py
==============================================================================
--- Webware/trunk/MiddleKit/Run/SQLObjectStore.py (original)
+++ Webware/trunk/MiddleKit/Run/SQLObjectStore.py Fri Apr 20 03:00:54 2007
@@ -631,7 +631,7 @@
# will be None. This means that dangling references will _not_ be remembered
# across dump/generate/create/insert procedures.
method = getattr(obj, attr.pyGetName())
- value = apply(method, ())
+ value = method()
if value is None:
fields.append('')
elif isinstance(value, MiddleObject):
Modified: Webware/trunk/MiscUtils/PickleRPC.py
==============================================================================
--- Webware/trunk/MiscUtils/PickleRPC.py (original)
+++ Webware/trunk/MiscUtils/PickleRPC.py Fri Apr 20 03:00:54 2007
@@ -365,6 +365,8 @@
def make_connection(self, host):
# create a HTTP connection object from a host descriptor
+ # @@ This uses the old httplib interface of Python 1.5.2
+ # @@ We should switch to the newer httplib interface of Python 2.0
import httplib
return httplib.HTTP(host)
@@ -409,6 +411,7 @@
def make_connection(self, host):
# create a HTTPS connection object from a host descriptor
# host may be a string, or a (host, x509-dict) tuple
+ # @@ see remark in Transport.make_connection
import httplib
if isinstance(host, types.TupleType):
host, x509 = host
@@ -420,7 +423,7 @@
raise NotImplementedError, \
"your version of httplib doesn't support HTTPS"
else:
- return apply(HTTPS, (host, None), x509)
+ return HTTPS(host, **x509)
def send_host(self, connection, host):
if isinstance(host, types.TupleType):
Modified: Webware/trunk/MiscUtils/pydoc.py
==============================================================================
--- Webware/trunk/MiscUtils/pydoc.py (original)
+++ Webware/trunk/MiscUtils/pydoc.py Fri Apr 20 03:00:54 2007
@@ -261,12 +261,12 @@
"""Generate documentation for an object."""
args = (object, name) + args
if inspect.ismodule(object):
- return apply(self.docmodule, args)
+ return self.docmodule(*args)
if inspect.isclass(object):
- return apply(self.docclass, args)
+ return self.docclass(*args)
if inspect.isroutine(object):
- return apply(self.docroutine, args)
- return apply(self.docother, args)
+ return self.docroutine(*args)
+ return self.docother(*args)
def fail(self, object, name=None, *args):
"""Raise an exception for unimplemented types."""
@@ -375,7 +375,7 @@
def bigsection(self, title, *args):
"""Format a section with a big heading."""
title = '<big><strong>%s</strong></big>' % title
- return apply(self.section, (title,) + args)
+ return self.section(title, *args)
def preformat(self, text):
"""Format literal preformatted text."""
Modified: Webware/trunk/WebKit/Adapters/ModPythonAdapter.py
==============================================================================
--- Webware/trunk/WebKit/Adapters/ModPythonAdapter.py (original)
+++ Webware/trunk/WebKit/Adapters/ModPythonAdapter.py Fri Apr 20 03:00:54 2007
@@ -194,7 +194,7 @@
apache.log_error('Python exception:\n')
traceback.print_exc(file=sys.stderr)
- output = apply(traceback.format_exception, sys.exc_info())
+ output = traceback.format_exception(*sys.exc_info())
output = ''.join(output)
output = output.replace('&', '&'
).replace('<', '<').replace('>', '>')
Modified: Webware/trunk/WebKit/HTTPContent.py
==============================================================================
--- Webware/trunk/WebKit/HTTPContent.py (original)
+++ Webware/trunk/WebKit/HTTPContent.py Fri Apr 20 03:00:54 2007
@@ -310,7 +310,7 @@
to pass in the transaction as the first argument.
"""
- return apply(self.application().callMethodOfServlet, (self.transaction(), URL, method) + args, kwargs)
+ return self.application().callMethodOfServlet(self.transaction(), URL, method, *args, **kwargs)
def endResponse(self):
"""End response.
Modified: Webware/trunk/WebKit/HTTPRequest.py
==============================================================================
--- Webware/trunk/WebKit/HTTPRequest.py (original)
+++ Webware/trunk/WebKit/HTTPRequest.py Fri Apr 20 03:00:54 2007
@@ -796,7 +796,7 @@
# Information methods
for method in _infoMethods:
try:
- info.append((method.__name__, apply(method, (self,))))
+ info.append((method.__name__, method(self)))
except:
info.append((method.__name__, None))
Modified: Webware/trunk/WebUtils/HTMLForException.py
==============================================================================
--- Webware/trunk/WebUtils/HTMLForException.py (original)
+++ Webware/trunk/WebUtils/HTMLForException.py Fri Apr 20 03:00:54 2007
@@ -40,7 +40,7 @@
res = ['<table style="%s" width=100%%'
' cellpadding="2" cellspacing="2">\n' % opt['table'],
'<tr><td><pre style="%s">\n' % opt['default']]
- out = apply(traceback.format_exception, excInfo)
+ out = traceback.format_exception(*excInfo)
for line in out:
match = fileRE.search(line)
if match:
|