This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

A versioned object is a specialized data container, capable of representing data when the schema for that data has gone through several different revisions. This is useful when loading data from a data store which may have older versions of the data, such as a file or a database.

To declare a versioned class, create a class extending VObject; then, declare one or more Schema classes within that class, i.e.:

class Employee(VObject):
    class Version1(Schema):
        __version__ = 1

        first = Attribute()
        last = Attribute()
        salary = Attribute(0, validate=int)

To create a new object of this class, simply pass keyword arguments to the constructor matching the attributes:

>>> worker = Employee(first='Kevin', last='Mitchell', salary=15)

The data is available as attributes of the object:

>>> worker.first
'Kevin'
>>> worker.salary
15

Eventually, you will discover changes that need to be made to this schema, such as the fact that some cultures do not use first or last names. To alter the schema for this, we’ll create a new “name” attribute and drop the “first” and “last” attributes. We also need an upgrader to convert values from the old schema to the new:

class Employee(VObject):
    class Version1(Schema):
        __version__ = 1

        first = Attribute()
        last = Attribute()
        salary = Attribute(0, validate=int)

    class Version2(Version1):
        # __version__ is automatically incremented here, but you
        # can set it explicitly

        name = Attribute()

        # salary is inherited, but so are first and last, so we
        # need to mask them...
        first = None
        last = None

        # And we need an upgrader...
        @upgrader
        def _upgrade_from_1(cls, state):
            state['name'] = '%s %s' % (state['first'], state['last'])
            del state['first']
            del state['last']
            return state

Versioned objects implement the pickle protocol, so that they can be pickled and unpickled. The pickle protocol implementation allows older versions of the object to be converted into the newer version. It is also possible to convert versioned objects directly to and from dictionaries, allowing any serialization mechanism to be used.

Release History

Release History

0.2.0

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
vobj-0.2.0.tar.gz (23.5 kB) Copy SHA256 Checksum SHA256 Source Apr 13, 2014

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting