B
Batista, Facundo
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
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