CGI vs WSGI

2007-07-04 Thread tuom . larsen
Dear all, what is the difference? Middleware? I'm wondering because the only variables I ever needed were PATH_INFO, REQUEST_METHOD, QUERY_STRING and maybe one more, all of which should be available from CGI, too. Thanks. -- http://mail.python.org/mailman/listinfo/python-list

Thread-safe dictionary

2007-05-10 Thread tuom . larsen
Hi, please consider the following code: from __future__ import with_statement class safe_dict(dict): def __init__(self, *args, **kw): self.lock = threading.Lock() dict.__init__(self, *args, **kw) def __getitem__(self, key): with self.lock: return dict

Re: Thread-safe dictionary

2007-05-10 Thread tuom . larsen
On May 10, 3:57 pm, Duncan Booth <[EMAIL PROTECTED]> wrote: > IMHO you are probably best to write a thread-safe class which uses an > ordinary dict (and has a nicely limited interface) rather than trying to > produce a completely thread-safe dict type. thanks, sounds good! but that again: from

Re: Thread-safe dictionary

2007-05-10 Thread tuom . larsen
On May 10, 8:25 pm, [EMAIL PROTECTED] wrote: instead: > class safe_dict(dict): there should be: class safe_dict(object): -- http://mail.python.org/mailman/listinfo/python-list

Re: Thread-safe dictionary

2007-05-12 Thread tuom . larsen
On May 12, 11:40 am, "Martin v. Löwis" <[EMAIL PROTECTED]> wrote: > > - in __getitem__, does it release the lock after returning the item? > > Yes, it does. > > > - wouldn't it be better to use threading.RLock, mutex, ... instead? > > Better in what sense? Performance-wise? Semantically? Performanc

state machine and a global variable

2007-12-14 Thread tuom . larsen
Dear list, I'm writing very simple state machine library, like this: _state = None def set_state(state): global _state _state = state def get_state(): print _surface but I hate to use global variable. So, please, is there a better way of doing this? All I want is that a user has

Re: state machine and a global variable

2007-12-14 Thread tuom . larsen
On Dec 14, 7:35 pm, Matimus <[EMAIL PROTECTED]> wrote: > On Dec 14, 8:52 am, [EMAIL PROTECTED] wrote: > > > > > Dear list, > > I'm writing very simple state machine library, like this: > > > _state = None > > > def set_state(state): > > global _state > > _state = state > > > def get_state()

Re: state machine and a global variable

2007-12-14 Thread tuom . larsen
On Dec 14, 11:06 pm, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] a écrit : > > > Dear list, > > I'm writing very simple state machine library, like this: > > > _state = None > > > def set_state(state): > > global _state > > _state = state > > > def get_state(): > >

Re: state machine and a global variable

2007-12-14 Thread tuom . larsen
On Dec 15, 12:02 am, "Chris Mellon" <[EMAIL PROTECTED]> wrote: > On Dec 14, 2007 4:43 PM, <[EMAIL PROTECTED]> wrote: > > > > > On Dec 14, 11:06 pm, Bruno Desthuilliers > > <[EMAIL PROTECTED]> wrote: > > > [EMAIL PROTECTED] a écrit : > > > > > Dear list, > > > > I'm writing very simple state machin

Re: state machine and a global variable

2007-12-15 Thread tuom . larsen
On Dec 15, 1:50 am, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Fri, 14 Dec 2007 23:06:28 +0100, Bruno Desthuilliers wrote: > > Now the question is: why do you think it's so important for your users > > to only see functions ? What's so wrong with: > > > from state_machine im