def load_all(startswith=None): if startswith: start = startswith end = startswith + '~' candids = DBResource.bucket.get_index("$key", start, end).results else: candids = DBResource.updated.filter(StrInt.p_min(), StrInt.p_max()) return [Resource(r) for r in DBResource.multi_get(candids)]
def load_updated(since=None, with_childs=True): if since is None: startkey = StrInt.p_min() else: startkey = since candids = DBResource.updated.filter(startkey, StrInt.p_max()) if with_childs: candids = DBResource.childs(candids) return [Resource(r) for r in DBResource.multi_get(candids)]
def test_updated_behaviour(rk): k1 = next(rk) _cmp = StrInt() r1 = create_resource(k1, {'name': 'blah'}) r1.save() assert isinstance(r1._riak_object.data['updated'], basestring) assert not isinstance(r1.updated, basestring) assert r1.updated >= _cmp assert k1 in Resource.updated.filter(StrInt.p_min(), StrInt.p_max())
def test_updated_only_last(rk): for i in range(3): r = create_resource(next(rk), {'name': str(i)}) r.save() assert Resource.updated.filter(r.updated, StrInt.p_max()) == [r.key]
def load_all(): candids = DBResource.updated.filter(StrInt.p_min(), StrInt.p_max()) return [Resource(r) for r in DBResource.multi_get(candids)]