'NoneType' Does Not Support Indexing

hi @cantony2 - like @jshaffstall points out - some debugging print statements would really help here.

The return value from

return app_tables.products.get(id_name=medicine_name)

is returning None - because no Row matches your query.
To debug you might also raise an error when you want your code to fail loudly

@ anvil.server.callable
def get_medicine_details(medicine_name):
    rv = app_tables.products.get(id_name=medicine_name)
    if rv is None:
        raise LookupError(f"no table found with id_name={medicine_name!r}")
    return rv

Adding that line gives the following error:

LookupError: no table found with id_name='adult robitussin maximum strength medicine'

Your id_name for that product is "adult_robitussin", so what you’re passing the function doesn’t match.

If you want some more logging anvil_extras just added client and server side logging that can be used for things like this.

from anvil_extras import logging
server_logger = logging.Logger("server_logger", level=logging.DEBUG)

@ anvil.server.callable
def get_medicine_details(medicine_name):
    rv = app_tables.products.get(id_name=medicine_name)
    if rv is None:
        server_logger.debug(f"None returned from product table id_name={medicine_name!r}")
    return rv
1 Like