This is the classic noob problem. Defining a class and getting
arguments mis-match when first instantiating an instance of the
class. But, I can't see where the problem is.
Traceback (most recent call last):
File "/var/web2py/gluon/restricted.py", line 204, in restricted
exec ccode in environment
File "/var/web2py/applications/pyjokes/controllers/default.py", line
384, in <module>
File "/var/web2py/gluon/globals.py", line 172, in <lambda>
self._caller = lambda f: f()
File "/var/web2py/gluon/tools.py", line 2533, in f
return action(*a, **b)
File "/var/web2py/applications/pyjokes/controllers/default.py", line
376, in test
b = builder.Build_jokes(jodb)
TypeError: __init__() takes exactly 1 argument (2 given)
What follows is the definition of the class in a module. __init__
takes self and one additional argument:
class Build_jokes:
"""
docstring...
"""
def __init__(self, dbhandle):
self.jodb = dbhandle
self.sortrequest = 'category'
self.sort_order = {'author': self.jodb.auth_user.last_name,
'category': self.jodb.category.name}
self.catquery = self.jodb.category.id>0
self.authorquery = self.jodb.joke.created_by>0
def anothermethod():
... code ...
Here is a controller/action (it's just a test for now--and not
working!) where I try to access the class:
def test():
import builder
b = builder.Build_jokes(jodb) #Note: this is line 376
referenced in traceback
b.controls()
b.displayjokes()
form = DIV(b.sortfilter, b.joketable)
Yes, the module and controller are in the same application. I've been
looking at it for hours--I can't see where the argument mismatch is.