Auto persistency

Batista, Facundo FBatista at uniFON.com.ar
Tue Aug 5 07:24:00 EDT 2003


Example of class. Just an object between all of them in my program:


class Example:
	def __init__(self, value):
		self.value = value
		return

	def getValue(self):
		return self.value

	def setValue(self, value):
		self.value = value
		return 


I want to implement persistency. I think it's a good idea to each object be
the responsible of it's own persistence in a file, in a sql server, anywhere
(opinions?).

Adding persistence:

class Example:
	def __init__(self, value):
		self.value = value
		# create in sql server
		return

	def getValue(self):
		return self.value

	def setValue(self, value):
		self.value = value
		# modify in sql server
		return


Now I have two questions:

	1) How do I implement the dead of the object. I need it to erase
itself from the sql server. Should I define the __del__ method?

	2) When the program starts, how do I retrieve all the objects from
the sql server to memory? (considering that only the object knows how it's
persisted).

Thanks for all.


.	Facundo





More information about the Python-list mailing list