def __init__ (self, database, config):
		# Init the pymongo object
		Collection.__init__(self, database,
			config.get('db_phrases_collection','phrases_collection'))

		# Create logger
		self.logger = logging.getLogger(__name__)

		# Ensures the collection of documents is indexed by _id and subject
		self.logger.info("Ensuring indexes exist...")
		self.ensure_index('_id', unique = True, drop_dups = True)
		self.ensure_index('lc_subject')

		# Check phrase count
		try:
			count = self.count()
		except TypeError:
			# Count is not set, set it to a sane value
			self.database.info.save({'_id': self.counter_name, 'count': self.find_highest_id()})
		finally:
			self.logger.info("Collection {} loaded - {}: {}".format(
				self.full_name, self.counter_name, self.count()))

		# Initialise variables
		self.last = None
 def __init__(self, database, collection_name, type_conversion):
     self._type_conversion = type_conversion
     Collection.__init__(self, database, collection_name)
Exemple #3
0
 def __init__(self, *args, **kwargs):
     self.as_class = kwargs.pop('as_class')
     BaseCollection.__init__(self, *args, **kwargs)
 def __init__(self, *args, **kwargs):
     self.as_class = kwargs.pop('as_class')
     BaseCollection.__init__(self, *args, **kwargs)
Exemple #5
0
 def __init__(self, database, collection_name, type_conversion):
     self._type_conversion = type_conversion
     Collection.__init__(self, database, collection_name)