{"id":60,"date":"2009-12-19T12:47:02","date_gmt":"2009-12-19T16:47:02","guid":{"rendered":"http:\/\/dashdrum.com\/blog\/?p=60"},"modified":"2010-01-29T15:36:04","modified_gmt":"2010-01-29T19:36:04","slug":"more-on-environment-variables-and-local-settings","status":"publish","type":"post","link":"https:\/\/dashdrum.com\/blog\/2009\/12\/more-on-environment-variables-and-local-settings\/","title":{"rendered":"More on Environment Variables and Local Settings"},"content":{"rendered":"<p><a href=\"http:\/\/dashdrum.com\/blog\/?p=56\">(See the earlier post)<\/a><\/p>\n<p>A little more research after a suggestion from the server admin has confirmed that I can&#8217;t see Apache environment variables with <code>os.environ<\/code> in a WSGI interface.  Instead, those are available through the <code>request<\/code> object.  Since I don&#8217;t yet have a request object when starting up the app, I had to find a new way to ID the instance.<\/p>\n<p>My server admin suggested that he add a system environment variable that would hold the instance name.  I can read those variables just fine.  He did, I read it, and all is well.  New code:<\/p>\n<pre>import os\r\nTIER = os.environ.get('TIER','') ## get the value of the TIER env variable\r\n\r\nif fqdn == 'dashdrum_laptop':          ## laptop\r\n    SERVER_ENVIRONMENT = 'Laptop'\r\nelif TIER == 'dev':                ## dev server\r\n    SERVER_ENVIRONMENT = 'DEV'\r\nelif TIER == 'qa':                 ## qa server\r\n    SERVER_ENVIRONMENT = 'QA'\r\nelif TIER == 'prod':               ## production server\r\n    SERVER_ENVIRONMENT = 'PROD'<\/pre>\n<p>Note that I&#8217;m still using the fqdn to ID the laptop.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>(See the earlier post) A little more research after a suggestion from the server admin has confirmed that I can&#8217;t see Apache environment variables with os.environ in a WSGI interface. Instead, those are available through the request object. Since I don&#8217;t yet have a request object when starting up the app, I had to find &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/dashdrum.com\/blog\/2009\/12\/more-on-environment-variables-and-local-settings\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;More on Environment Variables and Local Settings&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-60","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/dashdrum.com\/blog\/wp-json\/wp\/v2\/posts\/60","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dashdrum.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dashdrum.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dashdrum.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/dashdrum.com\/blog\/wp-json\/wp\/v2\/comments?post=60"}],"version-history":[{"count":4,"href":"https:\/\/dashdrum.com\/blog\/wp-json\/wp\/v2\/posts\/60\/revisions"}],"predecessor-version":[{"id":80,"href":"https:\/\/dashdrum.com\/blog\/wp-json\/wp\/v2\/posts\/60\/revisions\/80"}],"wp:attachment":[{"href":"https:\/\/dashdrum.com\/blog\/wp-json\/wp\/v2\/media?parent=60"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dashdrum.com\/blog\/wp-json\/wp\/v2\/categories?post=60"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dashdrum.com\/blog\/wp-json\/wp\/v2\/tags?post=60"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}