views:

69

answers:

2

Is it possible to programmatically retrieve any of the YAML parameters during run-time? Are they stored in the environment somewhere?

Good example would be to automatically find the application version and to add it as a comment in the landing HTML page.

+3  A: 

No (except for what environment settings CGI and WSGI standards mandate). If you need the full contents of app.yaml to use in your code, then I'd recommend keeping a copy of app.yaml (e.g. as my.yaml in the same directory), and doing

import yaml

...

data = yaml.load(open('my.yaml', 'rb'))

to get the required dictionary data.

Alex Martelli
You may be able to specify app.yaml should be uploaded with the app as well. Perhaps you can adjust skip_files so it will upload. See http://code.google.com/appengine/docs/python/config/appconfig.html#Skipping_Files.
Robert Kluin
@Robert, good idea, +1 -- this way you can avoid the `my.yaml` copy (you still do need the `yaml.load(open('app.yaml', 'rb'))` as in my A, though.
Alex Martelli
+3  A: 

No, but some of the data is available from os.environ - for example, os.environ['APPLICATION_ID'], and os.environ['CURRENT_VERSION_ID'].

Nick Johnson
Works. Thanks! So, the last 1 in the version ID is the API version, is it? (ie) I tried os.environ['CURRENT_VERSION_ID'] and got <app-version-number>.1
Amar Ravikumar
CURRENT_VERSION_ID is in the form 'major.minor'. 'major' is the version name you set in app.yaml; 'minor' is an ID generated by the system. On the dev_appserver, minor will always be 1, while in production it will vary from version to version.
Nick Johnson