Dynamically retrieving application's name

43 views
Skip to first unread message

Samidh

unread,
May 8, 2008, 4:28:49 PM5/8/08
to Google App Engine

Very basic question: Is there a python method I can call in order to
dynamically retrieve the name of my app engine application?

Basically I would like to find a way to access the name of my
application from within my python code (without hard coding it!).

Thanks!

James Ashley

unread,
May 8, 2008, 7:15:35 PM5/8/08
to google-a...@googlegroups.com
At the very worst, you could use the yaml library to parse app.yaml.

javaDinosaur

unread,
May 9, 2008, 8:43:00 AM5/9/08
to Google App Engine
The Datastore Key class has an app() method that returns the
application name. If you have a single data entity guaranteed to be
available that would be one route to the app name.

A more direct api call to this name would be preferable.

Barry Hunter

unread,
May 9, 2008, 9:36:57 AM5/9/08
to google-a...@googlegroups.com
I don't believe app.yaml actually exists appspot - its uploaded
separately and probably written to some propriety system. Not to say
you couldn't remove it from the exclude list.
http://code.google.com/appengine/docs/configuringanapp.html#Skipping_Files

How about looking at HTTP_HOST ? (or what ever the HTTP header would
be accessed as in GAE)

--
Barry

- www.nearby.org.uk - www.geograph.org.uk -

majek04

unread,
May 9, 2008, 9:41:50 AM5/9/08
to google-a...@googlegroups.com
On Thu, May 8, 2008 at 10:28 PM, Samidh <sm...@gmail.com> wrote:
>
>
> Very basic question: Is there a python method I can call in order to
> dynamically retrieve the name of my app engine application?

how about os.getcwd() ? (tested using http://shell.appspot.com/)

>>> os.getcwd()
'/base/data/home/apps/shell/1.21'

>>> os.getcwd().split('/')[-2]
'shell'

dsw

unread,
May 10, 2008, 4:32:47 PM5/10/08
to Google App Engine
Forgive the naivete of my question, but since you wrote the app, don't
you know its name? Unless you are writing a library that at some
point wants to display the app's name, I am having trouble
understanding when you would want this.

Lee O

unread,
May 11, 2008, 12:16:29 AM5/11/08
to google-a...@googlegroups.com
Not sure on the use, but if you plan to distribute a project (perhaps a opensource blog system) nothing can be hardcoded. You "could" make people enter their own app name when configing your software, but why do it if you dont have to.
--
Lee Olayvar
http://www.leeolayvar.com

Duncan

unread,
May 11, 2008, 4:08:36 AM5/11/08
to Google App Engine
On May 9, 2:41 pm, majek04 <maje...@gmail.com> wrote:
> On Thu, May 8, 2008 at 10:28 PM, Samidh <sm...@gmail.com> wrote:
>
> > Very basic question: Is there a python method I can call in order to
> > dynamically retrieve the name of my app engine application?
>
> how about os.getcwd() ? (tested usinghttp://shell.appspot.com/)
>
> >>> os.getcwd()
>
> '/base/data/home/apps/shell/1.21'
>
> >>> os.getcwd().split('/')[-2]
>
> 'shell'

That also answers the question I was going to ask: how do you find out
the application's current version. Even if app.yaml was uploaded that
still wouldn't reveal the minor version number, but getting it out of
the current directory or the environment
(os.environ['PATH_TRANSLATED'] has the path to the script) looks like
it should work. Thanks.

Pavel Vlasov

unread,
Mar 11, 2012, 3:12:56 PM3/11/12
to google-a...@googlegroups.com
The following variable holds correct application name on the production side:

os.getenv('APPLICATION_ID')

Unfortunately it holds a crap like "dev~appname" on the dev server. But it is better than parsing file path (that's a really bad idea).

Barry Hunter

unread,
Mar 11, 2012, 3:56:07 PM3/11/12
to google-a...@googlegroups.com
Well this thread is really old. There is now a App Identity API,

http://code.google.com/appengine/docs/python/appidentity/overview.html

This handles that for you.

> --
> You received this message because you are subscribed to the Google Groups
> "Google App Engine" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/google-appengine/-/v7W-7_p_rxsJ.
> To post to this group, send email to google-a...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-appengi...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/google-appengine?hl=en.

Reply all
Reply to author
Forward
0 new messages