Reputation: 970
I have a web.py application with following server code.
import web
import mod1
urls = (
'/(\w*)/(c|r|u|d)/(.*)', '\\1.\\2',
)
if __name__ == "__main__":
app = web.application(urls, globals())
app.run()
mod1.py
contains
class c:
def POST(self):
return "C"
class d:
def DELETE(self):
return "d"
class u:
def POST(self):
return "u"
class r:
def GET(self, _id):
return "v={0}".format(_id)
Now requesting http://.../mod1/r/3
returns GET() takes exactly 2 arguments (4 given)
.
What is the problem here?
Upvotes: 0
Views: 1971
Reputation: 1121166
Your URL configuration has 3 parameters ((\w*)
, (c|r|u|d)
and (.*)
). Plus the self
argument for methods, that makes 4 arguments.
Adjust your GET
method to accept all parameters:
def GET(self, param1, operation, id_):
These match each of the regular expression capturing groups; I guessed at the parameter names for each, you can adjust as needed.
Upvotes: 5