{ "info": { "author": "Paylogic International", "author_email": "developers@paylogic.com", "bugtrack_url": null, "classifiers": [], "description": "pltk: Paylogic toolkit\n======================\n\nThe ``pltk`` package is a collection of useful tools for frameworks and other tools. At the moment there's only one\nset of them - flask related tools.\n\n.. image:: https://api.travis-ci.org/paylogic/pltk.png\n :target: https://travis-ci.org/paylogic/pltk\n.. image:: https://pypip.in/v/pltk/badge.png\n :target: https://crate.io/packages/pltk/\n.. image:: https://coveralls.io/repos/paylogic/pltk/badge.png?branch=master\n :target: https://coveralls.io/r/paylogic/pltk\n\n\nInstallation\n------------\n\n.. sourcecode::\n\n pip install pltk\n\n\nUsage\n-----\n\nPackage contains several utility modules. We will describe them one by one.\n\n\nUseful Flask commands\n^^^^^^^^^^^^^^^^^^^^^\n\n.. code-block:: python\n\n from pltk import commands\n commands.install_commands(app, manager, db, model_collector)\n\nthen your app will have such additional commands:\n\n monitor_test\n Run a test as monitor command.\n Example usage::\n\n $ app monitor_test \\\n -T app.tests.test_utils:TestView \\\n -H dev.app.com -P 443 -R /unstable -S https\n\n shell\n Run Python shell with application context.\n\n dbshell\n Run database shell.\n\n http\n Run HTTP emulating console.\n Examples::\n - POST /foo/bar list=[1,2,3,4]\n - POST /user/login email=a@b.com password=p\n - GET /user/profile\n - header Authorization 1232123123\n\n print_settings\n Print all current Flask Settings.\n\n ec2_backup\n Create an ami from the current server and pushes its contents to s3.\n\n compile_messages\n Update the gettext messages.pot file and initialize the supported languages (if not already)\n and compile the messages to .mo files.\n This command assumes it is executed from the root of the project and stores translations into a folder\n 'translations' inside the same location. It also assumes there is a 'babel.cfg' file and lazy_gettext\n is used next to general gettext methods.\n\n If you want to add a new language, add it to app.config['SUPPORTED_LANGUAGES'] and run this command.\n\n\nRate limiting\n^^^^^^^^^^^^^\n\n.. code-block:: python\n\n from pltk import limit\n\n @app.route('/rate-limited')\n @limit.rate(limit=300, per=60 * 15)\n def index():\n return '

This is a rate limited response

'\n\n\nThis would limit the function to be called 300 times per 15 minutes.\n\nBefore the function is executed it increments the rate limit with the help of the RateLimit class and stores an\ninstance of it on g as g._view_rate_limit. Also if the view is indeed over limit we automatically call a different\nfunction instead.\n\nThe view function itself can get hold of the current rate limit by calling ::\n\n RateLimit.get_view_rate_limit().\n\nWe also give the key extra expiration_window seconds time to expire in redis so that badly synchronized clocks between\nthe workers and the redis server do not cause problems. Furthermore we use a pipeline (uses MULTI behind the scenes)\nto make sure that we never increment a key without also setting the key expiration in case an exception happens between\nthose lines (for instance if the process is killed).\n\n\nSetup locale\n^^^^^^^^^^^^\n\n.. code-block:: python\n\n from pltk import locale\n locale.setup_locale(babel, app):\n\n\nSetup locale selector for given app. This will set up straitforward locale selector based on babel's request locale\nbest_match mechanizm.\n\n\nMonitor command\n^^^^^^^^^^^^^^^\n\n.. code-block:: python\n\n from pltk import monitor_command\n monitor_command.main('tests.some.test', 'localhost', 'http', '8080', 'app'):\n\n\nScript for running a regular nose test which uses the Werkzeug test client as a\nmonitoring command against any remote server.\n\n\nRedis wrapper\n^^^^^^^^^^^^^\n\n.. code-block:: python\n\n from pltk import redis_wrapper\n redis = redis_wrapper.Redis(app)\n redis.set('some', 'value')\n\nModule for Redis operations. Holds the Redis Flask wrapper. All you need is the app instance to create it.\nIt gets all setting from the application. You don't have to pass them manually.\n\n\nBase test case\n^^^^^^^^^^^^^^\n\n.. code-block:: python\n\n from pltk import tests\n\n class MyTestCase(tests.TestCase):\n\n def test_something(self):\n response = self.get(self, '/foo', auth=False)\n self.assertTrue('test' in response.content)\n\n\nUseful Flask base test case.\n\n\nView\n^^^^\n\n.. code-block:: python\n\n from pltk import view\n\n def authorize(token):\n \"\"\"We implement own authorize callback.\"\"\"\n return token == 'ok'\n\n # then monkey patch it to the view module\n view.authorize = authorize\n\n\n class MyView(View):\n def get(self, query):\n \"\"\"If request headers have json in ACCEPT. This result of a function will be encoded to json.\"\"\"\n return {'result': [1, 2, 3]}\n\n\nContact\n-------\n\nIf you have questions, bug reports, suggestions, etc. please create an issue on the\n`GitHub project page `_.\n\nLicense\n-------\n\nThis software is licensed under the `MIT license `_\n\nSee ``_\n\n\u00a9 2013 Paylogic International.\n\nChangelog\n=========\n\n\n0.3\n---\n\n* Initial public release", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "UNKNOWN", "keywords": null, "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "pltk", "package_url": "https://pypi.org/project/pltk/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/pltk/", "project_urls": { "Download": "UNKNOWN", "Homepage": "UNKNOWN" }, "release_url": "https://pypi.org/project/pltk/0.3/", "requires_dist": null, "requires_python": null, "summary": "Paylogic Toolkit", "version": "0.3" }, "last_serial": 1055866, "releases": { "0.3": [ { "comment_text": "", "digests": { "md5": "f3c9d4e5ff1bc6260acca322382a4a38", "sha256": "0525ad1d5784436588ed679daed8722ef2d9cd5a2b15d9790295405bbd0a639d" }, "downloads": -1, "filename": "pltk-0.3.tar.gz", "has_sig": false, "md5_digest": "f3c9d4e5ff1bc6260acca322382a4a38", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14591, "upload_time": "2014-04-09T13:26:45", "url": "https://files.pythonhosted.org/packages/6e/c7/c3537060972a5ac45ac53fdf7c84f86df3e3386ab3f1bb23ecd02c3de870/pltk-0.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "f3c9d4e5ff1bc6260acca322382a4a38", "sha256": "0525ad1d5784436588ed679daed8722ef2d9cd5a2b15d9790295405bbd0a639d" }, "downloads": -1, "filename": "pltk-0.3.tar.gz", "has_sig": false, "md5_digest": "f3c9d4e5ff1bc6260acca322382a4a38", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14591, "upload_time": "2014-04-09T13:26:45", "url": "https://files.pythonhosted.org/packages/6e/c7/c3537060972a5ac45ac53fdf7c84f86df3e3386ab3f1bb23ecd02c3de870/pltk-0.3.tar.gz" } ] }