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开发者_Python百科 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.
No, but some of the data is available from os.environ - for example, os.environ['APPLICATION_ID']
, and os.environ['CURRENT_VERSION_ID']
.
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
.
In PyYAML, the __init__.py
file in the yaml folder has a global variable __version__
, so
#import yaml
print yaml.__version__
精彩评论