kylerw
(Kylerw)
August 27, 2018, 8:49pm
1
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))
kylerw
(Kylerw)
August 27, 2018, 8:58pm
2
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.
kylerw
(Kylerw)
August 27, 2018, 9:06pm
3
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
kylerw
(Kylerw)
August 27, 2018, 9:16pm
5
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.
aimc
(Andrew Cockburn)
August 27, 2018, 9:17pm
6
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)
kylerw
(Kylerw)
August 27, 2018, 11:08pm
8
Thanks, this is what I ended up doing.
1 Like