Amarnath Ravikumar
Amarnath Ravikumar

Reputation: 920

Retrieving YAML parameters during runtime in App Engine (Python)

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.

Upvotes: 3

Views: 1098

Answers (3)

Unwoven
Unwoven

Reputation: 21

In PyYAML, the __init__.py file in the yaml folder has a global variable __version__, so

#import yaml
print yaml.__version__

Upvotes: 2

Nick Johnson
Nick Johnson

Reputation: 101149

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

Upvotes: 5

Alex Martelli
Alex Martelli

Reputation: 882491

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.

Upvotes: 4

Related Questions