tags:

views:

90

answers:

1

http://www.slideshare.net/zeeg/djangocon-2010-scaling-disqus

Vertical partitioning helper:

class ApplicationRouter(object)

    def db_for_read(self, model, **hints):

        instance = hints.get('instance')

        if not instance:
            return None

        app_label = instance._meta.app_label

        return get_application_alias(app_label)

Can someone explain what this is doing?

Now this is for horizontal partitioning:

class ForumPartitionRouter(object):

    def db_for_read(self, model, **hints):

        instance = hints.get('instance')

        if not instance:
            return None

        forum_id = getattr(instance, 'forum_id', None)

        if not forum_id:
            return None

        return get_forum_alias(forum_id)

I sort of understand what these are doing, but not sure what some of the lines are doing like:

instance = hints.get('instance')