![]() # Let's limit the keys allowed on our dict-based class by adding a _schema_ # entry # class Foo ( dict ): _schema_ = # Now let's make sure this really works # try : Foo ( sneaky = 'git blame someone for this!' ) except AttributeError as exc : print "Thank you, Morpheus! You caught an error: %s " % exc # Prints: # Thank you, Morpheus! You caught an error: 'sneaky' is not a permitted # attribute for a 'Foo' # # Let's import MorpheusDict as dict in our module from morpheus import MorpheusDict as dict # Note: Comment this last line out to completely disable morpheus. Here is a simple example of a schema definition on a dict-based class. Passes all python tests for a dict (including json and pickle Generates schema documentation for developers and usersĭRY definition of schemas. Optional schema validation and inspection controlled globally or perĪutomatic or on-demand migration from an older schema to the current Intuitive schema definition using pythonic idioms NoSQL, etc…), so morpheus operates on native python dicts and doesn’t ![]() You get to pick which backend you use (sqlalchemy, sqlite, ![]() And you should be able to import morpheus or leave itįlexible. Schema definition should be readable and understandable. Like a docstring at the top of your class definition, a Make this normally unfun task painless and easy. Perform validation, migration, and generate documentation. Morpheus helps you define schemas for your dict-based classes and
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |