def _wrap(func_name):
        def wrapped(self, **kwargs):
            shards = self.model._shards
            try:
                key = shards.get_key_from_kwargs(**kwargs)
            except __HOLE__:
                raise AssertionError('You must filter on %s before expanding a QuerySet on %s models.' % (
                    shards.key, self.model.__name__))

            return getattr(self.get_query_set(key=int(key)), func_name)(**kwargs)

        wrapped.__name__ = func_name
        return wrapped
dataset/ETHPy150Open disqus/sharding-example/sqlshards/db/shards/manager.py/MasterPartitionManager._wrap