Pass the result of this function to another def

One question, how can I pass the result of this function to another def?

first def

def view_repor(id_repor):
    if not auth.get_user():
        return redirect(url_for("login"))
    
    repor = obtener_report_por_id_user2(db,usuario,id_repor)
    return render_template("view_repor.html", repor=repor)

obtener_report_por_id_user2 is a function that makes a mysql query to a database and I obtain a result.
I want to pass this result in a def so I can use that result. Specifically I want it here

def get_embed_info():

    reporte=repor (I know this doesn't work but I would like to do something like this)

The first problem is that repor here isn’t “the result of this function”.

But more importantly, it’s hard to understand how you want the code to work overall. The organization of the code doesn’t seem to make a lot of sense. The (apparent, since you are using things like redirect(url_for and render_template) point of view_repor is that it will be called on demand, in order to create a web page, when someone else visits some URL on your domain (that’s totally out of your control). If get_embed_info is supposed to be a part of that process, then we need a clearer explanation of how it intended to fit in. But if you want, for example, some background task on the server to use get_embed_info, then it doesn’t make any sense for it to depend on the result from view_repor because - which time that view_repor was called should matter?

1 Like

I explain a little the whole process
First you go to a page that shows a series of sectors, 1, 2, 3, 4
If you click on a sector, it shows you a series of reports, the reports it shows are taken from a mysql query to the database
Once you are on the reports page, you can choose which report to see specifically, which should refer to def view_repor(id_repor): and at the same time the def get_embed_info(): call the PbiEmbedService class and def RLS_roles to create the which would be the embeded of the report.

The problem I have is that the report id does not arrive correctly to get_embed_info():

The other option that is occurring to me now is to call the def RLS_roles directly in def view_repor(id_repor): I don’t know if it would work but you could try it.

I don’t know if it has been understood better.

Finally I solved it by modifying the jquery that creates the embed and passes the data, for some unknown reason it sent some correct data locally and others on the web. Now I collect the value from the template so that it has the values correctly from the beginning.
Greetings,