> Does anyone have any advice or thoughts, and/or can > point me to some > towards some example code? >
For my latest projects, I used a 'shared state' class instead of a classic 'singleton' pattern. It is described here (called 'BORG' in this write-up by Alex Martelli): http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66531 The trick is to create one instance of it, give it whatever default attributes you want to use (I have a configuration file that I change machine to machine or project to project), and then store a reference to the object in the APPLICATION object of Webware so that the reference count remains at 1 (minimum) until your app server goes down. My initialize code looks like this: if not self.application().__dict__.get("waldo", 0): self.application().waldo = Waldo(self._projectConfiguration) Then after that, any new instance of the object will have the same attributes/values because of the shared dictionary state. Very similar in concept to the Singleton, but there are instead multiple instances of the object working off one set of data. Waldo is the name of the class... just an arbitrary name for the framework I created (my acronym'ing needs work: Web Application Lazy Data Objects?). Waldo started off looking like this class Waldo: __shared_state = { # shared state: all instances share the same data 'dbPool': None, 'formRegistry': None, 'mutexDir': '', 'dbHost': '', 'dbName': '', 'dbUser': '', 'dbPass': '', } def __init__(self, configuration=None): # configure only once during Application's life self.__dict__ = self.__shared_state # BORG class: all class instances share the same data if configuration: self.__dict__.update(configuration) # update Borg w/ App. specific config data I can give your more info of what I did specifically, if you decide to go this route... but if not, I will save my breath ;) good luck, Ian Maurer __________________________________________________ Yahoo! - We Remember 9-11: A tribute to the more than 3,000 lives lost http://dir.remember.yahoo.com/tribute ------------------------------------------------------- This sf.net email is sponsored by: OSDN - Tired of that same old cell phone? Get a new here for FREE! https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390 _______________________________________________ Webware-discuss mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/webware-discuss
