Python Forum
missing 1 required positional argument error
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
missing 1 required positional argument error
#1
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?
Reply
#2
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.
Reply
#3
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?
Reply
#4
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?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Strange argument count error rowan_bradley 3 659 Aug-06-2023, 10:58 AM
Last Post: rowan_bradley
  Error TypeError: output_type_handler() takes 2 positional arguments but 6 were given paulo79 1 1,858 Oct-17-2022, 06:29 PM
Last Post: paulo79
  Error: _vhstack_dispatcher() takes 1 positional argument but 9 were given alexfrol86 3 5,718 May-09-2022, 12:49 PM
Last Post: deanhystad
  What is positional argument self? Frankduc 22 5,492 Mar-06-2022, 01:18 AM
Last Post: Frankduc
  TypeError: missing a required argument: 'y' gible 0 2,845 Dec-15-2021, 02:21 AM
Last Post: gible
  positional argument: 'self' mcmxl22 8 3,194 Dec-13-2021, 10:11 PM
Last Post: deanhystad
  error : "Microsoft Visual C++ 14.0 is required. " Even its installed Barak 4 3,923 Oct-13-2021, 10:39 PM
Last Post: Underscore
  Error about missing directory Led_Zeppelin 3 2,649 Aug-31-2021, 01:37 PM
Last Post: snippsat
  TypeError: missing 3 required positional arguments: wardancer84 9 10,663 Aug-19-2021, 04:27 PM
Last Post: deanhystad
  TypeError: run_oracle_job() missing 1 required positional argument: 'connection_strin python_student 1 1,937 Aug-06-2021, 08:05 PM
Last Post: SheeppOSU

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020