Metadata-Version: 1.0
Name: pez
Version: 0.0.2
Summary: PEZ - Python P(r)e-(Seriali)z(ation)
Home-page: https://github.com/balanced/pez
Author: Balanced
Author-email: dev@balancedpayments.com
License: UNKNOWN
Description: # PEZ - Python P(r)e-(Seriali)z(ation)
        
        A python library for serializing python objects from their internal
        representation to something that can be displayed externally. e.g. This will
        transform a python object into a dictionary.
        
        This can include mapping field names, transforming, and selectively displaying
        data.
        
        [![Build Status](https://secure.travis-ci.org/balanced/pez.png?branch=master)](http://travis-ci.org/balanced/pez)
        
        ## Installation
        
            pip install pez
        
        ## Example
        
            import pez
            import json
        
            # Your internal object e.g. a model
            class Internal(object):
                field1 = 123
        
                field2 = 1
                field3 = 2
        
            # How you want to expose the model to the world
            class InternalView(pez.FieldMapping):
                # pez.Field echos the object as it is.
                field1 = pez.Field()
        
                # A static method such as this can allow you to customize the data
                # returned.
                @staticmethod
                def calculated_field(ctx, o):
                    return o.field2 + o.field3
        
        
            # create an instance of the serialize and map views to models via the
            # register method
            pre_serialize = pez.Serializer()
            pre_serialize.register(Internal, InternalView())
        
            # calling our serializer with an instance of a class will return a
            # serializable object (e.g. a dictionary)
            pre_serialize(Internal())
        
        
        See `./examples/` for more examples including how to use with an ORM, how to
        use with Flask, and other more advanced use cases.
        
        
        ## Why
        
        PEZ allows you to separate the internal representation of data from your
        external view. This is handy for all sorts of scenarios:
        
        * Renaming internal fields without breaking external interfaces
        * Hiding or transforming internal data when exposing it
        * Adding information to views that doesn't belong in your data models, e.g. URL information
        
        ## Contributing
        
        1. Fork it
        2. Create your feature branch (`git checkout -b my-new-feature`)
        3. Write your code **and unit tests**
        4. Ensure all tests still pass (`nosetests`)
        5. [PEP8](http://pypi.python.org/pypi/pep8) your code
        6. Commit your changes (`git commit -am 'Add some feature'`)
        7. Push to the branch (`git push origin my-new-feature`)
        8. Create new pull request
        
Platform: UNKNOWN
