Re: Multiple modules with database access + general app design?

2006-01-20 Thread Daniel Dittmar
Frank Millman wrote: I have subclassed threading.Thread, and I store a number of attributes within the subclass that are local to the thread. It seems to work fine, but according to what you say (and according to the Python docs, otherwise why would there be a 'Local' class) there must be some

Re: Multiple modules with database access + general app design?

2006-01-20 Thread Frank Millman
Daniel Dittmar wrote: Frank Millman wrote: I have subclassed threading.Thread, and I store a number of attributes within the subclass that are local to the thread. It seems to work fine, but according to what you say (and according to the Python docs, otherwise why would there be a

Multiple modules with database access + general app design?

2006-01-19 Thread Robin Haswell
Hey people I'm an experience PHP programmer who's been writing python for a couple of weeks now. I'm writing quite a large application which I've decided to break down in to lots of modules (replacement for PHP's include() statement). My problem is, in PHP if you open a database connection it's

Re: Multiple modules with database access + general app design?

2006-01-19 Thread Paul McGuire
Robin Haswell [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hey people I'm an experience PHP programmer who's been writing python for a couple of weeks now. I'm writing quite a large application which I've decided to break down in to lots of modules (replacement for PHP's

Re: Multiple modules with database access + general app design?

2006-01-19 Thread Robin Haswell
On Thu, 19 Jan 2006 12:23:12 +, Paul McGuire wrote: Robin Haswell [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hey people I'm an experience PHP programmer who's been writing python for a couple of weeks now. I'm writing quite a large application which I've decided to break

Re: Multiple modules with database access + general app design?

2006-01-19 Thread Daniel Dittmar
Robin Haswell wrote: cursor for every class instance. This application runs in a very simple threaded socket server - every time a new thread is created, we create a new db.cursor (m = getattr(modules, module)\n m.c = db.cursor() is the first part of the thread), and when the thread finishes

Re: Multiple modules with database access + general app design?

2006-01-19 Thread Robin Haswell
On Thu, 19 Jan 2006 14:37:34 +0100, Daniel Dittmar wrote: Robin Haswell wrote: cursor for every class instance. This application runs in a very simple threaded socket server - every time a new thread is created, we create a new db.cursor (m = getattr(modules, module)\n m.c = db.cursor() is

Re: Multiple modules with database access + general app design?

2006-01-19 Thread Frank Millman
Robin Haswell wrote: Hey people I'm an experience PHP programmer who's been writing python for a couple of weeks now. I'm writing quite a large application which I've decided to break down in to lots of modules (replacement for PHP's include() statement). My problem is, in PHP if you open

Re: Multiple modules with database access + general app design?

2006-01-19 Thread Daniel Dittmar
Robin Haswell wrote: On Thu, 19 Jan 2006 14:37:34 +0100, Daniel Dittmar wrote: If you use a threading server, you can't put the connection object into the module. Modules and hence module variables are shared across threads. You could use thread local storage, but I think it's better to pass

Re: Multiple modules with database access + general app design?

2006-01-19 Thread Robin Haswell
On Thu, 19 Jan 2006 15:43:58 +0100, Daniel Dittmar wrote: Robin Haswell wrote: On Thu, 19 Jan 2006 14:37:34 +0100, Daniel Dittmar wrote: If you use a threading server, you can't put the connection object into the module. Modules and hence module variables are shared across threads. You could

Re: Multiple modules with database access + general app design?

2006-01-19 Thread Robin Haswell
On Thu, 19 Jan 2006 06:38:39 -0800, Frank Millman wrote: Robin Haswell wrote: Hey people I'm an experience PHP programmer who's been writing python for a couple of weeks now. I'm writing quite a large application which I've decided to break down in to lots of modules (replacement for

Re: Multiple modules with database access + general app design?

2006-01-19 Thread Magnus Lycka
Robin Haswell wrote: Can anyone give me advice on making this all a bit more transparent? I guess I really would like a method to bring all these files in to the same scope to make everything seem to be all one application, even though everything is broken up in to different files. This is

Re: Multiple modules with database access + general app design?

2006-01-19 Thread Daniel Dittmar
Robin Haswell wrote: Ah I see.. sounds interesting. Is it possible to make any module variable local to a thread, if set within the current thread? Not directly. The following class tries to simulate it (only in Python 2.4): import threading class ThreadLocalObject (threading.local):

Re: Multiple modules with database access + general app design?

2006-01-19 Thread Frank Millman
Daniel Dittmar wrote: Robin Haswell wrote: Ah I see.. sounds interesting. Is it possible to make any module variable local to a thread, if set within the current thread? Not directly. The following class tries to simulate it (only in Python 2.4): import threading class