views:

73

answers:

2

Under the application settings page in the Administration console, it is possible to specify a name for the application, AFAIK this is used in the login page when using the users API to login.

I would like to be able to use this information within an application, currently, the title is also specified in a separate configuration file, but configuration repetition is something I would like to avoid if at all possible.

Is there some way for a GAE application to determine the "Application Title"?

Oh, also, I am using python.

A: 

I believe that's not possible, unfortunately.

Using the app enine console, I could not find the application title on the environment variables.

>>> for key, value in os.environ.iteritems():
...     print key, value
... 
HTTP_REFERER http://con.appspot.com/console/
SERVER_SOFTWARE Google App Engine/1.3.4
SCRIPT_NAME 
REQUEST_METHOD POST
PATH_INFO /console/statement
HTTP_ORIGIN http://con.appspot.com
SERVER_PROTOCOL HTTP/1.1
QUERY_STRING 
USER_IS_ADMIN 0
CONTENT_LENGTH 68
HTTP_ACCEPT_CHARSET ISO-8859-1,utf-8;q=0.7,*;q=0.3
HTTP_USER_AGENT Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/532.5 (KHTML, like Gecko) Chrome/4.1.249.1064 Safari/532.5,gzip(gfe)
TZ UTC
HTTP_COOKIE __utmz=2586530.1263046728.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); ACSID=AJKiYcHZZt2WuvaQNPhvMLL3RhbTYHNsWUo54MIQVw8RCJDiiLZHChRq46hwNj6EN7mdJ9GRYXgYC33jDlHu4iq1-zNHRzr9-0V8vWSuKWIUb7wwErYzRtddAkzZKq_nOrCR4p5UxV5zwRnDCQVJn8QT1ZzXJe3cLsF3flKIIQzcGYNXWc_vLcIBOTm-FcXVdeFCXdRhppZRbXi5j-stKvcdrj7q8cv95YGX94a6FYA_P_UfDRkEZ5mc_UxMnHM5J1LcQQhzyJEtb6sDxQEuMUzcve5AoaXDxCCLgaWPq6f4YlNeINM8pm7x5-LWhV7-kCgSW1KqygZaR1q-qtsfnWJwOjtxvOOD_ERudh85LMb9p1kJXVxHuWoWoRxCfN_tRFpVPiZJM6UBnsI6nmtQGjhLLN6rpamyn6RXG5uxf6paQQKXwG3cM0ujx3e7-RpsRM18gMFTdrncs1zcrR5ZjKKeAjKrw_sX69V31KiHx4XAjwRz2lR61PymJDw57OyamUXMuDuLYrc_; __utma=2586530.845840213.1263046728.1264248611.1274271554.4; __utmc=2586530; __utmb=2586530.3.10.1274271554
SERVER_NAME con.appspot.com
REMOTE_ADDR 64.209.18.36
HTTP_VIA 1.1 BRSOPRX002
PATH_TRANSLATED /base/data/home/apps/con/1-0beta3.330900106084229577/console/app/console.py
SERVER_PORT 80
CONTENT_TYPE application/x-www-form-urlencoded
HTTP_X_REQUESTED_WITH XMLHttpRequest
CURRENT_VERSION_ID 1-0beta3.330900106084229577
USER_ORGANIZATION 
HTTP_HOST con.appspot.com
HTTPS off
APPLICATION_ID con
HTTP_CONTENT_TYPE application/x-www-form-urlencoded
USER_EMAIL [email protected]
HTTP_ACCEPT application/json, text/javascript, */*
DATACENTER na5
USER_ID 105014683574647550247
HTTP_ACCEPT_LANGUAGE en-US,en;q=0.8
USER_NICKNAME XXXXX
HTTP_CONTENT_LENGTH 68
AUTH_DOMAIN gmail.com
USER apphosting
jbochi
+2  A: 

There's actually a way to do it, but it might be a little too much on the hacky side.. you can get the title (ab)using the users API like this:

>>> from google.appengine.api import users
>>> import urllib
>>> url = users.create_login_url()
>>> url_dict = dict((p.split('=') for p in url.split('&')))
>>> urllib.unquote_plus(url_dict['ahname'])
'App Engine Console'

I tried it on the App Engine Console linked by jbochi (great link btw, thanks!). Not to sure weather I'd put such code into production, though. Further diving into google.appengine.api.user_service might turn up a saner way.

Jacob Oscarson
+1 - Nice hack!
jbochi