[mod_python] object type. why it not works?

Jeff Hinrichs - DM&T jeffh at dundeemt.com
Sun Jun 24 01:11:46 EDT 2007


On 6/23/07, ziapannocchia at gmail.com <ziapannocchia at gmail.com> wrote:
> I have a selfmade apache server, and I'm writing  a little web
> application with mod python.
>
> Using this def:
>
> def testPython(contenuto):
>   test="test"
>   return type(test)
>
> I obtain this error:
>
> Mod_python error: "PythonHandler mod_python.publisher"
>
> Traceback (most recent call last):
>
>   File "/usr/lib64/python2.4/site-packages/mod_python/apache.py", line
> 299, in HandlerDispatch
>     result = object(req)
>
>   File "/usr/lib64/python2.4/site-packages/mod_python/publisher.py",
> line 213, in handler
>     published = publish_object(req, object)
>
>   File "/usr/lib64/python2.4/site-packages/mod_python/publisher.py",
> line 412, in publish_object
>     return publish_object(req,util.apply_fs_data(object, req.form, req=req))
>
>   File "/usr/lib64/python2.4/site-packages/mod_python/publisher.py",
> line 412, in publish_object
>     return publish_object(req,util.apply_fs_data(object, req.form, req=req))
>
>   File "/usr/lib64/python2.4/site-packages/mod_python/util.py", line
> 401, in apply_fs_data
>     fc = object.__init__.im_func.func_code
>
> AttributeError: 'wrapper_descriptor' object has no attribute 'im_func'
>
> Instead, on command line, the same istruction works well:
>
> cloc3 at s939 /home/cloc3 $ python
> Python 2.4.4 (#1, May 18 2007, 08:25:49)
> [GCC 4.1.2 (Gentoo 4.1.2)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> test="test"
> >>> type(test)
> <type 'str'>
>
>
> What may be wrong?

Publisher wants to return a string -- and you are attempting to return
an object, http://docs.python.org/lib/bltin-type-objects.html

try, return test  --or-- return str(type(test))

-jeff


More information about the Mod_python mailing list