{ "info": { "author": "Abdallah Dorra", "author_email": "amdorra@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "==============\nDjango KVModel\n==============\n\n``KVModel`` provides a very convenient way to create key-value models with\njust two lines of code. ::\n\n from kvmodel.models import KVModel\n \n class SystemSettings(KVModel):\n \"\"\" \n SystemSettings Model now extends KVModel, and you will\n be able to access the key and the value fields on that Model\n \"\"\"\n\nInstallation\n------------\n\nYou can Install ``django-kvmodel`` from PyPI.\n ``pip install django-kvmodel``\n\nConfiguration\n-------------\n\nAdd ``kvmodel`` to your ``INSTALLED_APPS`` setting:::\n\n INSTALLED_APPS = (\n ...\n 'kvmodel',\n ...\n )\n\nThis will enable kvmodel, form more advanced settings please check the advanced\nsection.\n\nUsage\n-----\n\n``KVModel`` is an abstract model that has two fields ``key`` and ``value``.\n\n- ``key`` is a unique `CharField`. \n- ``value`` is a `SerializableField` which means that it's type is restored when\n loading an instance from the database, check out the advanced section for more\n details about ``SerializableField``.\n\nDefining key-value models\n^^^^^^^^^^^^^^^^^^^^^^^^^\nExtend ``KVModel`` to create a key-value model::\n\n from kvmodel.models import KVModel\n\n class Settings(KVModel):\n pass\n\nCreating instances\n^^^^^^^^^^^^^^^^^^\nYou can create Instances the same way you will use a Django Model\n ``setting = Settings(key='dragons_in_store', value=123)``\n\nfor a persistent instance\n ``setting = Settings.create(key='dragons_in_store', value=123)``\n\nRetrieving instances\n^^^^^^^^^^^^^^^^^^^^\nyou can use Django filters to retrieve data from your model, however you\nshouldn't use the value field to search for data.\n\nthere is also a method to retrieve objects using their key:\n ``setting = Settings.get_by_key('dragons_in_store')``\n\nwhich is equivalent to:\n ``setting = Settings.get(key='dragons_in_store')``\n\nAdvanced Usage\n--------------\n\nSerializableField\n^^^^^^^^^^^^^^^^^\nthis is a custom field that extends ``TextField``, it encodes the data before\nsaving and decodes it once an instance is loaded from the database.\n\nyou can use ``SerilizableField`` like this::\n \n from kvmodes.models import KVModel\n from kvmodel.fields import SerilizableField\n\n class SystemSettings(KVModel):\n default = SerialiableField()\n\nBy default ``SerializableField`` uses JSON for de-serializing data however you\ncan define your custom de-serializers. \n\nthe `serialize` function is called before the object is saved to the database,\nit should accept the value and returns a string.\n\nthe `deserialize` function is called when loading an instance from the data base,\nit should accept a string and return the restored value \n\nDefining Custom serializer/derserilizer\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\ndefine the functions you want to use as de-serilizers::\n\n aes_serialize(value):\n return aes_encrypt(json.dumps(value), key='super secret key')\n\n aes_deserialize(s):\n return json.loads(aes_decrypt(s, key='super secret key'))\n\nnext you should update the ``KVMODEL`` setting::\n\n KVMODEL = {\n 'SERIALIZE_FUNCTION': 'appname.modulename.aes_serilize',\n 'DESERIALIZE_FUNCTION': 'appname.modulename.aes_deserialize'\n }", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/amdorra/django-kvmodel", "keywords": null, "license": "The MIT License (MIT)\n\nCopyright (c) 2013 abdallah dorra\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of\nthis software and associated documentation files (the \"Software\"), to deal in\nthe Software without restriction, including without limitation the rights to\nuse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\nthe Software, and to permit persons to whom the Software is furnished to do so,\nsubject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\nFOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\nCOPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\nIN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\nCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.", "maintainer": null, "maintainer_email": null, "name": "django-kvmodel", "package_url": "https://pypi.org/project/django-kvmodel/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/django-kvmodel/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/amdorra/django-kvmodel" }, "release_url": "https://pypi.org/project/django-kvmodel/0.1.11/", "requires_dist": null, "requires_python": null, "summary": "A package that helps creating django key-value models easily.", "version": "0.1.11" }, "last_serial": 949345, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "b8a23ca08d0f494c84b8b0f8e1d8ea4c", "sha256": "59af96bc7dc874970e45b9441eeb27151e0b22ae974ad1f402f141dd3b864c31" }, "downloads": -1, "filename": "django-kvmodel-0.1.0.tar.gz", "has_sig": false, "md5_digest": "b8a23ca08d0f494c84b8b0f8e1d8ea4c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5012, "upload_time": "2013-12-07T21:55:55", "url": "https://files.pythonhosted.org/packages/c8/5d/a96bda7f433bc75f6146958f1f10651b24b80079d6e2f49646c06cf494cc/django-kvmodel-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "ad2d573baa4065bdbb99eef1d6ff3e23", "sha256": "9a3b29c18bc5b57d062bf743fe5c80dfce7184dbcd09a8ac6ed897d8fdad9ec3" }, "downloads": -1, "filename": "django-kvmodel-0.1.1.tar.gz", "has_sig": false, "md5_digest": "ad2d573baa4065bdbb99eef1d6ff3e23", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5671, "upload_time": "2013-12-07T22:10:42", "url": "https://files.pythonhosted.org/packages/6f/4f/2714519021865b1e219a2d2137735fbbfb6c846fbbc627151df45c975a40/django-kvmodel-0.1.1.tar.gz" } ], "0.1.11": [ { "comment_text": "", "digests": { "md5": "0d7a8413dcb2967b7238c20932a4ec25", "sha256": "f63958c593ceafa37064a835e015dcaee16c5c8ca579991647517a2e7e7c4a8c" }, "downloads": -1, "filename": "django-kvmodel-0.1.11.tar.gz", "has_sig": false, "md5_digest": "0d7a8413dcb2967b7238c20932a4ec25", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5701, "upload_time": "2013-12-20T03:19:05", "url": "https://files.pythonhosted.org/packages/96/36/40f5727d97b670aaef6efd8e77d87bf1b36bb321cd868e998c137c3f7b35/django-kvmodel-0.1.11.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "0d7a8413dcb2967b7238c20932a4ec25", "sha256": "f63958c593ceafa37064a835e015dcaee16c5c8ca579991647517a2e7e7c4a8c" }, "downloads": -1, "filename": "django-kvmodel-0.1.11.tar.gz", "has_sig": false, "md5_digest": "0d7a8413dcb2967b7238c20932a4ec25", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5701, "upload_time": "2013-12-20T03:19:05", "url": "https://files.pythonhosted.org/packages/96/36/40f5727d97b670aaef6efd8e77d87bf1b36bb321cd868e998c137c3f7b35/django-kvmodel-0.1.11.tar.gz" } ] }