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/09/01 10:54:53 UTC

svn commit: r265674 - /httpd/mod_python/trunk/lib/python/mod_python/util.py

Author: nlehuen
Date: Thu Sep  1 01:54:47 2005
New Revision: 265674

URL: http://svn.apache.org/viewcvs?rev=265674&view=rev
Log:
Graham's patch for MODPYTHON-73

Modified:
    httpd/mod_python/trunk/lib/python/mod_python/util.py

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?rev=265674&r1=265673&r2=265674&view=diff
==============================================================================
--- httpd/mod_python/trunk/lib/python/mod_python/util.py (original)
+++ httpd/mod_python/trunk/lib/python/mod_python/util.py Thu Sep  1 01:54:47 2005
@@ -371,20 +371,6 @@
    then call the object, return the result.
    """
 
-   # add form data to args
-   for field in fs.list:
-       if field.filename:
-           val = field
-       else:
-           val = field.value
-       args.setdefault(field.name, []).append(val)
-
-   # replace lists with single values
-   for arg in args:
-       if ((type(args[arg]) is ListType) and
-           (len(args[arg]) == 1)):
-           args[arg] = args[arg][0]
-
    # we need to weed out unexpected keyword arguments
    # and for that we need to get a list of them. There
    # are a few options for callable objects here:
@@ -409,8 +395,26 @@
        expected = []
    elif hasattr(object, '__call__'):
        # callable object
-       fc = object.__call__.im_func.func_code
-       expected = fc.co_varnames[1:fc.co_argcount]
+       if type(object.__call__) is MethodType:
+           fc = object.__call__.im_func.func_code
+           expected = fc.co_varnames[1:fc.co_argcount]
+       else:
+           # abuse of objects to create hierarchy
+           return apply_fs_data(object.__call__, fs, **args)
+
+   # add form data to args
+   for field in fs.list:
+       if field.filename:
+           val = field
+       else:
+           val = field.value
+       args.setdefault(field.name, []).append(val)
+
+   # replace lists with single values
+   for arg in args:
+       if ((type(args[arg]) is ListType) and
+           (len(args[arg]) == 1)):
+           args[arg] = args[arg][0]
 
    # remove unexpected args unless co_flags & 0x08,
    # meaning function accepts **kw syntax