riakkit, a python riak object mapper, has hit beta!

Andrey V. Martyanov realduke at gmail.com
Thu Mar 1 21:35:03 EST 2012


Two things force me to avoid using Riakkit: the code is GPL licensed and
non pep8 compliant. So, I cannot fork it and make changes. The code needs
clean up, for example, json module is imported in document.py, but not
used. Riakkit has no conflict resolution logic, it's basically delegate the
work to underlying python client. If I'd like to implement my save method I
need to copy and rewrite more than 150 lines of code mess. What I think the
mapper should do:
1. Serialize the objects to valid json;
2. Deserialize the data back to class instances;
3. Validate the fields data;
4. Track dependencies between models;

Simple example using Riakkit-like syntax;

class Post(Document):

    bucket_name  = 'posts'

    title = types.StringProperty(required=True)
    content = types.StringProperty(required=True)

class Comment(Document):

    bucket_name = 'comments'

    text = types.StringProperty(required=True)
    post = types.IndexReferenceProperty(reference_class=Post,

>>> post = Post('title', 'content')
>>> comment1 = ('comment1', post=post)
>>> comment2 = ('comment2', post=post)
>>> post.is_valid()
>> post.serialize()
    "key": "post_key",
    "title": "title",
    "content": "content",
    "comments": [
            "key": "comment1_key",
            "text": "comment1"
            "key": "comment2_key",
            "text": "comment2"
>>> post.store()
>>> post = Post.get_with_key('post_key')
>>> post.comments
['Post comment1', 'Post comment2']
>>> post_json_data = get_json_data_from_request()
>>> post = Post.deserialize(post_json_data)
>>> post.title
>>> post.comments
['Post comment1', 'Post comment2']

Something like that.

Best regards,
Andrey Martyanov

On Fri, Mar 2, 2012 at 5:39 AM, Sean Carey <carey at basho.com> wrote:

> Keep up the great work Shuhao!
> On Mar 1, 2012, at 7:36 PM, Shuhao Wu <admin at thekks.net> wrote:
> Hey guys,
> I started writing riakkit approximately 3 months ago and announced it
> here. In case you missed that, Riakkit is basically an object mapper for
> python and riak, which seemed to be lacking in at the time. Now that 3
> months has passed and I have developed this project into much more than
> what I had envisioned to begin with. It's currently also being used and
> tested in a project of mine (web application) as well and functioning quite
> nicely. I would say that currently this is the only object mapper that can
> compete with their counterparts in other languages for Riak in Python,
> although a lot of work still needs to be done before it could fully compete.
> So today I felt that riakkit is "stable" and "clean" enough to deserve the
> first beta release. So I whipped up a website and it's released to pypi.
> Here's (again), a demo (the full tutorial can be found on the links below)
> class User(Document):
>     client = riak.RiakClient()
>     bucket_name = "users"
>     name = StringProperty(required=True)
> >>> user = User(name="foo")
> >>> user.save()
> >>> print user.name
> foo
> If anyone is interested, you can find the website here:
> http://ultimatebuster.github.com/riakkit and the code at
> http://github.com/ultimatebuster/riakkit
> Cheers!
> Shuhao
> _______________________________________________
> riak-users mailing list
> riak-users at lists.basho.com
> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
> _______________________________________________
> riak-users mailing list
> riak-users at lists.basho.com
> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.basho.com/pipermail/riak-users_lists.basho.com/attachments/20120302/6ba3a75e/attachment.html>

More information about the riak-users mailing list