{ "info": { "author": "Georg Bauer", "author_email": "gb@rfc1437.de", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Utilities" ], "description": "-*- markdown -*-\n\nSimple Standalone Scripts Using the Django ORM\n=====================================================\n\nThis little library is all about easing the pain of using\nthe Django ORM for simple tools that just happen to be in need\nof some easy to use ORM for object persistence.\n\nThe best way of course is to set up a full Django project and\njust use a settings.py file and using the DJANGO_SETINGS_MODULE\nenvironment variable. But when you just want to do little tools\nthat just need some sqlite3 database to store some of their\ndata and don't want to go for a full Django project, that is\nwhere this little library comes into play.\n\nIt consists of just two modules so far:\n\nstandalone.conf handles all the configuration needs, setting up\n\nstandalone.models carries a base class for your models that\nautomatically tells Python that all models created actually\nreside in the standalone Django app, even though they are\nin a different file, outside the app's namespace.\n\nAs a warning: this might be seen as voodoo, bad magic or just\na plain stupid idea by some people. And the official way\nto do it might be a much better idea for you. I myself just\nhappen to like to have the ability to easily create standalone\nexecutable scripts that don't rely on some predefined project\nstructure.\n\nhow to get it\n---------------\n\nThe easiest way to get django-standalone is to use easy_install\nor pip:\n\nsudo easy_install django-standalone\n\nor\n\nsudo pip install django-standalone\n\nOr you can clone this repository and run the included setup.py\n\nTo run the included test cases, just run the following:\n\npythons setup.py test\n\nusing in your scripts:\n------------------------\n\nFirst create a dynamic configuration for your database\nconnection:\n\n from standalone.conf import settings\n settings = settings(\n DATABASE_ENGINE='sqlite3',\n DATABASE_NAME=options.database,\n )\n\nthis is all you need to do to have django modules working\nin your script. You would have to add additional settings if\nyou want to use more than just the ORM, for example you will\nhave to add TEMPLATE_DIR if you want to use the template modules.\n\nYou can add any django setting you want - standalone.conf will\nallways extend your settings, never overwrite them.\n\nNow you just define a bunch of Models, using the provided base\nclass in your script. The needed module standalone.models\nreexports everything from django.models, so you only need one.\n\n from standalone import models\n\n class MyModel(models.StandaloneModel):\n\n col1 = models.CharField(max_length=1000)\n col2 = models.IntegerField()\n col3 = models.BooleanField()\n\n def __unicode__(self):\n return self.col1\n\nThis will create the model and will make it available directly\nin your script. Additionally it will make them available in the\nmodule standalone.models for access by modules you might import\nin your script or for access in the django shell.\n\nThis patching into standalone.models only happens for models\ndefined in scripts, though - if your models reside in proper\npython modules, nothing of that kind will happen, as they\nare easily accessible to modules or the shell in their original\nmodule. If for any reason you need to force install into\nstandalone.models, too (for example the testing uses this\nto make sure the model is accessible in a standard place even\nthough defined in a module), you can add a class variable\nforce_install_standalone_models with a true value.\n\nIf you want to access a Django shell with access to your models,\nyou can just use the standard way to access management commands\nfrom scripts:\n\n from django.core.management import call_command\n call_command(\"shell\")\n\nThe same way can be used to actually create the tables, too. Put\nthe following lines directly after your model declarations and\nyour script will automatically set up the database tables if they\ndon't yet exist.\n\n from django.core.management import call_command\n call_command(\"syncdb\")\n\nUsing with a library of models\n--------------------------------\n\nYou can create library modules with model definitions based\non StandaloneModel, too. These won't be patched into standalone.models,\nthough, so you have to reference them by their own modules. They\ncan reference models in your script by using symbolic names.\n\n from standalone import models\n\n class MyOtherModel(models.StandaloneModel):\n\n col1 = models.CharField(max_length=100)\n col2 = models.ForeignKey(\"standalone.MyModel\")\n\nTo write a class that again references this library model, just do\nsomething like the following:\n\n from mylibrary.mymodels import MyOtherModel\n\n class AndYetAnotherModel(models.StandaloneModel):\n\n col1 = models.ForeignKey(MyOtherModel)\n\nThere are situations where you need to force a model to be installed\ninto standalone.models to make sure you can access it from other\nplaces. One such situation is setUp methods in test cases. For that\npurpose, you can define an option as follows:\n\n class AllwaysInstalledModel(models.StandaloneModel):\n force_install_standalone_models = True\n\n col1 = models.CharField(max_length=100)\n\nThis model will not only reside in it's own scope but will additionally\nbe hooked up in standalone.models as a global value.\n\nCAVEAT: even if a model is not installed into standalone.models,\nthey will allways be regarded as models of the standalone application.\nWhich means, their table names will all start with 'standalone_'\nin the database! This has to do with the fact that django only likes\nmodel definitions that are linked to some installed django application\nand django-standalone behaves as an umbrella application for all\nmodels defined in the context of a script.\n\ncontacting the author\n-----------------------\n\nCan be done at gb at rfc1437.de in case of problems. Allthough, as the\nlicense says, essentially it's a \"if you break it, you have to keep\nthe pieces\" thing. Of course, I allways like to hear war stories. Just\ndon't blame me if this little lib kills your production server, hunts\ndown your boss and eradicates all your companies expense records.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://bitbucket.org/rfc1437/django-standalone/", "keywords": "django standalone script orm", "license": "BSD", "maintainer": null, "maintainer_email": null, "name": "django-standalone", "package_url": "https://pypi.org/project/django-standalone/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/django-standalone/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://bitbucket.org/rfc1437/django-standalone/" }, "release_url": "https://pypi.org/project/django-standalone/0.4/", "requires_dist": null, "requires_python": null, "summary": "use the Django ORM with standalone scripts", "version": "0.4" }, "last_serial": 790738, "releases": { "0.3": [ { "comment_text": "", "digests": { "md5": "f347f069aeeee0c9dbd44a16e75d7849", "sha256": "8b23dac1d1e3c09dc34602204d1ff92a91f1e6bba0ef758210329b218f6e70f6" }, "downloads": -1, "filename": "django_standalone-0.3-py2.6.egg", "has_sig": false, "md5_digest": "f347f069aeeee0c9dbd44a16e75d7849", "packagetype": "bdist_egg", "python_version": "2.6", "requires_python": null, "size": 8374, "upload_time": "2010-02-28T19:46:40", "url": "https://files.pythonhosted.org/packages/df/11/8bf3a09cfbf57d7098e10cfb4c9a8f56c362bb64b46c72635f0335855449/django_standalone-0.3-py2.6.egg" }, { "comment_text": "", "digests": { "md5": "98d7b42199e9f92c0e7e22589ad61368", "sha256": "1cc645a1fdaefef96c28c499db922ceed1314357db62d6416af76259ea747139" }, "downloads": -1, "filename": "django-standalone-0.3.tar.gz", "has_sig": false, "md5_digest": "98d7b42199e9f92c0e7e22589ad61368", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4980, "upload_time": "2010-02-28T19:46:39", "url": "https://files.pythonhosted.org/packages/3a/cf/e979144cfae45d340682e82216affde1922e0680b4cb210e90db159beb79/django-standalone-0.3.tar.gz" } ], "0.4": [ { "comment_text": "", "digests": { "md5": "a052c0e63e3cf652faf50e03731b7ad7", "sha256": "fba986ad6cf779c644183559b3a17e4dd6c6472771d200b5ccc85fa5c433fc80" }, "downloads": -1, "filename": "django_standalone-0.4-py2.6.egg", "has_sig": false, "md5_digest": "a052c0e63e3cf652faf50e03731b7ad7", "packagetype": "bdist_egg", "python_version": "2.6", "requires_python": null, "size": 12493, "upload_time": "2010-03-07T13:41:28", "url": "https://files.pythonhosted.org/packages/de/6c/df9316e5c6ee1c8aa43a24e3d0f51d868760a02eceed8d873155e7c8873e/django_standalone-0.4-py2.6.egg" }, { "comment_text": "", "digests": { "md5": "d11295dc5e58721eba75fda8597d453b", "sha256": "a5061772165a6167ca1efd2fd71a4e88d2c93fe7ec05554b11d3fa8b48b85d7e" }, "downloads": -1, "filename": "django-standalone-0.4.tar.gz", "has_sig": false, "md5_digest": "d11295dc5e58721eba75fda8597d453b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8012, "upload_time": "2010-03-07T13:41:27", "url": "https://files.pythonhosted.org/packages/d2/6d/b6fc7ff502e79b9c6e26c49b55a53536a4c06eade0a54bcceabe23d6b012/django-standalone-0.4.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "a052c0e63e3cf652faf50e03731b7ad7", "sha256": "fba986ad6cf779c644183559b3a17e4dd6c6472771d200b5ccc85fa5c433fc80" }, "downloads": -1, "filename": "django_standalone-0.4-py2.6.egg", "has_sig": false, "md5_digest": "a052c0e63e3cf652faf50e03731b7ad7", "packagetype": "bdist_egg", "python_version": "2.6", "requires_python": null, "size": 12493, "upload_time": "2010-03-07T13:41:28", "url": "https://files.pythonhosted.org/packages/de/6c/df9316e5c6ee1c8aa43a24e3d0f51d868760a02eceed8d873155e7c8873e/django_standalone-0.4-py2.6.egg" }, { "comment_text": "", "digests": { "md5": "d11295dc5e58721eba75fda8597d453b", "sha256": "a5061772165a6167ca1efd2fd71a4e88d2c93fe7ec05554b11d3fa8b48b85d7e" }, "downloads": -1, "filename": "django-standalone-0.4.tar.gz", "has_sig": false, "md5_digest": "d11295dc5e58721eba75fda8597d453b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8012, "upload_time": "2010-03-07T13:41:27", "url": "https://files.pythonhosted.org/packages/d2/6d/b6fc7ff502e79b9c6e26c49b55a53536a4c06eade0a54bcceabe23d6b012/django-standalone-0.4.tar.gz" } ] }