Esempio n. 1
0
	def getObjectsByKey(self, key, value, limit=None):
		""" This will retrieve documents from the database and collection specified by this object based on one of their keys and convert them to their proper Python object state.
		
		:param key: The key to select on.
		:param value: The value to search for.
		:param limit: The maximum amount of objects to return. Will return all results by default.
		:rtype: All the matching objects stored in the database.
		"""
		storage = Storage()
		database = self._database
		collection = self._collection
		
		if database is None or collection is None:
			raise ValueError, "The object needs to be assigned a database and a collection."
		
		storage.getDatabase(database)
		storage.getCollection(collection)
		documents = storage.getDocuments({key:value}, limit)
		
		objects = [ self.loadFromRawData( data ) for data in documents ]
		return objects