Metadata-Version: 1.0
Name: riak-docs
Version: 0.1.3
Summary: Models to facilitate some common interactions with Riak documents.
Home-page: https://bitbucket.org/danostrowski/riakdocs
Author: Dan Ostrowski
Author-email: dan.ostrowski@gmail.com
License: BSD
Description: Riak Docs
        =========
        
        This is a little module to save me time by modeling Riak docs and then providing common operations.
        
        It is nowhere near complete and is probably unsuitable for whatever you want to do. Do NOT use this in production
        unless you know what you're doing and by that I mean: you're me.
        
        Example Usage
        =============
        
            :::python
            from riakdoc.documents import BaseDocument
            from riakdoc.indexes import StrFieldsIndex
            from blinker import signal
        
            class MyDoc(BaseDocument):
                """
                Create a Riak document that:
                    1. Automatically creates a 2i index called "complex_index" which holds an id and category as {id}_{cat}
                    2. Initializes data if created without data.
                """
                complex_index = StrFieldsIndex(['id', 'person.category'])
        
                def initialize_data(self, *args, **kwargs):
                    # Extra args/kwargs are passed to the initialize_data call, making it easy to pass data to help init docs.
                    return {'id': self.key, 'violations': [], 'tag': kwargs.get('tag', '')}
        
            # Listen for the post save event, but only from MyDoc, and then print.
            def announce(sender, **kwargs):
                print "just saved: {0}".format(kwargs.pop('document').data)
            signal('post-document save').connect(announce, sender=MyDoc)
        
            doc = MyDoc('abc1', tag='noodle')
            # Doc can be accessed like a dict since initialize_data(), above, returns a dict.
            doc['person'] = {'category': 'engineer'}
            print doc.complex_index                        # prints "abc1_engineer"
            doc.save()                                     # stores to Riak, prints "just saved: {'id': 'abc1', 'tag': 'noodle', 'person': ..."
Keywords: riak models object
Platform: UNKNOWN
Classifier: Programming Language :: Python :: 2.5
Classifier: Programming Language :: Python :: 2.6
Classifier: Programming Language :: Python :: 2.7
Classifier: Development Status :: 3 - Alpha
Classifier: License :: OSI Approved :: MIT License
Classifier: Intended Audience :: Developers
Classifier: Topic :: Database
Classifier: Topic :: Software Development :: Libraries :: Python Modules
