# Basic persistence and object database use import BoboPOS class Customer(BoboPOS.Persistent): "A persistent class" def __init__(self,name): self.name=name def set_favorite(self,food): self.favorite_food=food # open the object store db=BoboPOS.PickleDictionary("customers.bbb") # if amos is not already in the object store if not db.has_key("amos"): # create a Customer instance in the object store db["amos"]=Customer("Amos") # change an attribute of the persistent object db["amos"].set_favorite("spam") # commit the change get_transaction().commit() # prints "Amos' favorite food is spam" print "Amos' favorite food is", db["amos"].favorite_food
Bobo and Principia (Web Techniques, Feb 1999)
Related Reading
More Insights
INFO-LINK
To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy. | |