Example #1
0
    def handle(self):
        data = loads(self.request.input.data.decode('base64').decode('bz2'))
        with self.server.kvdb.conn.pipeline() as p:
            p.delete(KVDB.DICTIONARY_ITEM_ID)
            p.delete(KVDB.DICTIONARY_ITEM)
            p.delete(KVDB.TRANSLATION_ID)

            for item in self._get_translations():
                key = translation_name(item['system1'], item['key1'], item['value1'], item['system2'], item['key2'])
                p.delete(key)

            # Another proof software engineering and philosophy have /a lot/ in common!
            data = data['data']

            p.set(KVDB.DICTIONARY_ITEM_ID, data['last_dict_id'])

            if data['last_translation_id']:
                p.set(KVDB.TRANSLATION_ID, data['last_translation_id'])

            for item in data['dict_list']:
                p.hset(KVDB.DICTIONARY_ITEM, item['id'], dict_item_name(item['system'], item['key'], item['value']))

            for item in data['translation_list']:
                key = item.keys()[0]
                for value_key, value in item[key].items():
                    p.hset(key, value_key, value)

            p.execute()
Example #2
0
 def handle(self):
     data = loads(self.request.input.data.decode('base64').decode('bz2'))
     with self.server.kvdb.conn.pipeline() as p:
         p.delete(KVDB.DICTIONARY_ITEM_ID)
         p.delete(KVDB.DICTIONARY_ITEM)
         p.delete(KVDB.TRANSLATION_ID)
         
         for item in self._get_translations():
             key = translation_name(item['system1'], item['key1'], item['value1'], item['system2'], item['key2'])
             p.delete(key)
             
         # Another proof software engineering and philosophy have /a lot/ in common!
         data = data['data'] 
         
         p.set(KVDB.DICTIONARY_ITEM_ID, data['last_dict_id'])
         p.set(KVDB.TRANSLATION_ID, data['last_translation_id'])
         
         for item in data['dict_list']:
             p.hset(KVDB.DICTIONARY_ITEM, item['id'], dict_item_name(item['system'], item['key'], item['value']))
             
         for item in data['translation_list']:
             key = item.keys()[0]
             for value_key, value in item[key].items():
                 p.hset(key, value_key, value)
             
         p.execute()
Example #3
0
 def _get_item_name(self):
     return dict_item_name(self.request.input.system,
                           self.request.input.key, self.request.input.value)
Example #4
0
 def _get_item_name(self):
     return dict_item_name(self.request.input.system, self.request.input.key, self.request.input.value)