{ "info": { "author": "Christian Haintz", "author_email": "christian.haintz@orangelabs.at", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Software Development :: Pre-processors" ], "description": "================================================================\nFlatty - marshaller/unmarshaller for light-schema python objects\n================================================================\n\nIntroduction\n------------\n\n``Flatty`` is a microframework for easily creating flexible python class schemas.\nNormaly you will use flatty on top of marshallers which uses python dict as\ninput/output format. Think of couchdb, json, xml, yaml, etc. With flatty you can\neasily store an object-oriented class schema in these systems by just storing \nthe data (no meta-data is stored). \n\n**Key Features:**\n\n\t- easy to use\n\t- couchdb adapter to use flatty schemas with couchdb\n\t- only plain data is marshaled, no class meta-data\n\t- extensible, add custom converters for your own needs and types\n\t- can be easily extended to support unique features of a marshal framework \n\t- light-weight (flatty has currently less than 200 lines of code)\n\t- OpenSource BSD-licensed\n\t\n\n**Full documentation can be found on** `PyPi Flatty Documentation`_\n\n.. _`PyPi Flatty Documentation`: http://packages.python.org/flatty/index.html\n\n\nIdea behind Flatty\n------------------\n\nThe goal of Flatty is to provide a class-to-dict marshaller which stays in the\nbackground on top of other low-level marshallers. They might only support python \ndicts and some base types. \n\nWith Flatty you can build a complete class schema and\nmarshall/unmarshall (flatten/unflatten) high-level class objects to the low-level \nmarshaller which provides the persistence layer. \nA good example where Flatty already provides an \nadapter is couchdb. We tried to keep the schema definition as much as possible \n\"standard python\" and gather the needed information through inspection to keep \nthings easy. \n\nFlatty reduces everything to a simple dict, without storing metainformation in \nthe marshalled data. The marshalling process Flatty uses is simple:\nIt treats classes as dicts and their attributes as key-value pairs in the dict. \nLists are stored as lists. That's it.\n \n\n\t\nGetting started with Flatty\n---------------------------\n\n\tLet's go:\n\t\n\t>>> import flatty\n\n\tThis imports the flatty module. Now we can define a schema using python\n\tclasses:\n\t\t\n\t>>> class Bar(flatty.Schema):\n\t...\t a_num = int\n\t...\t a_str = str\n\t...\t a_thing = None \n\t\n\tThe class `Bar`has 3 attributes. `a_num` is typed as int, `a_str` as string\n\tand `a_thing` can be of any type. Types are checked during flattening and\n\tunflattening and couse a `TypeError` Exception if type does not fit.\n\t\n\t>>> class Foo(flatty.Schema):\n\t...\t my_typed_list = flatty.TypedList.set_type(Bar)\n\t\n\tThe class `Foo` defines just one attribute `my_typed_list`. As the name\n\tmight already explain, the type of this attribute is a list. It acts like a\n\tnormal python list (actually it is inherited from `list`) with one difference\n\tit only accepts items instances of type `Bar`.\n\t\n\t.. note::\n\t\n\t\tThe benefit of this \"strict\" typing with `TypedList` is that `Flatty` \n\t\tknows which types you expect and can create instances of class `Bar` during \n\t\tunflattening. Because flatty doesn't marshal type information it needs\n\t\tthis information during unmarshaling to restore the correct types \n\t\n\tYou can also use just a normal python list but when you unflat your data\n\tyou will just get \"classless\" items instead of `Bar` instances.\n\t\n\tThere is also a `TypedDict` to produce \"strict\" typed dicts\n\t \n\tNext we create some instances. You see we can use named arguments in the\n\tconstructor to fill the attributes.\n\t\n\t>>> my_bar = Bar(a_num=42, a_str='hello world', a_thing='whatever type here')\n\t>>> foo = Foo(my_typed_list=[my_bar,])\n\t\n\tNo we have `my_bar`added to the list of `foo`. \n\t\n\t.. note::\n\t\t\n\t\tAbove you can see that we use a python list (not `TypedList`) \n\t\t``my_typed_list=[my_bar,]``\tto create the `foo` instance with the \n\t\t`my_typed_list` attribute.\n\t\t\n\tFlatty, flat it!\n\t\n\t>>> flatted = foo.flatit()\n\t>>> print flatted\n\t{'my_typed_list': [{'a_num': 42, 'a_str': 'hello world', 'a_thing': 'whatever type here'}]}\n\t\n\tVoila, this is the flattened dictionary you get. \n\t\n\tPer default just instances\n\tof type `Schema`, `datetime`, `date`, `time` will be flattened. But if - \n\tfor example - your marshaller don't understand integers just strings\n\tyou can easily add a `Converter` for type `int` (see reference).\n\n\tThe `flatted` can now be stored using your favorite low-level marshaller\n\t(couchdb, json, yaml, xml, etc).\n\t\n\tNext we see how we can restore objects only using the flatted data and the\n\tschema.\n\n\t>>> restored_obj = Foo.unflatit(flatted)\n\t>>> isinstance(restored_obj, Foo)\n\tTrue\n\t>>> isinstance(restored_obj.my_typed_list[0], Bar)\n\tTrue\n\t>>> restored_obj.my_typed_list[0].a_num\n\t42\n\t\n\tThe restored_obj is a new object filled with the data of flatted\n\t\n\t\nBug Tracker\n-----------\n\nIf you find any issues please report them on https://github.com/ceelian/Flatty/issues\n\n\nGetting Flatty\n--------------\n\nYou can get the python package on the `Python Package Index`_\n\n.. _`Python Package Index`: http://pypi.python.org/pypi/flatty\n\nThe git repository is available at `github.com Flatty`_\n\n.. _`github.com Flatty`: https://github.com/ceelian/Flatty\n\n\nInstallation\n------------\n\n\n``Flatty`` can be installed via the Python Package Index of from source.\n\nUsing ``easy_install`` to install ``Flatty``::\n\n\t$ easy_install Flatty\n\n\nIf you have downloaded a source tarball you can install it\nby doing the following::\n\n $ python setup.py build\n $ python setup.py install\n\n\nSupported by\n------------\nWingware - The Python IDE (http://wingware.com)\n\nContributing\n------------\n\nWe are welcome everyone who wants to contribute to Flatty. \nDevelopment of Flatty happens at https://github.com/ceelian/Flatty\n\nLicense\n-------\n\nFlatty is released under the BSD License. \nThe full license text is in the root folder of the Flatty Package.", "description_content_type": null, "docs_url": "https://pythonhosted.org/flatty/", "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://packages.python.org/flatty", "keywords": "marshaller schema objectmapper couchdb mongodb orm", "license": "BSD", "maintainer": null, "maintainer_email": null, "name": "flatty", "package_url": "https://pypi.org/project/flatty/", "platform": "any", "project_url": "https://pypi.org/project/flatty/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://packages.python.org/flatty" }, "release_url": "https://pypi.org/project/flatty/0.1.2/", "requires_dist": null, "requires_python": null, "summary": "flatty - marshaller/unmarshaller for light-schema python objects", "version": "0.1.2" }, "last_serial": 792060, "releases": { "0.0.1dev": [ { "comment_text": "", "digests": { "md5": "46f79bb06e889025a3e6df6233f8de11", "sha256": "13a9801550e4efa7a44e5055efbfb96c0c1d9e8abf2c68140995dc40445412ea" }, "downloads": -1, "filename": "flatty-0.0.1dev.tar.gz", "has_sig": false, "md5_digest": "46f79bb06e889025a3e6df6233f8de11", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 305220, "upload_time": "2011-07-15T12:14:37", "url": "https://files.pythonhosted.org/packages/70/10/30efb384d7d9221f60fedf7183f971a245201b53cb5c1999689df1db048d/flatty-0.0.1dev.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "534a3801c6f508e3c28ec165f0c433f8", "sha256": "bccc7ec46b26232d05f490f35e3aedf6ef6f195e8feef0b04be0053e32732809" }, "downloads": -1, "filename": "flatty-0.1.1.tar.gz", "has_sig": false, "md5_digest": "534a3801c6f508e3c28ec165f0c433f8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 325494, "upload_time": "2011-07-15T21:18:33", "url": "https://files.pythonhosted.org/packages/69/6a/edab12614a4e982f22d1f069baaafd05570e82b323fb6ed6b5c3dd100cf0/flatty-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "6881439cbfbbce669c67e40a34742cd5", "sha256": "fd7f974dd7579e1524cd41fa8778f2c8f80b04a332f45a7e5f859423a7977d8e" }, "downloads": -1, "filename": "flatty-0.1.2.tar.gz", "has_sig": false, "md5_digest": "6881439cbfbbce669c67e40a34742cd5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 21456, "upload_time": "2012-01-13T19:14:47", "url": "https://files.pythonhosted.org/packages/5a/74/a30c2e29da54429119899a450cd86648a618d6211dbd4a83c1ae9bc254d0/flatty-0.1.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "6881439cbfbbce669c67e40a34742cd5", "sha256": "fd7f974dd7579e1524cd41fa8778f2c8f80b04a332f45a7e5f859423a7977d8e" }, "downloads": -1, "filename": "flatty-0.1.2.tar.gz", "has_sig": false, "md5_digest": "6881439cbfbbce669c67e40a34742cd5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 21456, "upload_time": "2012-01-13T19:14:47", "url": "https://files.pythonhosted.org/packages/5a/74/a30c2e29da54429119899a450cd86648a618d6211dbd4a83c1ae9bc254d0/flatty-0.1.2.tar.gz" } ] }