Download Install Tutorial Docs FAQ Tools WikiLicense Team IRC Planet Involvement Shop Book

Ticket #661 (defect)

Opened 2 years ago

Last modified 2 years ago

Cannot create tool out of an object callable

Status: closed (fixed)

Reported by: guest Assigned to: rdelon
Priority: normal Milestone:
Component: CherryPy code Keywords:
Cc:

The folowing:

import cherrypy

class A (object):
    def __init__(self):
        pass
    def __call__(self):
        pass

a = A()
cherrypy.tools.a = cherrypy._cptools.HandlerTool(a)

fails with

Traceback (most recent call last):
  File "no-callable.py", line 10, in ?
    cherrypy.tools.a = cherrypy._cptools.HandlerTool(a)
  File "/home/npat/lib/python/cherrypy/_cptools.py", line 119, in __init__
    Tool.__init__(self, 'before_handler', callable, name)
  File "/home/npat/lib/python/cherrypy/_cptools.py", line 45, in __init__
    self._setargs()
  File "/home/npat/lib/python/cherrypy/_cptools.py", line 51, in _setargs
    for arg in inspect.getargspec(self.callable)[0]:
  File "/usr/lib/python2.3/inspect.py", line 663, in getargspec
    raise TypeError('arg is not a Python function')
TypeError: arg is not a Python function

Change History

02/19/07 14:04:20: Modified by fumanchu

  • status changed from new to closed.
  • resolution set to fixed.

Fixed in [1621].

Hosted by WebFaction

Log in as guest/cpguest to create tickets