{ "info": { "author": "Kevin L. Mitchell", "author_email": "kevin.mitchell@rackspace.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Topic :: Database", "Topic :: Internet" ], "description": "=================\nVersioned Objects\n=================\n\nA versioned object is a specialized data container, capable of\nrepresenting data when the schema for that data has gone through\nseveral different revisions. This is useful when loading data from a\ndata store which may have older versions of the data, such as a file\nor a database.\n\nTo declare a versioned class, create a class extending ``VObject``;\nthen, declare one or more ``Schema`` classes within that class, i.e.::\n\n class Employee(VObject):\n class Version1(Schema):\n\t __version__ = 1\n\n\t first = Attribute()\n\t last = Attribute()\n\t salary = Attribute(0, validate=int)\n\nTo create a new object of this class, simply pass keyword arguments to\nthe constructor matching the attributes::\n\n >>> worker = Employee(first='Kevin', last='Mitchell', salary=15)\n\nThe data is available as attributes of the object::\n\n >>> worker.first\n 'Kevin'\n >>> worker.salary\n 15\n\nEventually, you will discover changes that need to be made to this\nschema, such as the fact that some cultures do not use first or last\nnames. To alter the schema for this, we'll create a new \"name\"\nattribute and drop the \"first\" and \"last\" attributes. We also need an\n*upgrader* to convert values from the old schema to the new::\n\n class Employee(VObject):\n class Version1(Schema):\n\t __version__ = 1\n\n\t first = Attribute()\n\t last = Attribute()\n\t salary = Attribute(0, validate=int)\n\n\tclass Version2(Version1):\n\t # __version__ is automatically incremented here, but you\n # can set it explicitly\n\n\t name = Attribute()\n\n\t # salary is inherited, but so are first and last, so we\n # need to mask them...\n\t first = None\n\t last = None\n\n\t # And we need an upgrader...\n\t @upgrader\n\t def _upgrade_from_1(cls, state):\n\t state['name'] = '%s %s' % (state['first'], state['last'])\n\t\tdel state['first']\n\t\tdel state['last']\n\t\treturn state\n\nVersioned objects implement the pickle protocol, so that they can be\npickled and unpickled. The pickle protocol implementation allows\nolder versions of the object to be converted into the newer version.\nIt is also possible to convert versioned objects directly to and from\ndictionaries, allowing any serialization mechanism to be used.", "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/klmitch/vobj", "keywords": null, "license": "Apache License (2.0)", "maintainer": null, "maintainer_email": null, "name": "vobj", "package_url": "https://pypi.org/project/vobj/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/vobj/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/klmitch/vobj" }, "release_url": "https://pypi.org/project/vobj/0.2.0/", "requires_dist": null, "requires_python": null, "summary": "Versioned Objects", "version": "0.2.0" }, "last_serial": 1058997, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "5ec957bff501fc0938c4b62e992308c2", "sha256": "6a22dd29a5c217f9a842201430cefd0f531b919bd6aa9a2692bc21a2427a1041" }, "downloads": -1, "filename": "vobj-0.1.0.tar.gz", "has_sig": false, "md5_digest": "5ec957bff501fc0938c4b62e992308c2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15711, "upload_time": "2013-05-18T23:00:55", "url": "https://files.pythonhosted.org/packages/3f/cb/7bebd9b9406f71c6b502ea61be06564ceb3fd665745f3338f5d45a3030e7/vobj-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "37782166fb8fcab06cd02f5fd63a8914", "sha256": "f8c6731ce7d694fbd4c6f2c2a031455e2c534c4b12883baad3d29bbabfcbd18a" }, "downloads": -1, "filename": "vobj-0.1.1.tar.gz", "has_sig": false, "md5_digest": "37782166fb8fcab06cd02f5fd63a8914", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15718, "upload_time": "2013-05-18T23:04:46", "url": "https://files.pythonhosted.org/packages/de/9e/5f5c96a8fd8d86bc1846c3518ec13230611c00ebdf515293c8777e7f7173/vobj-0.1.1.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "42cc3188430c03b72ba6afcc1c206b64", "sha256": "1a9f72dc3df780ccaac372d1144928f5818b9c934fe398231aeb888d7376ae5d" }, "downloads": -1, "filename": "vobj-0.2.0.tar.gz", "has_sig": false, "md5_digest": "42cc3188430c03b72ba6afcc1c206b64", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 23468, "upload_time": "2014-04-13T07:44:59", "url": "https://files.pythonhosted.org/packages/cb/68/3a0ce30cb591f5a5f854541795747808cdacbdfad63e73f45abd67f4969c/vobj-0.2.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "42cc3188430c03b72ba6afcc1c206b64", "sha256": "1a9f72dc3df780ccaac372d1144928f5818b9c934fe398231aeb888d7376ae5d" }, "downloads": -1, "filename": "vobj-0.2.0.tar.gz", "has_sig": false, "md5_digest": "42cc3188430c03b72ba6afcc1c206b64", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 23468, "upload_time": "2014-04-13T07:44:59", "url": "https://files.pythonhosted.org/packages/cb/68/3a0ce30cb591f5a5f854541795747808cdacbdfad63e73f45abd67f4969c/vobj-0.2.0.tar.gz" } ] }