{
"info": {
"author": "Pablo Martin",
"author_email": "goinnn@gmail.com",
"bugtrack_url": null,
"classifiers": [
"Development Status :: 4 - Beta",
"Framework :: Django",
"License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)"
],
"description": ".. contents::\n\n======================\ndjango-deep-serializer\n======================\n\n.. image:: https://travis-ci.org/goinnn/django-deep-serializer.png?branch=master\n :target: https://travis-ci.org/goinnn/django-deep-serializer\n\n.. image:: https://coveralls.io/repos/goinnn/django-deep-serializer/badge.png?branch=master\n :target: https://coveralls.io/r/goinnn/django-deep-serializer\n\n.. image:: https://badge.fury.io/py/django-deep-serializer.png\n :target: https://badge.fury.io/py/django-deep-serializer\n\n.. image:: https://pypip.in/d/django-deep-serializer/badge.png\n :target: https://pypi.python.org/pypi/django-deep-serializer\n\nWith django-deep-serializer you can serialize/deserialize an object and its relations through class definitions\n\nRequeriments\n============\n\n* `django `_ (>=1.4, it's possible that works with previous versions)\n* `PyYAML `_ (>=3.10, optional only if you want use this serializer)\n* `django-form-admin `_ (>=0.4.2, optional only to the example project)\n\n\nInstallation\n============\n\nIf you want use natural keys, you have use the `internal serializers `_ These are got from django git repository. These are not in the any stable branch or release. You have to write in your settings:\n\n::\n\n SERIALIZATION_MODULES = {\n \"xml\" : \"deep_serializer.serializers.xml_serializer\",\n \"python\" : \"deep_serializer.serializers.python\",\n \"json\" : \"deep_serializer.serializers.json\",\n #\"yaml\" : \"deep_serializer.serializers.pyyaml\",\n }\n\nUse cases\n=========\n\n* Serialize (using primary keys or natural keys) an object and its relations. Sometimes django can not serialize an app. E.g. if you try to serialize the \"example.app\" application in the example project you will get the next error: \"CommandError: Unable to serialize database: Can't resolve dependencies for app.Page, app.WebSite in serialized app list.\"\n* Deserialize (using primary keys or natural keys) some objects\n* Clone (using natural keys) an object. To do you can serialize, update the natural key to the main object and after deserialize these objects\n* Restore an object with its relations, (using primary keys or natural keys)\n\nHow to use\n==========\n\nThe idea is get to have a serializer or/and a deserializer implemented with very few lines. These have to be able to define some \"rules\".\nThere are five examples (five distinct use case) in the `example project `_. E.g.:\n\n::\n\n class WebSiteClone(MyMetaWalkClass):\n\n @classmethod\n def pre_serialize(cls, initial_obj, obj, request, serialize_options=None):\n obj = super(WebSiteClone, cls).pre_serialize(initial_obj, obj,\n request,\n serialize_options=serialize_options)\n new_title = '%s-%s' % (obj.title, time.time())\n obj.title = new_title[:200]\n obj.slug = get_hash()\n obj.original_website_id = obj.pk\n obj.initial_page = None\n return obj\n\n @classmethod\n def walking_into_class(cls, initial_obj, obj, field_name, model, request=None):\n if field_name in ('initial_page', 'websites_created_of'):\n return WALKING_STOP\n elif field_name in ('original_website', 'owners'):\n return ONLY_REFERENCE\n elif field_name == 'page':\n return WALKING_INTO_CLASS\n update_the_serializer(obj, field_name)\n\n\n class PageClone(MyMetaWalkClass):\n\n @classmethod\n def pre_serialize(cls, initial_obj, obj, request, serialize_options=None):\n obj = super(PageClone, cls).pre_serialize(initial_obj,\n obj, request,\n serialize_options=serialize_options)\n obj.website = initial_obj\n obj.created_from_id = obj.pk\n return obj\n\n @classmethod\n def walking_into_class(cls, initial_obj, obj, field_name, model, request=None):\n if field_name in ('pages_created_of', 'website', 'website_initial_page'):\n return WALKING_STOP\n elif field_name in ('created_from', 'last_editor'):\n return ONLY_REFERENCE\n update_the_serializer(obj, field_name)\n\n @classmethod\n def post_save(cls, initial_obj, obj, request=None):\n super(PageClone, cls).post_save(initial_obj, obj, request=request)\n initial_page = obj.created_from.website.initial_page\n if initial_page and obj.slug == initial_page.slug:\n obj.website.initial_page = obj\n obj.website.save()\n\n\n def clone_website(website, format='python'):\n walking_classes = {WebSite: WebSiteClone,\n Page: PageClone,\n User: BaseMetaWalkClass}\n natural_keys = True\n fixtures = serializer(format, website,\n walking_classes=walking_classes,\n natural_keys=natural_keys)\n return deserializer(format, fixtures,\n initial_obj=website,\n walking_classes=walking_classes,\n natural_keys=natural_keys)\n\nYou can see a real example in `moocng project `_\n\nDevelopment\n===========\n\nYou can get the last bleeding edge version of django-deep-serializer by doing a clone\nof its git repository::\n\n git clone https://github.com/goinnn/django-deep-serializer\n\n\nTest project\n============\n\nIn the source tree, you will find a directory called 'example'. It contains\na readily setup project that uses django-deep-serializer. You can run it as usual:\n\n::\n\n python manage.py syncdb --noinput\n python manage.py loaddata app_data.json\n python manage.py runserver\n\n\nReleases\n========\n\n0.1.3 (2014-10-13)\n-------------------\n* Support to Django 1.7\n\n0.1.2 (2013-11-14)\n------------------\n\n* Little details\n\n0.1.1 (2013-11-13)\n------------------\n\n* Add tests to django 1.6\n* Update the django 1.5 version, from 1.5.4 to 1.5.5\n\n0.1.0 (2013-11-05)\n------------------\n\n* Fix a bug when you deserializer and the format to the fixtures was XML\n* Add message when raise exceptions\n* Improvements in the serialization form in the example project\n* Fix a little error when you serialized and the format was python\n* Reorder and refactor the code. **There are backward incompatible changes** like reorder of the params of the methods\n* Improvements in the tests\n\n\n\n0.0.1 (2013-10-29)\n------------------\n\n* Initial version",
"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/goinnn/django-deep-serializer",
"keywords": "django,serializer,deep,deep serializer,deserialize,deep deserialize",
"license": "LGPL 3",
"maintainer": null,
"maintainer_email": null,
"name": "django-deep-serializer",
"package_url": "https://pypi.org/project/django-deep-serializer/",
"platform": "UNKNOWN",
"project_url": "https://pypi.org/project/django-deep-serializer/",
"project_urls": {
"Download": "UNKNOWN",
"Homepage": "https://github.com/goinnn/django-deep-serializer"
},
"release_url": "https://pypi.org/project/django-deep-serializer/0.1.3/",
"requires_dist": null,
"requires_python": null,
"summary": "Serialize/Deserialize an object and its relations through class definitions",
"version": "0.1.3"
},
"last_serial": 1268862,
"releases": {
"0.0.1": [
{
"comment_text": "",
"digests": {
"md5": "d2204edfbfef2038251a4cb21ca0d705",
"sha256": "c57eb01265e1a75833fa6d60011e79cab7f8d86fd0f1ddc75007ee2372cb24c2"
},
"downloads": -1,
"filename": "django-deep-serializer-0.0.1.tar.gz",
"has_sig": false,
"md5_digest": "d2204edfbfef2038251a4cb21ca0d705",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 21649,
"upload_time": "2013-10-29T10:50:24",
"url": "https://files.pythonhosted.org/packages/61/45/e054d5a4eccda518b7eb0f5a39bfe1518b8ce499469416d9de92752a7a47/django-deep-serializer-0.0.1.tar.gz"
}
],
"0.1.0": [
{
"comment_text": "",
"digests": {
"md5": "fbae5ef8fd557db507e32d22b8cd746e",
"sha256": "e6164332ce8161538bd99692e7296aa007222b06d192917d085ac7d3d0cd7bf0"
},
"downloads": -1,
"filename": "django-deep-serializer-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "fbae5ef8fd557db507e32d22b8cd746e",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 22502,
"upload_time": "2013-11-05T11:07:55",
"url": "https://files.pythonhosted.org/packages/d5/19/280fbb4ede471c17cb266c381b12791f2b0c67d3dd83c2d531157d5c2e24/django-deep-serializer-0.1.0.tar.gz"
}
],
"0.1.1": [
{
"comment_text": "",
"digests": {
"md5": "f33473b5956ac7dbdca3570670ad7846",
"sha256": "03474eb0148a459610b8754f27e25261c8909d20823911aa8304e8566a54bce0"
},
"downloads": -1,
"filename": "django-deep-serializer-0.1.1.tar.gz",
"has_sig": false,
"md5_digest": "f33473b5956ac7dbdca3570670ad7846",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 22686,
"upload_time": "2013-11-13T16:08:48",
"url": "https://files.pythonhosted.org/packages/d7/87/65b40109f31c0bcc13dbca4e1df611b10a8191d40ed46db5b25e43387a3f/django-deep-serializer-0.1.1.tar.gz"
}
],
"0.1.2": [
{
"comment_text": "",
"digests": {
"md5": "1058c875e116fd596f258d6ca6a2cb7e",
"sha256": "0600d8519786a1c2e1562c1ac8cfc2f0d548127faeb6618740978c999b088e31"
},
"downloads": -1,
"filename": "django-deep-serializer-0.1.2.tar.gz",
"has_sig": false,
"md5_digest": "1058c875e116fd596f258d6ca6a2cb7e",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 22721,
"upload_time": "2013-11-14T19:22:16",
"url": "https://files.pythonhosted.org/packages/ee/ae/5e32ec415e26c04e9d5537f1c77c1ed50598916d5905273c1ab1306d8f40/django-deep-serializer-0.1.2.tar.gz"
}
],
"0.1.3": [
{
"comment_text": "",
"digests": {
"md5": "532d138549bff2e4b73a1ce25a08d690",
"sha256": "7054f4d51f345748a52d2b867431040657421de74c6d2c8623082fdfb7d418d0"
},
"downloads": -1,
"filename": "django-deep-serializer-0.1.3.tar.gz",
"has_sig": false,
"md5_digest": "532d138549bff2e4b73a1ce25a08d690",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 22796,
"upload_time": "2014-10-13T16:17:23",
"url": "https://files.pythonhosted.org/packages/37/9a/5a2221c42bdc42ccf5b7621b72b6fd48023e0fee224f1ff725c2157c12f9/django-deep-serializer-0.1.3.tar.gz"
}
]
},
"urls": [
{
"comment_text": "",
"digests": {
"md5": "532d138549bff2e4b73a1ce25a08d690",
"sha256": "7054f4d51f345748a52d2b867431040657421de74c6d2c8623082fdfb7d418d0"
},
"downloads": -1,
"filename": "django-deep-serializer-0.1.3.tar.gz",
"has_sig": false,
"md5_digest": "532d138549bff2e4b73a1ce25a08d690",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 22796,
"upload_time": "2014-10-13T16:17:23",
"url": "https://files.pythonhosted.org/packages/37/9a/5a2221c42bdc42ccf5b7621b72b6fd48023e0fee224f1ff725c2157c12f9/django-deep-serializer-0.1.3.tar.gz"
}
]
}