Python Forum

Full Version: missing 1 required positional argument error
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm receiving the following error:

Error:
Traceback (most recent call last): File "/usr/lib64/python3.6/site-packages/bottle.py", line 862, in _handle return route.call(**args) File "/usr/lib64/python3.6/site-packages/bottle.py", line 1740, in wrapper rv = callback(*a, **ka) File "/usr/lib64/python3.6/site-packages/bottle.py", line 2690, in wrapper return func(*a, **ka) TypeError: listall() missing 1 required positional argument: 'pymydb'
and this is my route:
@app.route( '/' )
@auth_basic(counters.is_authenticated_user)
def listall( pymydb ):
The way i understand this error is that i'am trying to call 'listall()' without giving it an argument while in its definition i do have 'pymydb' as a parameter.

BUT from inside my script i do NOT call listall at all, so how can it miss an argument?
Where is pymydb supposed to come from?
I'm not super-familiar with bottle, but in most frameworks which use route decorators, arguments are provided by the decorator when using an appropriately-formatted route path.
pymydb comes from these lines in the top of myscript.

plugin = bottle_pymysql.Plugin( dbuser='nikos', dbpass='trustno1bm3$', dbname='clientele', dictrows=False )
app.install(plugin)
That is in the top of my script after the imports and NOT within the view function in case it matters.

i have 2 scripts with '/' routes and they both use the parameter 'pymydb'

@app.route( '/' ) 
@app.route( '/<page>' ) 
def index( pymydb, page='index.html' ):
this one works without an error, so it seems it can find pymydb

while in my other script

@app.route( '/' )
@auth_basic(counters.is_authenticated_user)
def listall( pymydb ):
is giving the error i posted.

i just noticed that if i remove the:

@auth_basic(counters.is_authenticated_user)
then the script work without giving me an error!

But why is that?
Hello, can someone help me with this please?

This route works as expected

@app.route( '/download', method=['GET', 'POST'] )
def download( pymydb ):
while the following, in which iam trying with http auth

@app.route( '/download', method=['GET', 'POST'] )
@auth_basic(counters.is_authenticated_user)
def download( pymydb ):
fails by giving me the error

Error:
TypeError("download() missing 1 required positional argument: 'pymydb'",) Traceback: Traceback (most recent call last): File "/usr/lib64/python3.6/site-packages/bottle.py", line 862, in _handle return route.call(**args) File "/usr/lib64/python3.6/site-packages/bottle.py", line 1740, in wrapper rv = callback(*a, **ka) File "/usr/lib64/python3.6/site-packages/bottle.py", line 2690, in wrapper return func(*a, **ka) TypeError: download() missing 1 required positional argument: 'pymydb'
Why is that? How will i be able to enable http auth in this route?