You are viewing a plain text version of this content. The canonical link for it is here.
Posted to mod_python-commits@quetz.apache.org by nl...@apache.org on 2005/01/29 19:26:01 UTC
svn commit: r149056 - in httpd/mod_python/trunk: dist lib/python/mod_python test test/htdocs
Author: nlehuen
Date: Sat Jan 29 10:26:00 2005
New Revision: 149056
URL: http://svn.apache.org/viewcvs?view=rev&rev=149056
Log:
Cosmetic changes to the code in order to unify coding style.
Modified:
httpd/mod_python/trunk/dist/setup.py.in
httpd/mod_python/trunk/dist/win32_postinstall.py
httpd/mod_python/trunk/lib/python/mod_python/publisher.py
httpd/mod_python/trunk/lib/python/mod_python/util.py
httpd/mod_python/trunk/test/htdocs/tests.py
httpd/mod_python/trunk/test/test.py
Modified: httpd/mod_python/trunk/dist/setup.py.in
Url: http://svn.apache.org/viewcvs/httpd/mod_python/trunk/dist/setup.py.in?view=diff&rev=149056&p1=httpd/mod_python/trunk/dist/setup.py.in&r1=149055&p2=httpd/mod_python/trunk/dist/setup.py.in&r2=149056
==============================================================================
--- httpd/mod_python/trunk/dist/setup.py.in (original)
+++ httpd/mod_python/trunk/dist/setup.py.in Sat Jan 29 10:26:00 2005
@@ -38,8 +38,8 @@
config_status_file = os.path.join(getmp_rootdir(), 'config.status')
if not os.path.exists(config_status_file):
raise AssertionError("config.status not found in expected location (%s)" % config_status_file)
- header = open(config_status_file,'r')
- r = re.compile('s,@%s@,(?P<OPTION_STRING>[^,]+),' % (option_name))
+ header = open(config_status_file, 'r')
+ r = re.compile('s, @%s@, (?P<OPTION_STRING>[^,]+), ' % (option_name))
for line in header.readlines():
m = r.search(line)
if m is not None:
@@ -52,7 +52,7 @@
mpversion_file = os.path.join(getmp_includedir(), 'mpversion.h')
if not os.path.exists(mpversion_file):
raise AssertionError("mpversion.h not found in expected location (%s)" % mpversion_file)
- header = open(mpversion_file,'r')
+ header = open(mpversion_file, 'r')
r = re.compile('#define\s+MPV_STRING\s+"(?P<MPV_STRING>[^"]+)"')
for line in header.readlines():
m = r.search(line)
@@ -104,7 +104,7 @@
)
if winbuild:
- self.define_macros.extend([('WIN32',None),('NDEBUG',None),('_WINDOWS',None)])
+ self.define_macros.extend([('WIN32', None), ('NDEBUG', None), ('_WINDOWS', None)])
PSPModule = PSPExtension(getmp_srcdir(), [getmp_includedir()])
@@ -123,11 +123,11 @@
Extension.__init__(self, "mod_python_so",
sources = [os.path.join(source_dir, source_file) for source_file in modpy_src_files],
include_dirs=include_dirs,
- libraries = ['libhttpd','libapr','libaprutil','ws2_32'],
+ libraries = ['libhttpd', 'libapr', 'libaprutil', 'ws2_32'],
library_dirs=library_dirs
)
if winbuild:
- self.define_macros.extend([('WIN32',None),('NDEBUG',None),('_WINDOWS',None)])
+ self.define_macros.extend([('WIN32', None),('NDEBUG', None),('_WINDOWS', None)])
self.sources.append(os.path.join(source_dir, "Version.rc"))
else:
# TODO: fix this to autodetect if required...
Modified: httpd/mod_python/trunk/dist/win32_postinstall.py
Url: http://svn.apache.org/viewcvs/httpd/mod_python/trunk/dist/win32_postinstall.py?view=diff&rev=149056&p1=httpd/mod_python/trunk/dist/win32_postinstall.py&r1=149055&p2=httpd/mod_python/trunk/dist/win32_postinstall.py&r2=149056
==============================================================================
--- httpd/mod_python/trunk/dist/win32_postinstall.py (original)
+++ httpd/mod_python/trunk/dist/win32_postinstall.py Sat Jan 29 10:26:00 2005
@@ -111,9 +111,9 @@
# put mod_python.so there
mod_python_so_path = os.path.join(apachedir, "modules", "mod_python.so")
- mod_python_uninstall_log = os.path.join(os.path.dirname(__file__),'mod_python_uninstall.log')
+ mod_python_uninstall_log = os.path.join(os.path.dirname(__file__), 'mod_python_uninstall.log')
shutil.copy2(mp, mod_python_so_path)
- f = file(mod_python_uninstall_log,'wb')
+ f = file(mod_python_uninstall_log, 'wb')
f.write(mod_python_so_path)
f.close()
os.remove(mp)
@@ -154,8 +154,8 @@
""" % (mp, os.path.join(apachedir, "conf", "httpd.conf"))
elif len(sys.argv) > 1 and sys.argv[1] == "-remove":
- mod_python_uninstall_log = os.path.join(os.path.dirname(__file__),'mod_python_uninstall.log')
- f = file(mod_python_uninstall_log,'rb')
+ mod_python_uninstall_log = os.path.join(os.path.dirname(__file__), 'mod_python_uninstall.log')
+ f = file(mod_python_uninstall_log, 'rb')
mod_python_so_path = f.read()
f.close()
os.remove(mod_python_so_path)
Modified: httpd/mod_python/trunk/lib/python/mod_python/publisher.py
Url: http://svn.apache.org/viewcvs/httpd/mod_python/trunk/lib/python/mod_python/publisher.py?view=diff&rev=149056&p1=httpd/mod_python/trunk/lib/python/mod_python/publisher.py&r1=149055&p2=httpd/mod_python/trunk/lib/python/mod_python/publisher.py&r2=149056
==============================================================================
--- httpd/mod_python/trunk/lib/python/mod_python/publisher.py (original)
+++ httpd/mod_python/trunk/lib/python/mod_python/publisher.py Sat Jan 29 10:26:00 2005
@@ -66,7 +66,7 @@
if func_path[0] == '_' or func_path.count("._"):
req.log_error('Cannot access %s because '
'it contains at least an underscore'
- %func_path,apache.APLOG_WARNING)
+ % func_path, apache.APLOG_WARNING)
raise apache.SERVER_RETURN, apache.HTTP_FORBIDDEN
## import the script
@@ -228,7 +228,7 @@
if not user:
# note that Opera supposedly doesn't like spaces around "=" below
- s = 'Basic realm="%s"' % realm
+ s = 'Basic realm="%s"' % realm
req.err_headers_out["WWW-Authenticate"] = s
raise apache.SERVER_RETURN, apache.HTTP_UNAUTHORIZED
@@ -265,17 +265,17 @@
# The first item in the tuple is a boolean telling if the object can be traversed (default is True)
# The second item in the tuple is a boolen telling if the object can be published (default is True)
tp_rules = {
- FunctionType : (False,True),
- MethodType : (False,True),
- BuiltinFunctionType : (False,True),
- ModuleType : (False,False),
- ClassType : (False,False),
+ FunctionType : (False, True),
+ MethodType : (False, True),
+ BuiltinFunctionType : (False, True),
+ ModuleType : (False, False),
+ ClassType : (False, False),
# XXX Generators should be publishable, see
# http://issues.apache.org/jira/browse/MODPYTHON-15
# Until they are, it is not interesting to publish them
- GeneratorType : (False,False),
+ GeneratorType : (False, False),
}
-default_tp_rule = (True,True)
+default_tp_rule = (True, True)
def resolve_object(req, obj, object_str, realm=None, user=None, passwd=None):
"""
@@ -283,28 +283,25 @@
(period) to find the last one we're looking for.
"""
parts = object_str.split('.')
- last_part = len(parts)-1
for i, obj_str in enumerate(parts):
+
# path components starting with an underscore are forbidden
if obj_str[0]=='_':
req.log_error('Cannot traverse %s in %s because '
'it starts with an underscore'
- %(obj_str,req.unparsed_uri),apache.APLOG_WARNING)
+ % (obj_str, req.unparsed_uri), apache.APLOG_WARNING)
raise apache.SERVER_RETURN, apache.HTTP_FORBIDDEN
# if we're not in the first object (which is the module)
if i>0:
- # we must be in an instance, nothing else
- # we have to check for old-style instances AND
- # new-style instances.
- # XXX testing for new-style class instance is tricky
- # see http://groups.google.fr/groups?th=7bab336f2b4f7e03&seekm=107l13c5tti8876%40news.supernews.com
- rule = tp_rules.get(type(obj),default_tp_rule)
+
+ # we're going to check whether be can traverse this type or not
+ rule = tp_rules.get(type(obj), default_tp_rule)
if not rule[0]:
req.log_error('Cannot traverse %s in %s because '
'%s is not a traversable object'
- %(obj_str,req.unparsed_uri,obj),apache.APLOG_WARNING)
+ % (obj_str, req.unparsed_uri, obj), apache.APLOG_WARNING)
raise apache.SERVER_RETURN, apache.HTTP_FORBIDDEN
# we know it's OK to call getattr
@@ -312,16 +309,18 @@
# of property objects (or attribute with __get__ special methods)...
obj = getattr(obj, obj_str)
- realm, user, passwd = process_auth(req, obj, realm,
- user, passwd)
+ # we process the authentication for the object
+ realm, user, passwd = process_auth(req, obj, realm, user, passwd)
- rule = tp_rules.get(type(obj),default_tp_rule)
- # XXX the isinstance(obj,type) test is required until
+ # we're going to check if the final object is publishable
+ rule = tp_rules.get(type(obj), default_tp_rule)
+ # XXX the isinstance(obj, type) test is required until
# we allow the publication of class objects.
- if (not rule[1]) or isinstance(obj,type):
+ if (not rule[1]) or isinstance(obj, type):
+
req.log_error('Cannot publish %s in %s because '
'%s is not publishable'
- %(obj_str,req.unparsed_uri,obj),apache.APLOG_WARNING)
+ % (obj_str, req.unparsed_uri, obj), apache.APLOG_WARNING)
raise apache.SERVER_RETURN, apache.HTTP_FORBIDDEN
return obj
Modified: httpd/mod_python/trunk/lib/python/mod_python/util.py
Url: http://svn.apache.org/viewcvs/httpd/mod_python/trunk/lib/python/mod_python/util.py?view=diff&rev=149056&p1=httpd/mod_python/trunk/lib/python/mod_python/util.py&r1=149055&p2=httpd/mod_python/trunk/lib/python/mod_python/util.py&r2=149056
==============================================================================
--- httpd/mod_python/trunk/lib/python/mod_python/util.py (original)
+++ httpd/mod_python/trunk/lib/python/mod_python/util.py Sat Jan 29 10:26:00 2005
@@ -354,7 +354,7 @@
# builtin
fc = None
expected = []
- elif hasattr(object,'__call__'):
+ elif hasattr(object, '__call__'):
# callable object
fc = object.__call__.im_func.func_code
expected = fc.co_varnames[1:fc.co_argcount]
Modified: httpd/mod_python/trunk/test/htdocs/tests.py
Url: http://svn.apache.org/viewcvs/httpd/mod_python/trunk/test/htdocs/tests.py?view=diff&rev=149056&p1=httpd/mod_python/trunk/test/htdocs/tests.py&r1=149055&p2=httpd/mod_python/trunk/test/htdocs/tests.py&r2=149056
==============================================================================
--- httpd/mod_python/trunk/test/htdocs/tests.py (original)
+++ httpd/mod_python/trunk/test/htdocs/tests.py Sat Jan 29 10:26:00 2005
@@ -829,25 +829,25 @@
return apache.OK
def index(req):
- return "test ok, interpreter=%s"%req.interpreter
+ return "test ok, interpreter=%s" % req.interpreter
def test_publisher(req):
- return "test ok, interpreter=%s"%req.interpreter
+ return "test ok, interpreter=%s" % req.interpreter
class OldStyleClassTest:
- def __call__(self,req):
+ def __call__(self, req):
return "test callable old-style instance ok"
- def traverse(self,req):
+ def traverse(self, req):
return "test traversable old-style instance ok"
old_instance = OldStyleClassTest()
-test_dict = {1:1,2:2,3:3}
+test_dict = {1:1, 2:2, 3:3}
test_dict_keys = test_dict.keys
class InstanceTest(object):
- def __call__(self,req):
+ def __call__(self, req):
return "test callable instance ok"
- def traverse(self,req):
+ def traverse(self, req):
return "test traversable instance ok"
instance = InstanceTest()
Modified: httpd/mod_python/trunk/test/test.py
Url: http://svn.apache.org/viewcvs/httpd/mod_python/trunk/test/test.py?view=diff&rev=149056&p1=httpd/mod_python/trunk/test/test.py&r1=149055&p2=httpd/mod_python/trunk/test/test.py&r2=149056
==============================================================================
--- httpd/mod_python/trunk/test/test.py (original)
+++ httpd/mod_python/trunk/test/test.py Sat Jan 29 10:26:00 2005
@@ -732,17 +732,17 @@
print "\n * Testing interpreter per directive"
- interpreter_name = DOCUMENT_ROOT.replace('\\','/')+'/'
+ interpreter_name = DOCUMENT_ROOT.replace('\\', '/')+'/'
rsp = self.vhost_get("test_interpreter_per_directive")
if (rsp != interpreter_name):
self.fail(`rsp`)
- rsp = self.vhost_get("test_interpreter_per_directive",'/subdir/foo.py')
+ rsp = self.vhost_get("test_interpreter_per_directive", '/subdir/foo.py')
if (rsp != interpreter_name):
self.fail(`rsp`)
- rsp = self.vhost_get("test_interpreter_per_directive",'/subdir/')
+ rsp = self.vhost_get("test_interpreter_per_directive", '/subdir/')
if (rsp != interpreter_name):
self.fail(`rsp`)
@@ -764,17 +764,17 @@
print "\n * Testing interpreter per directory"
- interpreter_name = DOCUMENT_ROOT.replace('\\','/')+'/'
+ interpreter_name = DOCUMENT_ROOT.replace('\\', '/')+'/'
rsp = self.vhost_get("test_interpreter_per_directory")
if (rsp != interpreter_name):
self.fail(`rsp`)
- rsp = self.vhost_get("test_interpreter_per_directory",'/subdir/foo.py')
+ rsp = self.vhost_get("test_interpreter_per_directory", '/subdir/foo.py')
if (rsp != interpreter_name+'subdir/'):
self.fail(`rsp`)
- rsp = self.vhost_get("test_interpreter_per_directory",'/subdir/')
+ rsp = self.vhost_get("test_interpreter_per_directory", '/subdir/')
if (rsp != interpreter_name+'subdir/'):
self.fail(`rsp`)
@@ -793,7 +793,7 @@
print "\n * Testing util_fieldstorage()"
- params = urllib.urlencode([('spam',1),('spam',2),('eggs',3),('bacon',4)])
+ params = urllib.urlencode([('spam', 1), ('spam', 2), ('eggs', 3), ('bacon', 4)])
headers = {"Host": "test_util_fieldstorage",
"Content-type": "application/x-www-form-urlencoded",
"Accept": "text/plain"}
@@ -1162,35 +1162,35 @@
status, response = get_status("/tests.py/_SECRET_PASSWORD")
if status != 403:
- self.fail('Vulnerability : underscore prefixed attribute (%i)\n%s'%(status,response))
+ self.fail('Vulnerability : underscore prefixed attribute (%i)\n%s' % (status, response))
status, response = get_status("/tests.py/__ANSWER")
if status != 403:
- self.fail('Vulnerability : underscore prefixed attribute (%i)\n%s'%(status,response))
+ self.fail('Vulnerability : underscore prefixed attribute (%i)\n%s' % (status, response))
status, response = get_status("/tests.py/re")
if status != 403:
- self.fail('Vulnerability : module published (%i)\n%s'%(status,response))
+ self.fail('Vulnerability : module published (%i)\n%s' % (status, response))
status, response = get_status("/tests.py/OldStyleClassTest")
if status != 403:
- self.fail('Vulnerability : old style class published (%i)\n%s'%(status,response))
+ self.fail('Vulnerability : old style class published (%i)\n%s' % (status, response))
status, response = get_status("/tests.py/InstanceTest")
if status != 403:
- self.fail('Vulnerability : new style class published (%i)\n%s'%(status,response))
+ self.fail('Vulnerability : new style class published (%i)\n%s' % (status, response))
status, response = get_status("/tests.py/index/func_code")
if status != 403:
- self.fail('Vulnerability : function traversal (%i)\n%s'%(status,response))
+ self.fail('Vulnerability : function traversal (%i)\n%s' % (status, response))
status, response = get_status("/tests.py/old_instance/traverse/func_code")
if status != 403:
- self.fail('Vulnerability : old-style method traversal (%i)\n%s'%(status,response))
+ self.fail('Vulnerability : old-style method traversal (%i)\n%s' % (status, response))
status, response = get_status("/tests.py/instance/traverse/func_code")
if status != 403:
- self.fail('Vulnerability : new-style method traversal (%i)\n%s'%(status,response))
+ self.fail('Vulnerability : new-style method traversal (%i)\n%s' % (status, response))
def test_publisher_old_style_instance_conf(self):
c = VirtualHost("*",