Skip to content

Instantly share code, notes, and snippets.

@nickbauman
Created August 15, 2014 22:01
Show Gist options
  • Save nickbauman/9eff03186a74ff8ca3a3 to your computer and use it in GitHub Desktop.
Save nickbauman/9eff03186a74ff8ca3a3 to your computer and use it in GitHub Desktop.
GAE app identity, version and deploy time example
# config
def _APP_VERSION():
if on_development_server or not on_server:
return "0", 0
else:
version_time = os.environ['CURRENT_VERSION_ID']
return (version_time.find('.') > -1 and version_time.split('.')) or (version_time, -1)
config.APP_VERSION = _APP_VERSION()
# Useage in a handler
class MainHandler(RequestHandler):
(version, deploy_epoch) = config.APP_VERSION
deploy_timestamp = long(deploy_epoch) / pow(2, 28)
# Note this will be a nonsensical value on the dev/sdk server
when_deployed = datetime.fromtimestamp(deploy_timestamp).strftime("%d/%m/%y %X")
def get(self):
render_template(self.response, 'main.html', {'version': self.version,
"when_deployed": self.when_deployed,
'home_view': True,
'logout_url': users.create_logout_url('/')})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment