Debug mode / dev for Python App Engine

I am working on an App Engine (Python) project, where we would like to make certain changes to the behavior of the application during debugging / development (most often locally). For example, during debugging, we would like to disable our speed limiters, enable the debug parameter in WSGIApplication, perhaps add some statements.

As far as I can tell, App Engine, of course, has no idea about the global mode dev-mode or debug-mode, so I'm wondering how best to implement this mode. The options that I have been able to find so far:

  • Use google.appengine.api.app_identity.get_default_version_hostname()to get the host name and see if it starts with localhost. It seems ... unreliable and does not allow you to use debug mode in a deployed application instance.

  • Use os.environ.get('APPLICATION_ID')to get the application identifier, which according to this page is automatically added using the dev~server. Unfortunately, the source of this information is in the warning window:

    Do not extract the application identifier from the environment variable. Development server imitates App Engine service. One way he does this is to add line ( dev~) to APPLICATION_IDan environment variable that looks like a line added to for applications that use high replication storage. You can change this behavior by using the --default_partition flag by selecting "" according to the master-slave parameter during production. Google recommends always getting the application identifier using get_application_id, as described above.

    , . , , , ​​ .

  • ( ), -A dev_appserver.py google.appengine.api.app_identity.get_application_id() . ( , ).

  • dev os.environ.get('CURRENT_VERSION_ID').split('.')[0] . , , dev_appserver.py app.yaml. , sed app.yaml /tmp/ ( dev-app.yaml), dev_appserver.py. / .

- ? , ? ?

+4
1

"" localhost, / .

IS_DEV_APPSERVER = 'development' in os.environ.get('SERVER_SOFTWARE', '').lower()

, , .

+3

All Articles