Manuel de la Pena  committed 3962ac7

Fixed code according to reviews.

  • Participants
  • Parent commits cfd42bd

Comments (0)

Files changed (1)

File conversa/daemon/dal/

 except ImportError:
     import pickle
+import abc
 import os
 from kyotocabinet import DB, Visitor
     id_regexp = '%(index_name)s_%(record_id)s'
-    def __init__(self, db, index):
+    def __init__(self, index):
         """Create a new instance."""
         super(IndexVisitor, self).__init__()
         self.index = index
-        self.db = db = {}
     def visit_full(self, key, value):
 class Index(object):
     """Base index class."""
+    __metaclass__ = abc.ABCMeta
     def __init__(self, index_name):
         """Creates a new index."""
         super(Index, self).__init__() = index_name
+    @abc.abstractmethod
     def map_func(self, key, obj):
         """Map function to be used."""
-        raise NotImplementedError('To be implemented by subclasses.')
 class ConversaDb(object):
             if data:
                 current_index = pickle.loads(data)
                 self.indexes[] = current_index
-            else:
-                pass
         return True
     def open(self):
     def _generate_index(self, index):
         """Generate the data for a given index."""
         # use the index as a visitor to generate the index data
-        visitor = IndexVisitor(self.db, index)
+        visitor = IndexVisitor(index)
         generated = self.db.iterate(visitor, False)
         if not generated:
             raise IndexCreationError('Index could not be created.')
             return added
         # loop over the indexes and decide if it was to be added
         for index in self.indexes.values():
-            visitor = IndexVisitor(self.db, index)
+            visitor = IndexVisitor(index)
             if self.db.accept(key, visitor, False):
                 # index accepts the obj and therefore we add it
     def _view_updated(self, result, view):
         """Callback excuted once a view has been updated."""
-    def upfate_view(self, name, map_func):
+    def update_view(self, name, map_func):
         """Update a view."""
     def _in_memory_view_done(self, result, view):