On Oct 28, 2003, at 6:10 PM, Nathan Seven wrote:
--- phil@bubblehouse.org wrote:
I'm using MySQLdb to interface with my sql server, but i'm not really sure what to do with my connection object once it's created. i want to put it somewhere that will be easy to access for the rest of the modules, but obviously i don't want it to be persisted when the TAP is saved....
.
Hmmm- well I'm just getting started here as well- but yeah, I don't remember any mentioned way of selectively removing state information for objects. I don't like the whole state-saving stuff at all- I'm doing atomic DB stuff, so my "state" above all is maintained on the DB itself. The Twisted clients are just basically dumb transaction handlers.
This is the way you should be doing it -- the only state in the tap should be configuration information about what services live on what ports, what directory the web server looks at, etc.
but i don't know how to make it so the connection object isn't persisted, but created new each time the server is started...
Hmmm- would a simple solution be to simply re-initialize the connection(s) upon any restart? (can a restart even be detected with .app?)
Since the tap is just a pickle, the easiest way to prevent certain objects from getting persisted is to implement a __getstate__ and __setstate__ for your class. See the python documentation for information. dp