App Name of calling app

Is there a way to get the calling app name from a global/dependency application?

For instance, I have a Global notification application. When calling it, I’d like to be able to reference the name of the app making the call.

def initialize(self):
  self.notify = self.get_app('Notify')

def calling_app_function(self, ..., ...,):
  notify.alert("this is the message from app {}".format(app_name))
  

similarly (or in place of) - is it possible to get the name of the app instance? While not ideal, I could pass the name into the notify.alert() function.

self.name - easy enough. First question/OP still stands, though… Is it possible?

you use self.notify in your initialise, so you need to use self.notify elsewhere in your app and not notify

yes, freehanded mistake. I understand that part. I’m now wondering if the app that was called has an easy reference to the calling app.

self.get_app().name might work … or something close to that - I can;t check the code at the moment but each App has its name stored somewhere inits instance varibles.

no not that i know. the app that gets called doesnt know who is calling so you need to tell who is calling

i give the name from the calling app in the args, like you tried to.

   self.notify = self.get_app('Notify')
   self.notify.alert("this is the message from app {}".format(self.name))

or rewrite your notify and do it like:

    self.notify.alert(message,self.name)

Thanks, this is what I ended up doing.

1 Like