{ "info": { "author": "Denis Mishchishin", "author_email": "dennz78@gmail.com", "bugtrack_url": null, "classifiers": [ "Framework :: Django", "License :: OSI Approved", "License :: OSI Approved :: GNU General Public License (GPL)", "Programming Language :: Python", "Programming Language :: Python :: 2.7" ], "description": "OUTLINE\n=======\n\n\nPersistent representation of django QuerySet`s.\n\nQuick creation of simple search functionality without custom SQL or implicit markers/ids/indexes storing.\n\nEXAMPLES\n========\n\nTrivial example\n---------------\n\n::\n\n from stored.queryset import FilterQuerySet\n q = FilterQuerySet('Q(text__icontains=\"sometext\")', 'someapp.somemodel')\n q.objects.all() #outputs all \n\n loads(dumps(q)).objects.all() #same result\n\n\n\nSimple with literals\n--------------------\n\n::\n\n #define default literals\n q0 = FilterQuerySet('Q(text__icontains=\"{literal_text}\")', \n 'someapp.somemodel', \n literal_parameter='\"sometext\"')\n\n #new queryset with different `literal_text` value\n q1 = q0.literal(literal_text='\"some_other_text\"').objects.all()\n #literals are parsed with safe `ast.literal_eval` and can be taken from user input\n\n #q1 can be pickled and thus user search can be stored in db\n #if to keep different `FilterQuerySet` for each user.\n loads(dumps(q1)).objects.all() #same result\n\n\nMore complex - user specific search with related fields and persistent parameters\n---------------------------------------------------------------------------------\n\nmodels.py::\n\n from django.db import models\n from django.contrib.auth.models import User\n\n from stored.queryset import FilterQuerySet\n\n class RelatedModel(models.Model):\n user = models.ForeignKey(User, blank=True, null=True)#or maybe MtM\n rating = models.IntegerField()\n\n class SomeModel(models.model):\n text = models.CharField()\n related_field = models.ForeignKey(RelatedModel)\n\nviews.py::\n\n search_query = 'Q(text__icontains=\"{search}\")\\\n &Q(related_field__in=related.filter(rating__gte={min_related_rating}))'\n\n default_search_queryset = \\\n FilterQuerySet(query, 'someapp.somemodel', min_related_rating='3')\n\n def view(request):\n if not request.user.is_anonymous():\n profile = request.user.get_profile()\n query = loads(profile.search) \\\n if profile.search \\\n else default_search_queryset)\n\n #query.objects.all() will raise an exception - \n #we have to define `related` variable and `search` literal\n \n related = RelatedModel.objects.filter(Q(user=request.user)|Q(user__in=[None, '']))\n \n def store_search(query):\n profile.search = dumps(query)\n profile.save()\n else:\n query = default_search_queryset\n related = RelatedModel.objects.filter(Q(user__in=[None, '']))\n def store_search(query):\n pass\n \n #define evaluated variables\n actual_query = query(related=related)\n\n #ALERT: NEVER PASS USER INPUT AS EVALUATED VARIABLES\n #use literals for that\n\n if request.REQUEST.get('search', None): #bonus: previous search stored too\n actual_query.literals(search=request.REQUEST['search'])\n\n\n if request.REQUEST.get('min_rating', None): #override min_rating if required\n actual_query.literals(min_related_rating=request.REQUEST['min_rating'])\n\n #now we can store it together with last search string and `min_related_rating` parameter\n store_search(actual_query)\n #NOTICE. `related` and any evaluated variables will NOT be stored \n #so next time we have to call query with `related` again.\n\n return render_to_response('search.html', {'items':actual_query.objects})\n\nINSTALLATION\n============\nTry one of these::\n\n pip install django-stored-queryset\n easy_install django-stored-queryset", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/denz/django-stored-queryset", "keywords": null, "license": "Copyright (c) 2011, Denis Mishchishin, dennz78@gmail.com\nAll rights reserved.\n\nThis file is part of django-stored-queryset.\n\ndjango-stored-queryset is free software: you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program. If not, see .", "maintainer": null, "maintainer_email": null, "name": "django-stored-queryset", "package_url": "https://pypi.org/project/django-stored-queryset/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/django-stored-queryset/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://github.com/denz/django-stored-queryset" }, "release_url": "https://pypi.org/project/django-stored-queryset/0.0.2/", "requires_dist": null, "requires_python": null, "summary": "pickleable Django QuerySet", "version": "0.0.2" }, "last_serial": 790777, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "65d942f9868d7864788f114835e39f50", "sha256": "73209871fc2533677a3f5830f819198caee9634c2c698d3272ead2c5e33a33be" }, "downloads": -1, "filename": "django_stored_queryset-0.0.1-py2.7.egg", "has_sig": false, "md5_digest": "65d942f9868d7864788f114835e39f50", "packagetype": "bdist_egg", "python_version": "2.7", "requires_python": null, "size": 11473, "upload_time": "2012-05-03T02:14:42", "url": "https://files.pythonhosted.org/packages/5f/6e/91cd1fdc67b19f68326b7e3b479894f03dc6cfff5cb9e41900e8d0ba9911/django_stored_queryset-0.0.1-py2.7.egg" }, { "comment_text": "", "digests": { "md5": "c59cc5546179af12c44ec3d5a1f98f8a", "sha256": "bc45715e8ea4b4ad938a30c5a3f6dd8111eb5e405da1fc193b235ae7fabb209f" }, "downloads": -1, "filename": "django-stored-queryset-0.0.1.tar.gz", "has_sig": false, "md5_digest": "c59cc5546179af12c44ec3d5a1f98f8a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8560, "upload_time": "2012-05-03T10:47:13", "url": "https://files.pythonhosted.org/packages/62/cc/0ede3030ec873bafa488987583b88eab08f22dfed5caff70b9bc0b6fd490/django-stored-queryset-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "49ea96fe19c2f890755d0e51d14dcfe1", "sha256": "f978cc1dc7a5de2105a0aef0968737d55138332666f31e1b1ab6a3ffaaa7e515" }, "downloads": -1, "filename": "django_stored_queryset-0.0.2-py2.7.egg", "has_sig": false, "md5_digest": "49ea96fe19c2f890755d0e51d14dcfe1", "packagetype": "bdist_egg", "python_version": "2.7", "requires_python": null, "size": 11509, "upload_time": "2012-05-04T11:06:58", "url": "https://files.pythonhosted.org/packages/d6/3f/f27351beec7c383a9bdfa5726d156d1aca22a4fb2ac61c8425f582b18adf/django_stored_queryset-0.0.2-py2.7.egg" }, { "comment_text": "", "digests": { "md5": "8edcaa52990239682fa773d9f39ca429", "sha256": "da735d53fa1a6c036cd2427e11a522146cda73dcaf5a35f527c25f67ba9099cf" }, "downloads": -1, "filename": "django-stored-queryset-0.0.2.tar.gz", "has_sig": false, "md5_digest": "8edcaa52990239682fa773d9f39ca429", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8629, "upload_time": "2012-05-04T11:06:57", "url": "https://files.pythonhosted.org/packages/bf/4d/91b59d57b9bef9ead148f8ab8da457b902752ac926ddde5e430f3c27678f/django-stored-queryset-0.0.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "49ea96fe19c2f890755d0e51d14dcfe1", "sha256": "f978cc1dc7a5de2105a0aef0968737d55138332666f31e1b1ab6a3ffaaa7e515" }, "downloads": -1, "filename": "django_stored_queryset-0.0.2-py2.7.egg", "has_sig": false, "md5_digest": "49ea96fe19c2f890755d0e51d14dcfe1", "packagetype": "bdist_egg", "python_version": "2.7", "requires_python": null, "size": 11509, "upload_time": "2012-05-04T11:06:58", "url": "https://files.pythonhosted.org/packages/d6/3f/f27351beec7c383a9bdfa5726d156d1aca22a4fb2ac61c8425f582b18adf/django_stored_queryset-0.0.2-py2.7.egg" }, { "comment_text": "", "digests": { "md5": "8edcaa52990239682fa773d9f39ca429", "sha256": "da735d53fa1a6c036cd2427e11a522146cda73dcaf5a35f527c25f67ba9099cf" }, "downloads": -1, "filename": "django-stored-queryset-0.0.2.tar.gz", "has_sig": false, "md5_digest": "8edcaa52990239682fa773d9f39ca429", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8629, "upload_time": "2012-05-04T11:06:57", "url": "https://files.pythonhosted.org/packages/bf/4d/91b59d57b9bef9ead148f8ab8da457b902752ac926ddde5e430f3c27678f/django-stored-queryset-0.0.2.tar.gz" } ] }