{ "info": { "author": "Prince Odame", "author_email": "opodame@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 2.7", "Topic :: Software Development :: Libraries" ], "description": "# gae_env\n\nConsole-visible environment variables for Google Appengine projects\n\n#\n## Overview\n\nBy default, GAE environment variables may be [configured in the app.yaml file][1] or uploaded via a secrets.json.\n\nBut, for sensitive data, you should not store it in source code as it will be checked into source control.\nEven if you dont, the wrong people (inside your organization) may find it there.\n\nAlso, your development environment probably uses different config values from your production environment.\nIf these values are stored in code, you will have to run different code in development and production, which is not just messy but also bad practice.\n\n# \n\n`gae_env` reads environment variables from [Cloud Datastore][7] (and/or system environment variables). This way, it becomes more convenient to edit variables in the [Developer's Console][2]\n\n## Usage\n\n```python\n# coding: utf-8\nimport gae_env\nfrom gae_env import ValueNotSetError, NOT_SET_VALUE\n\nkey_foo = 'foo'\n\n# get the value stored at key 'key_foo'\nvalue_bar = gae_env.get(key_foo)\n\n# By default, values are of type str\n\n# get value as int\nvalue_bar = gae_env.get(key_foo, converter_class=int)\n\n# get value as float\nvalue_bar = gae_env.get(key_foo, converter_class=float)\n\n# ******************************************************************************\n# If there is a value for a key in the system environment variables or datastore,\n# it will be returned.\n# Else, a place holder record will be created and ValueNotSetError exception will be raised.\n# The exception will remind you to go to the Developers Console\n# and update the placeholder record.\n# ******************************************************************************\n\n# The default error raising behaviour can be turned off with a param\n# get value without raising any ValueNotSetError\nvalue_bar = gae_env.get(key_foo, raise_value_not_set_error=False)\n\n# If no value has been set for a key and raise_value_not_set_error=False,\n# it will return NOT_SET_VALUE.\n# To return None instead, pass return_none_for_not_set_value=True\nvalue_bar = gae_env.get(\n key_foo, raise_value_not_set_error=False, return_none_for_not_set_value=True\n)\n\n# There's a convenience method for setting the value of a key at runtime\n# NB: This sets the value in Cloud Datastore (not system environment variables)\nvalue_bar = 'bar'\ngae_env.set_value(name=key_foo, value=value_bar)\n\n```\n\n**How to set Datastore values in the App Engine console:**\n\n1. Go to the [console][2].\n\n2. Select your project at the top of the page if it's not already selected.\n\n3. In the Kind dropdown box, select `GaeEnvSettings`.\n\n4. Your keys will show up. For those where an exception was raised, they will all have the value `__NOT_SET__`. Click each one and set its value.\n\n**What if I am in development?**\n\n- Using the local admin server. This is usually started on the url http://localhost:8000\n 1. In the admin server page, go to the *Datastore Viewer*\n 2. In the EntityKind dropdown box, select `GaeEnvSettings`.\n 3. Your keys will show up. For those where an exception was raised, they will all have the value `__NOT_SET__`. Click each one and set its value.\n\n- Alternatively, you can pass environment variables as arguments to `dev_appserver.py`.\n - The argument `--env_var=...` can be used to specify the environment variables to use when running the local development server.\nEach env_var argument is in the format of *`key=value`*, and you can define multiple envrionment variables.\nFor example: `--env_var=KEY_1=val1 --env_var=KEY_2=val2`\n\n\n## Dependencies\n\n`gae_env` uses the `ndb` library which uses [MemCache][6] and [Cloud Datastore][7] under the hood, so it's fast.\n\nBut this also means it requires the context of a Google Appengine runtime in order to work, and can be used in Google Appengine projects only\n\n\n## Testing\nThis project uses [`nose`][3], [`nosegae`][4] and [`coverage`][5] for testing.\n\nYou must have these installed:\n\n pip install -r test_requirements.txt\n\nIn addition, you must have gcloud sdk installed, with google appengine enabled.\n\nRun:\n\n export GAE_LIB_ROOT=/path/to/local/google-cloud-sdk/platform/google_appengine/\n python setup.py nosetests --gae-lib-root=$GAE_LIB_ROOT\n\n\n## Contributing\n\n1. Fork it ()\n2. Create your feature branch (`git checkout -b feature/fooBar`)\n3. Commit your changes (`git commit -am 'Add some fooBar'`)\n4. Push to the branch (`git push origin feature/fooBar`)\n5. Create a new Pull Request\n\n\n\n[1]: https://cloud.google.com/appengine/docs/standard/python3/config/appref#runtime_and_app_elements\n[2]: https://console.cloud.google.com/datastore/\n[3]: https://nose.readthedocs.io/en/latest/index.html\n[4]: https://github.com/Trii/NoseGAE\n[5]: https://coverage.readthedocs.io/en/coverage-4.5.1x/\n[6]: https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=2ahUKEwjgjpb-ue7dAhVpL8AKHfCBAPAQFjAAegQIChAB&url=https%3A%2F%2Fcloud.google.com%2Fappengine%2Fdocs%2Fstandard%2Fpython%2Fmemcache%2F&usg=AOvVaw1zwnB3ofKYNGfyHRqq_i2j\n[7]: https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=2ahUKEwip1q-Huu7dAhURTsAKHYM3BJcQFjAAegQICBAB&url=https%3A%2F%2Fcloud.google.com%2Fdatastore%2Fdocs%2Fconcepts%2Foverview&usg=AOvVaw0gMRTKGWVdpgoM40VbA9BC", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/Odame/gae-env", "keywords": "google appengine env var environment variable cloud datastore", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "gae-env", "package_url": "https://pypi.org/project/gae-env/", "platform": "", "project_url": "https://pypi.org/project/gae-env/", "project_urls": { "Homepage": "https://github.com/Odame/gae-env" }, "release_url": "https://pypi.org/project/gae-env/0.1.2/", "requires_dist": null, "requires_python": "", "summary": "Google Appengine environment variables stored in Cloud Datastore (and/or system environment variables)", "version": "0.1.2" }, "last_serial": 4375524, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "0a6358052ec5fa98c83f6271e35745ac", "sha256": "26fa4b5b093b7d1bc8cb92f5cc2cff8d210efe1b12881d6f8e0e22552095648d" }, "downloads": -1, "filename": "gae_env-0.1.0.tar.gz", "has_sig": false, "md5_digest": "0a6358052ec5fa98c83f6271e35745ac", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5958, "upload_time": "2018-10-05T06:38:49", "url": "https://files.pythonhosted.org/packages/d9/6f/0c9861352f4d990c7b3f7ccec61bfbf75986d34a817259eec56cfbd6063c/gae_env-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "7d1d7b941a66f79992a18ab11dc29043", "sha256": "34814839192994bf614e908cfb9a5cd379932429e15f63ad710d529cdee6523e" }, "downloads": -1, "filename": "gae_env-0.1.1.tar.gz", "has_sig": false, "md5_digest": "7d1d7b941a66f79992a18ab11dc29043", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5957, "upload_time": "2018-10-05T06:51:42", "url": "https://files.pythonhosted.org/packages/ac/8e/ba968ed579f604574ac9604ad07fd275cde7e457ed567d256dde91ab6303/gae_env-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "914ad2368f792e9ee70b7b15fc38b973", "sha256": "b1f08950eda45961a3507265a681b9dc27d0dcc4f7f76c2aa1fab7a0787b546d" }, "downloads": -1, "filename": "gae_env-0.1.2.tar.gz", "has_sig": false, "md5_digest": "914ad2368f792e9ee70b7b15fc38b973", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6335, "upload_time": "2018-10-14T22:31:29", "url": "https://files.pythonhosted.org/packages/15/f8/6ae5f1cc15a980241bd02442761824c4266eb92dac44196c8a94be989059/gae_env-0.1.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "914ad2368f792e9ee70b7b15fc38b973", "sha256": "b1f08950eda45961a3507265a681b9dc27d0dcc4f7f76c2aa1fab7a0787b546d" }, "downloads": -1, "filename": "gae_env-0.1.2.tar.gz", "has_sig": false, "md5_digest": "914ad2368f792e9ee70b7b15fc38b973", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6335, "upload_time": "2018-10-14T22:31:29", "url": "https://files.pythonhosted.org/packages/15/f8/6ae5f1cc15a980241bd02442761824c4266eb92dac44196c8a94be989059/gae_env-0.1.2.tar.gz" } ] }