33:9dfe8668e7fe
Anton Shestakov <engored@ya.ru>, Thu, 21 Mar 2013 16:04:47 +0900
Update Underscore (1.4.3), Backbone (1.0.0) and Shard.

next change 96:5e7f52c8da36
previous change 7:5c5d433b3a14

fruitbar/indexes.py

Permissions: -rw-r--r--

Other formats: Feeds:
#-*- coding:utf-8 -*-
from hashlib import md5
from CodernityDB.hash_index import HashIndex
class ProjectIndex(HashIndex):
def __init__(self, *args, **kwargs):
kwargs['key_format'] = '16s'
super(ProjectIndex, self).__init__(*args, **kwargs)
def make_key_value(self, data):
if data['_t'] == 'project':
return md5(data['workspace'].encode('utf-8')).digest(), None
def make_key(self, key):
return md5(key).digest()
class TaskIndex(HashIndex):
def __init__(self, *args, **kwargs):
kwargs['key_format'] = '16s'
super(TaskIndex, self).__init__(*args, **kwargs)
def make_key_value(self, data):
if data['_t'] == 'task':
return md5(data['workspace'].encode('utf-8')).digest(), None
def make_key(self, key):
return md5(key).digest()
def run_delete_for_project(self, db, workspace, project_id):
for task in db.get_many('task', workspace, with_doc=True):
if task['doc']['project_id'] == project_id:
db.delete(task['doc'])