예제 #1
0
def tear_down():
	# Teardown db
	from heinzel.core import connection
	conn = connection.connect()
	conn.close()

	from heinzel.core.queries import storage as store
	store.clear()

	if os.path.exists(os.path.abspath("test.db")):
		os.remove("test.db")
예제 #2
0
	def __init__(self, relation, master, identifier, slaves, db=None):
		self.relation = relation
		self.master = master
		self.identifier = identifier

		# slaves is a list of instances, whose relation to self.master will be
		# deleted from the linker table. If slaves is empty, all relations 
		# that self.master has to other instances in this linker table, will be 
		# deleted.
		self.slaves = slaves

		self.db = db or connection.connect()

		self.table = link_table_name(MODES[self.relation.mode],
			self.relation.model.tablename(), self.relation.identifier,
			self.relation.related_model.tablename()
		)
예제 #3
0
	def __init__(self, relation, master, identifier, slaves, db=None):
		self.relation = relation

		self.master = master
		self.identifier = identifier
		
		assert (self.relation.has_identity(type(self.master), self.identifier))
		
		self.slaves = slaves

		self.db = db or connection.connect()

		self.table = link_table_name(
			MODES[self.relation.mode], self.relation.model.tablename(),
			self.relation.identifier, self.relation.related_model.tablename()
		)

		self.db_columns = self.db.table_registry[self.table].columns
예제 #4
0
	def __init__(self, model, db=None):
		self.model = model
		self.db_table = model.tablename()
		self.db = db or connection.connect()
		self.db_columns = self.db.table_registry[self.db_table].columns
예제 #5
0
	def __init__(self, relation, db=None):
		self.relation = relation
		self.db = db or connection.connect()
예제 #6
0
	def closeDB(self):
		from heinzel.core import connection
		conn = connection.connect()
		conn.close()
예제 #7
0
	def __init__(self, model, store=None, query=None, db=None):
		self.model = model
		self.store = store or storage
		self.query = query or SelectQuery(model, db)
		self.db = db or connection.connect()