Setdefault bypasses __setitem__

2005-10-12 Thread Ron Garret
Is this a bug or a feature? class mydict(dict): def __setitem__(self, key, val): print 'foo' dict.__setitem__(self, key, val) >>> d=mydict() >>> d[1]=2 foo >>> d.setdefault(2,3) 3 rg -- http://mail.python.org/mailman/listinfo/python-list

Re: question about timestamp and MySQLdb

2005-10-19 Thread Ron Garret
In article <[EMAIL PROTECTED]>, "Sean Berry" <[EMAIL PROTECTED]> wrote: > I am using MySQLdb to connect to a database and retrieve a timestamp from a > table. The problem is I want the timestamp as a long, unformatted and all. > > In the table I have a timestamp like this > 20051019111617 > >

Re: Python! Is! Truly! Amazing!

2005-01-02 Thread Ron Garret
In article <[EMAIL PROTECTED]>, "Erik Bethke" <[EMAIL PROTECTED]> wrote: > > I have NEVER experienced this kind of programming joy. Just wait until you discover Lisp! ;-) rg -- http://mail.python.org/mailman/listinfo/python-list

Rebinding stdout (was: Re: Python! Is! Truly! Amazing!)

2005-01-02 Thread Ron Garret
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (Aahz) wrote: > In article <[EMAIL PROTECTED]>, > Roy Smith <[EMAIL PROTECTED]> wrote: > >In article <[EMAIL PROTECTED]>, > > Ron Garret <[EMAIL PROTECTED]> wrote: > >> In article &l

Re: Rebinding stdout

2005-01-02 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Mark McEahern <[EMAIL PROTECTED]> wrote: > Ron Garret wrote: > > > But this topic does bring up a legitimate question: I have a bunch of > > code that generates HTML using PRINT statements. I need to convert > > all thi

Re: Rebinding stdout (was: Re: Python! Is! Truly! Amazing!)

2005-01-03 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Just <[EMAIL PROTECTED]> wrote: > In article <[EMAIL PROTECTED]>, > Simo Melenius <[EMAIL PROTECTED]> wrote: > > > I've sometimes replaced sys.stdout (and/or sys.stderr) to > > capture/redirect debugging information in existing code that has > > unwisely just "pr

Re: Python! Is! Truly! Amazing!

2005-01-03 Thread Ron Garret
In article <[EMAIL PROTECTED]>, jfj <[EMAIL PROTECTED]> wrote: > Ron Garret wrote: > > In article <[EMAIL PROTECTED]>, > > "Erik Bethke" <[EMAIL PROTECTED]> wrote: > > > > > >>I have NEVER experienced this ki

Re: variable hell

2005-08-25 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Benji York <[EMAIL PROTECTED]> wrote: > Peter Maas wrote: > > >>> suffix = 'var' > > >>> vars()['a%s' % suffix] = 45 > > >>> avar > > 45 > > Quoting from http://docs.python.org/lib/built-in-funcs.html#l2h-76 about > the "vars" built in: > > The returned dicti

Re: variable hell

2005-08-25 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Robert Kern <[EMAIL PROTECTED]> wrote: > In the > bowels of my modules, I may not know what the contents are at code-time, Then how do you write your code? rg -- http://mail.python.org/mailman/listinfo/python-list

Re: variable hell

2005-08-25 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Steve Holden <[EMAIL PROTECTED]> wrote: > rafi wrote: > > Reinhold Birkenfeld wrote: > > > > > exec(eval("'a%s=%s' % (count, value)")) > >>> > >>>why using the eval? > >>> > >>>exec ('a%s=%s' % (count, value)) > >>> > >>>should be fine > >> > >>And this demo

Re: supress creation of .pyc files

2005-02-16 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Thomas Guettler <[EMAIL PROTECTED]> wrote: > Hi, > > Is there a way to import a file without creating > a .pyc file? > > Of course you can delete the pyc in my script after > the import statement, but maybe there is a switch > that I have not found yet. > > The

Re: __getitem__ method on (meta)classes

2005-03-14 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Leif K-Brooks <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > Why doesn't this work? > > > > > def foo(lst): > > > > ... class baz(object): > > ... def __getitem__(cls, idx): return cls.lst[idx] > > ... __getitem__=classmethod(__getitem__

Re: __getitem__ method on (meta)classes

2005-03-14 Thread Ron Garret
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (Bengt Richter) wrote: > On 14 Mar 2005 17:43:53 -0800, [EMAIL PROTECTED] wrote: > > > > >Why doesn't this work? > > > def foo(lst): > >... class baz(object): > >... def __getitem__(cls, idx): return cls.lst[idx] > >... __getitem__

Re: __getitem__ method on (meta)classes

2005-03-14 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Ron Garret <[EMAIL PROTECTED]> wrote: Wow, this is really cool: > What I'm really trying to do is to create enumerated types... And the code I ended up with is: # Inheriting from type, not object, is the key: class enum_metaclass(type):

Re: __getitem__ method on (meta)classes

2005-03-15 Thread Ron Garret
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (Bengt Richter) wrote: > >Did you mean type(x).__getitem__(x,y)? > > > Not if x is a classmethod, Oh yeah, right. Duh! > >And where is this documented? > Between the lines in my previous post ;-) I see. I guess I wasn't asking a stupid questi

Re: __getitem__ method on (meta)classes

2005-03-15 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Steven Bethard <[EMAIL PROTECTED]> wrote: > Ron Garret wrote: > > What I'm really trying to do is to create enumerated types such that if: > > > > e1 = enum(lst) and v = e1(x) > > > > then > > > >

Re: __getitem__ method on (meta)classes

2005-03-15 Thread Ron Garret
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (Bengt Richter) wrote: > On Mon, 14 Mar 2005 23:44:46 -0700, Steven Bethard <[EMAIL PROTECTED]> > wrote: > > >Ron Garret wrote: > >> What I'm really trying to do is to create enumerated types such that i

Re: __getitem__ method on (meta)classes

2005-03-15 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Steven Bethard <[EMAIL PROTECTED]> wrote: > > Yeah, except I actually left out one thing: I also want type(v)==e1. > > Why? In Python usually you rely on duck-typing and not explicit type > checks. What is it that you're trying to gain by asserting type(v) ==

Re: __getitem__ method on (meta)classes

2005-03-16 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Steven Bethard <[EMAIL PROTECTED]> wrote: > Ron Garret wrote: > > In article <[EMAIL PROTECTED]>, > > Steven Bethard <[EMAIL PROTECTED]> wrote: > > > >>>Yeah, except I actually left out one thing: I al

[jobs] Python web programmer needed (Los Angeles)

2004-12-11 Thread Ron Garret
Python programmer needed to do web development for an early-stage entertainment industry startup company. We prefer someone in the northern LA area (the company offices are in Altadena), but will consider telecommuters. Please email resumes to me at ron at flownet.com. rg -- http://mail.py

Specifying __slots__ in a dynamically generated type

2005-03-27 Thread Ron Garret
I need to dynamically generate new types at run time. I can do this in two ways. I can use the "type" constructor, or I can generate a "class" statement as a string and feed that to the exec function. The former technique is much cleaner all else being equal, but I want to be able to specif

Re: Specifying __slots__ in a dynamically generated type

2005-03-27 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Leif K-Brooks <[EMAIL PROTECTED]> wrote: > Ron Garret wrote: > > I need to dynamically generate new types at run time. I can do this in > > two ways. I can use the "type" constructor, or I can generate a "class"

Re: Specifying __slots__ in a dynamically generated type

2005-03-27 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Steven Bethard <[EMAIL PROTECTED]> wrote: > Ron Garret wrote: > > I need to dynamically generate new types at run time. I can do this in > > two ways. I can use the "type" constructor, or I can generate a "class"

Weakrefs to classes that derive from str

2005-03-29 Thread Ron Garret
Why doesn't this work? >>> from weakref import ref >>> class C(str): pass ... >>> ref(C()) Traceback (most recent call last): File "", line 1, in ? TypeError: cannot create weak reference to 'C' object >>> Note that this does work: >>> class D(int): pass ... >>> ref(D()) >>> Likewise for

Re: Weakrefs to classes that derive from str

2005-03-29 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Steven Bethard <[EMAIL PROTECTED]> wrote: > Ron Garret wrote: > > Why doesn't this work? > > > >>>>from weakref import ref > >>>>class C(str): pass > > ... > >>>>ref(C()) >

Re: Weakrefs to classes that derive from str

2005-03-30 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Peter Hansen <[EMAIL PROTECTED]> wrote: > Steven Bethard wrote: > > Ron Garret wrote: > >> None of the native types (int, float, list, tuple, etc.) can have weak > >> references, but wrapping them in a class is supposed

Re: Weakrefs to classes that derive from str

2005-03-30 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Peter Hansen <[EMAIL PROTECTED]> wrote: > Ron Garret wrote: > >>>>foo(int) > >>>>foo(float) > >>>>foo(dict) > >>>>foo(list) > >>>>foo(str) > > TypeError: cannot create

Re: Weakrefs to classes that derive from str

2005-03-30 Thread Ron Garret
In article <[EMAIL PROTECTED]>, "Raymond Hettinger" <[EMAIL PROTECTED]> wrote: > [Ron Garret] > > Why doesn't this work? > > > > >>> from weakref import ref > > >>> class C(str): pass > > ... > > >>&

Re: Weakrefs to classes that derive from str

2005-03-30 Thread Ron Garret
In article <[EMAIL PROTECTED]>, "Raymond Hettinger" <[EMAIL PROTECTED]> wrote: > [Ron Garret] > > Thanks for the detailed explanation. I understand now why you can't > > create weakrefs to these types. What I don't understand still is why > &

Re: Regex anomaly

2006-01-03 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Roy Smith <[EMAIL PROTECTED]> wrote: > In article <[EMAIL PROTECTED]>, > "Sam Pointon" <[EMAIL PROTECTED]> wrote: > > > Would this particular inconsistency be candidate for change in Py3k? > > Seems to me the pos and endpos arguments are redundant with slicing, >

Why doesn't this work?

2006-10-21 Thread Ron Garret
Python 2.3.5 (#1, Jan 30 2006, 13:30:29) [GCC 3.3 20030304 (Apple Computer, Inc. build 1819)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> from datetime import datetime >>> class ts(datetime): ... def __init__(self): pass ... >>> ts() Traceback (most rece

Re: Why doesn't this work?

2006-10-21 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Larry Bates <[EMAIL PROTECTED]> wrote: > Because datetime is a new-style class: Ah. > The Constructor __new__ > > If you are like me, then you probably always thought of the __init__ method > as > the Python equivalent of what is called a constructor in C++. Th

Re: What is Expressiveness in a Computer Language

2006-06-19 Thread Ron Garret
In article <[EMAIL PROTECTED]>, "Marshall" <[EMAIL PROTECTED]> wrote: > The conversation I would *really* like to have is the one where we > discuss what all the differences are, functionally, between the two, > and what the implications of those differences are, without trying > to address which

Parsing form input in a BaseHTTPServer

2006-09-01 Thread Ron Garret
I'm write a web server using BaseHTTPServer. It can't be a CGI because it has to do some weird server-push stuff as database updates come in. But I still need to process form inputs as if it were a CGI. But the cgi module only works in a CGI environment. Is there something with the equivale

BaseHTTPServer weirdness

2006-09-11 Thread Ron Garret
I'm trying to figure out how to use BaseHTTPServer. Here's my little test app: = #!/usr/bin/python from BaseHTTPServer import * import cgi class myHandler(BaseHTTPRequestHandler): def do_GET(r): s = '' try: s = cgi.parse_qs(r.rfile.read(int(r.

Re: BaseHTTPServer weirdness

2006-09-11 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Steve Holden <[EMAIL PROTECTED]> wrote: > The normal way is > > s = cgi.parse() > > since the CGI script sees the client network socket (after consumption > of HTTP headers) as its standard input. Doesn't work. (I even tried sys.stdin=r.rfile; s=cgi.parse())

Re: BaseHTTPServer weirdness

2006-09-11 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Steve Holden <[EMAIL PROTECTED]> wrote: > But basically, you aren't providing a CGI environment, and that's why > cgi.parse() isn't working. Clearly. So what should I be doing? Surely I'm not the first person to have this problem? I have managed to work aroun

Re: BaseHTTPServer weirdness

2006-09-11 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Steve Holden <[EMAIL PROTECTED]> wrote: > Ron Garret wrote: > > In article <[EMAIL PROTECTED]>, > > Steve Holden <[EMAIL PROTECTED]> wrote: > > > > > >>But basically, you aren't providing

Re: BaseHTTPServer weirdness

2006-09-11 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Kent Johnson <[EMAIL PROTECTED]> wrote: > Steve Holden wrote: > > Ron Garret wrote: > >> In article <[EMAIL PROTECTED]>, > >> Steve Holden <[EMAIL PROTECTED]> wrote: > >> > >> > &

Re: BaseHTTPServer weirdness

2006-09-11 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Damjan <[EMAIL PROTECTED]> wrote: > >> But basically, you aren't providing a CGI environment, and that's why > >> cgi.parse() isn't working. > > > > Clearly. So what should I be doing? > > Probably you'll need to read the source of cgi.parse_qs (like Steve did)

Re: BaseHTTPServer weirdness

2006-09-12 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Steve Holden <[EMAIL PROTECTED]> wrote: > I wouldn't necessarily say you are wrong here, It's just that the cgi > module has sort of "just growed", so it isn't conveniently factyored for > reusability in other contexts. Several people (including me) have taken >

Is there a reason not to do this?

2006-11-30 Thread Ron Garret
One of the things I find annoying about Python is that when you make a change to a method definition that change is not reflected in existing instances of a class (because you're really defining a new class when you reload a class definition, not actually redefining it). So I came up with thi

Re: Is there a reason not to do this?

2006-11-30 Thread Ron Garret
In article <[EMAIL PROTECTED]>, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > Ron Garret schrieb: > > One of the things I find annoying about Python is that when you make a > > change to a method definition that change is not reflected in existing >

Re: Is there a reason not to do this?

2006-11-30 Thread Ron Garret
In article <[EMAIL PROTECTED]>, "Hendrik van Rooyen" <[EMAIL PROTECTED]> wrote: > "Ron Garret" <[EMAIL PROTECTED]> wrote: > > > > > > One of the things I find annoying about Python is that when you make a > > change to a method

Re: Is there a reason not to do this?

2006-11-30 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Ron Garret <[EMAIL PROTECTED]> wrote: > In article <[EMAIL PROTECTED]>, > "Hendrik van Rooyen" <[EMAIL PROTECTED]> wrote: > > > "Ron Garret" <[EMAIL PROTECTED]> wrote: > > > > >

Re: Is there a reason not to do this?

2006-11-30 Thread Ron Garret
In article <[EMAIL PROTECTED]>, "Paul McGuire" <[EMAIL PROTECTED]> wrote: > "Carl Banks" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > > > A straightforward, Pythonic way to do it would be to create an > > intermediate representation that understands both the existing class >

Functions, callable objects, and bound/unbound methods

2006-12-01 Thread Ron Garret
If I do this: def f(self): print self class c1: pass setattr(c1, 'm1', f) Then f is automagically transmogrified into the appropriate sort of method depending on how it is used: >>> c1.m1 >>> c1().m1 > >>> c1().m1() <__main__.c1 instance at 0x51ec60> Note that m1 gets passed a self argument

Re: Functions, callable objects, and bound/unbound methods

2006-12-01 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Kent Johnson <[EMAIL PROTECTED]> wrote: > Ron Garret wrote: > > The reason I want to do this is that I want to implement a trace > > facility that traces only specific class methods. I want to say: > > > > trace(c1.m1) >

Re: Functions, callable objects, and bound/unbound methods

2006-12-01 Thread Ron Garret
In article <[EMAIL PROTECTED]>, "Michele Simionato" <[EMAIL PROTECTED]> wrote: > Duncan Booth wrote: > > Ron Garret <[EMAIL PROTECTED]> wrote: > > > > > I want to say: > > > > > > trace(c1.m1) > > > > > > an

Re: Is there a reason not to do this?

2006-12-01 Thread Ron Garret
In article <[EMAIL PROTECTED]>, "Carl Banks" <[EMAIL PROTECTED]> wrote: > The principle behind this is pretty much "it was just a language design > decision". Yes, and I'm not taking issue with the decision, just pointing out that the desire to do things differently is not necessarily perverse.

Re: Is there a reason not to do this?

2006-12-01 Thread Ron Garret
In article <[EMAIL PROTECTED]>, "Michele Simionato" <[EMAIL PROTECTED]> wrote: > Ron Garret wrote: > > One of the things I find annoying about Python is that when you make a > > change to a method definition that change is not reflected in existing > >

Select weirdness

2007-04-21 Thread Ron Garret
Here's my code. It's a teeny weeny little HTTP server. (I'm not really trying to reinvent the wheel here. What I'm really doing is writing a dispatching proxy server, but this is the shortest way to illustrate the problem I'm having): from SocketServer import * from socket import * from sele

Re: Select weirdness

2007-04-22 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Bjoern Schliessmann <[EMAIL PROTECTED]> wrote: > > The only difference I can discern is that the browser send \r\n > > for end-of-line while telnet just sends \n. ... > > But I don't see why that should make any difference. > > Easy. If you only accept "\r\n

Re: Select weirdness

2007-04-22 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Irmen de Jong <[EMAIL PROTECTED]> wrote: > Ron Garret wrote: > > Here's my code. It's a teeny weeny little HTTP server. (I'm not really > > trying to reinvent the wheel here. What I'm really doing is writing a

Re: Select weirdness

2007-04-22 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Ron Garret <[EMAIL PROTECTED]> wrote: > Here's my code. It's a teeny weeny little HTTP server. (I'm not really > trying to reinvent the wheel here. What I'm really doing is writing a > dispatching proxy server, but t

Re: Select weirdness

2007-04-22 Thread Ron Garret
I think I've figured out what's going on. First, here's the smoking gun: I changed the code as follows: class myHandler(StreamRequestHandler): def handle(self): print '>>>' while 1: sl = select([self.rfile],[],[],1)[0] print sl l = self.rfile.readline() i

Bug in select (was: Re: Select weirdness)

2007-04-22 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Ron Garret <[EMAIL PROTECTED]> wrote: > The answer is obvious: select is looking only at the underlying socket, > and not at the rfile buffers. Here is conclusive proof that there's a bug in select: from socket import * from select

Re: Bug in select

2007-04-22 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Erik Max Francis <[EMAIL PROTECTED]> wrote: > Ron Garret wrote: > > > So this is clearly a bug, but surely I'm not the first person to have > > encountered this? Is there a known workaround? > > It's hard to see

Re: Bug in select

2007-04-22 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Erik Max Francis <[EMAIL PROTECTED]> wrote: > Ron Garret wrote: > > > Geez you people are picky. Since I ran this several times I ran into > > the TIM_WAIT problem. Here's the actual transcript: > > It's not abou

Re: Bug in select (was: Re: Select weirdness)

2007-04-22 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: > Well, on WinXP, Python 2.4, with I should have specified: I'm running 2.5 on unix. (I've reproduced the problem on both Linux and OS X.) rg -- http://mail.python.org/mailman/listinfo/python-list

Re: Select weirdness

2007-04-23 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Irmen de Jong <[EMAIL PROTECTED]> wrote: > Ron Garret wrote: > > I don't understand why socketserver calling select should matter. (And > > BTW, there are no calls to select in SocketServer.py. I'm using > > Python

Re: Select weirdness

2007-04-23 Thread Ron Garret
In article <[EMAIL PROTECTED]>, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > En Mon, 23 Apr 2007 04:33:22 -0300, Ron Garret <[EMAIL PROTECTED]> > escribió: > > > I have not been able to find a proxy server that can proxy to unix > > socket

Re: Select weirdness

2007-04-23 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Jean-Paul Calderone <[EMAIL PROTECTED]> wrote: > Twisted does this out of the box, for what it's worth. Thanks. I will look at that. rg -- http://mail.python.org/mailman/listinfo/python-list

Re: Select weirdness

2007-04-23 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Donn Cave <[EMAIL PROTECTED]> wrote: > In article <[EMAIL PROTECTED]>, > Ron Garret <[EMAIL PROTECTED]> wrote: > > > The answer is obvious: select is looking only at the underlying socket, > > and not at the rfile bu

Is wsgi ready for prime time?

2007-05-17 Thread Ron Garret
The wsgiref module in Python 2.5 seems to be empty: [EMAIL PROTECTED]:~/Sites/modpy]$ python Python 2.5 (r25:51908, Mar 1 2007, 10:09:05) [GCC 4.0.1 (Apple Computer, Inc. build 5367)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import wsgiref >>> dir(wsgi

Re: Is wsgi ready for prime time?

2007-05-17 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Stargaming <[EMAIL PROTECTED]> wrote: > Ron Garret wrote: > > The wsgiref module in Python 2.5 seems to be empty: > > > > [EMAIL PROTECTED]:~/Sites/modpy]$ python > > Python 2.5 (r25:51908, Mar 1 2007, 10:09:05) > >

Is there a way to change the default string encoding?

2007-08-20 Thread Ron Garret
Is there a way to change the default string encoding used by the string.encode() method? My default environment is utf-8 but I need it to be latin-1 to avoid errors like this: >>> 'Andr\xe9 Ramel'.decode() Traceback (most recent call last): File "", line 1, in UnicodeDecodeError: 'a

Re: Is there a way to change the default string encoding?

2007-08-21 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Peter Otten <[EMAIL PROTECTED]> wrote: > If all else fails there's > > >>> sys.setdefaultencoding("latin1") > >>> "Andre\xe9 Ramel".decode() > u'Andre\xe9 Ramel' > > but that's an evil hack, you should rather talk to the maintainer of the > offending code to upda

BaseHTTPServer and Apache

2007-04-13 Thread Ron Garret
I have a fairly large web app written in Python as a CGI fairly elaborate CGI. All of the requests go through a single CGI script which does authentication and session management and then dispatches to one of a number of handlers that generate the various pages. There is one page that is a per

Re: BaseHTTPServer and Apache

2007-04-13 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Ron Garret <[EMAIL PROTECTED]> wrote: > Does > anyone know of a straightforward way to get Apache to "forward" requests > to a given path to another HTTP server running on a different port? Never mind, I think I figured it out.

Re: BaseHTTPServer and Apache

2007-04-14 Thread Ron Garret
In article <[EMAIL PROTECTED]>, "Luis M. González" <[EMAIL PROTECTED]> wrote: > On Apr 13, 8:44 pm, Ron Garret <[EMAIL PROTECTED]> wrote: > > In article <[EMAIL PROTECTED]>, > > Ron Garret <[EMAIL PROTECTED]> wrote: > > > >

Python, readline and OS X

2007-02-01 Thread Ron Garret
I have installed Python 2.5 on my new Intel Mac but I can't for the life of me get readline to work. I have libreadline installed, I've tried copying readline.so from my Python 2.3 installation into 2.5, I've searched the web, and no joy. Could someone please give me a clue? rg -- http://mai

Re: Python, readline and OS X

2007-02-01 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Irmen de Jong <[EMAIL PROTECTED]> wrote: > Ron Garret wrote: > > I have installed Python 2.5 on my new Intel Mac but I can't for the life > > of me get readline to work. I have libreadline installed, I've tried >

Re: Python, readline and OS X

2007-02-01 Thread Ron Garret
In article <[EMAIL PROTECTED]>, James Stroud <[EMAIL PROTECTED]> wrote: > Ron Garret wrote: > > I have installed Python 2.5 on my new Intel Mac but I can't for the life > > of me get readline to work. I have libreadline installed, I've tried >

Re: Python, readline and OS X

2007-02-01 Thread Ron Garret
In article <[EMAIL PROTECTED]>, James Stroud <[EMAIL PROTECTED]> wrote: > Ron Garret wrote: > > In article <[EMAIL PROTECTED]>, > > James Stroud <[EMAIL PROTECTED]> wrote: > > > >>Is LD_LIBRARY_PATH pointing to the directory libreadline.dyl

Python on a mac: how to build pythonw?

2007-03-01 Thread Ron Garret
I'm trying to run the Python examples distributed with XCode and they all give me the same error: Traceback (most recent call last): File "checktext.py", line 35, in main() File "checktext.py", line 8, in main pathname = EasyDialogs.AskFileForOpen(message='File to check end-of-lines

Re: Python on a mac: how to build pythonw?

2007-03-01 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Robert Kern <[EMAIL PROTECTED]> wrote: > Ron Garret wrote: > > I'm trying to run the Python examples distributed with XCode and they > > all give me the same error: > > > > Traceback (most recent call last): > >

Re: Python on a mac: how to build pythonw?

2007-03-01 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Robert Kern <[EMAIL PROTECTED]> wrote: > Ron Garret wrote: > > In article <[EMAIL PROTECTED]>, > > Robert Kern <[EMAIL PROTECTED]> wrote: > > >> Note that in recent versions of Python, I believe that the pythonw

WTF? Printing unicode strings

2006-05-18 Thread Ron Garret
>>> u'\xbd' u'\xbd' >>> print _ Traceback (most recent call last): File "", line 1, in ? UnicodeEncodeError: 'ascii' codec can't encode character u'\xbd' in position 0: ordinal not in range(128) >>> -- http://mail.python.org/mailman/listinfo/python-list

Re: WTF? Printing unicode strings

2006-05-18 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Ron Garret wrote: > > >>>> u'\xbd' > > u'\xbd' > >>>> print _ > > Traceback (most recent call last): > > File "", line

Re: WTF? Printing unicode strings

2006-05-18 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Robert Kern <[EMAIL PROTECTED]> wrote: > Ron Garret wrote: > > > I forgot to mention: > > > >>>>sys.getdefaultencoding() > > > > 'utf-8' > > A) You shouldn't be able to do that. Wha

Re: WTF? Printing unicode strings

2006-05-18 Thread Ron Garret
In article <[EMAIL PROTECTED]>, "Serge Orlov" <[EMAIL PROTECTED]> wrote: > Ron Garret wrote: > > In article <[EMAIL PROTECTED]>, > > Robert Kern <[EMAIL PROTECTED]> wrote: > > > > > Ron Garret wrote: > > &

Re: WTF? Printing unicode strings

2006-05-18 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Robert Kern <[EMAIL PROTECTED]> wrote: > Ron Garret wrote: > > > I'm using an OS X terminal to ssh to a Linux machine. > > Click on the "Terminal" menu, then "Window Settings...". Choose "Display&qu

Re: WTF? Printing unicode strings

2006-05-18 Thread Ron Garret
In article <[EMAIL PROTECTED]>, "Serge Orlov" <[EMAIL PROTECTED]> wrote: > Ron Garret wrote: > > In article <[EMAIL PROTECTED]>, > > "Serge Orlov" <[EMAIL PROTECTED]> wrote: > > > > > Ron Garret wrote: > > &g

Re: WTF? Printing unicode strings

2006-05-19 Thread Ron Garret
In article <[EMAIL PROTECTED]>, "Serge Orlov" <[EMAIL PROTECTED]> wrote: > Ron Garret wrote: > > > > I'm using an OS X terminal to ssh to a Linux machine. > > > > > > In theory it should work out of the box. OS X terminal should set &

Re: WTF? Printing unicode strings

2006-05-19 Thread Ron Garret
In article <[EMAIL PROTECTED]>, "Serge Orlov" <[EMAIL PROTECTED]> wrote: > Ron Garret wrote: > > In article <[EMAIL PROTECTED]>, > > "Serge Orlov" <[EMAIL PROTECTED]> wrote: > > > > > Ron Garret wrote: > > >

Re: WTF? Printing unicode strings

2006-05-19 Thread Ron Garret
In article <[EMAIL PROTECTED]>, "Serge Orlov" <[EMAIL PROTECTED]> wrote: > Serge Orlov wrote: > > Ron Garret wrote: > > > In article <[EMAIL PROTECTED]>, > > > "Serge Orlov" <[EMAIL PROTECTED]> wrote: > > > >

WSGI question: reading headers before message body has been read

2009-01-18 Thread Ron Garret
I'm writing a WSGI application and I would like to check the content- length header before reading the content to make sure that the content is not too big in order to prevent denial-of-service attacks. So I do something like this: def application(environ, start_response): status = "200 OK"

Re: WSGI question: reading headers before message body has been read

2009-01-18 Thread Ron Garret
On Jan 18, 11:29 am, "Diez B. Roggisch" wrote: > Ron Garret schrieb: > > > > > I'm writing a WSGI application and I would like to check the content- > > length header before reading the content to make sure that the content > > is not too big in orde

Re: WSGI question: reading headers before message body has been read

2009-01-18 Thread Ron Garret
On Jan 18, 11:43 am, Petite Abeille wrote: > On Jan 18, 2009, at 8:01 PM, Ron Garret wrote: > > > def application(environ, start_response): > >    status = "200 OK" > >    headers = [('Content-Type', 'text/html'), ] > >    start_res

Re: WSGI question: reading headers before message body has been read

2009-01-18 Thread Ron Garret
On Jan 18, 12:40 pm, "Diez B. Roggisch" wrote: > Ron Garret schrieb: > > > > > On Jan 18, 11:29 am, "Diez B. Roggisch" wrote: > >> Ron Garret schrieb: > > >>> I'm writing a WSGI application and I would like to check the conten

Re: WSGI question: reading headers before message body has been read

2009-01-18 Thread Ron Garret
On Jan 18, 1:21 pm, Graham Dumpleton wrote: > On Jan 19, 6:01 am, Ron Garret wrote: > > > I'm writing a WSGI application and I would like to check the content- > > length header before reading the content to make sure that the content > > is not too big in order

Yaro vs WebOb

2009-01-19 Thread Ron Garret
I'm selecting infrastructure for a web development and I've found two lightweight frameworks that seem to offer a lot of bang-for-the-byte: Yaro and WebOb. I'm wondering if anyone here has used either or both and has opinions about them. What has been your experience with them? Which do you

wsgi silently swallows errors

2009-01-19 Thread Ron Garret
Consider the following wsgi app: def application(env, start_response): start_response('200 OK',[('Content-type','text/plain')]) yield "hello" x=1/0 yield "world" The result of this is that the web browser displays "hello" and an error message ends up in the web log. But there is no othe

Sloooooowwwww WSGI restart

2009-01-28 Thread Ron Garret
I'm running a WSGI app under apache/mod_wsgi and I've noticed that whenever I restart the server after making a code change it takes a very long time (like a minute) before the script is active again. In other words, I do an apachectl restart, reload the page in my browser, and one minute late

Re: Sloooooowwwww WSGI restart

2009-01-28 Thread Ron Garret
In article , Aleksandar Radulovic wrote: > Hi there, > > On Wed, Jan 28, 2009 at 9:35 PM, Ron Garret wrote: > > I'm running a WSGI app under apache/mod_wsgi and I've noticed that > > Off the bat, there's no reason to run an app under apache/mod_wsgi &

Re: Sloooooowwwww WSGI restart

2009-01-28 Thread Ron Garret
In article , Jean-Paul Calderone wrote: > On Wed, 28 Jan 2009 13:35:56 -0800, Ron Garret wrote: > >I'm running a WSGI app under apache/mod_wsgi and I've noticed that > >whenever I restart the server after making a code change it takes a very > >long time (like

Re: Sloooooowwwww WSGI restart

2009-01-28 Thread Ron Garret
In article <4cd232ff-ba8b-47aa-8ee6-d8d9712db...@s1g2000prg.googlegroups.com>, Graham Dumpleton wrote: > On Jan 29, 8:35 am, Ron Garret wrote: > > I'm running a WSGI app under apache/mod_wsgiand I've noticed that > > whenever I restart the server after makin

Re: Sloooooowwwww WSGI restart

2009-01-29 Thread Ron Garret
In article <498171a5$0$3681$426a7...@news.free.fr>, Bruno Desthuilliers wrote: > Ron Garret a écrit : > > In article , > > Aleksandar Radulovic wrote: > (snip) > >> Secondly, why are you restarting apache after code changes? In normal > >> ci

Re: Sloooooowwwww WSGI restart

2009-01-29 Thread Ron Garret
In article <498170d4$0$23718$426a7...@news.free.fr>, Bruno Desthuilliers wrote: > Ron Garret a écrit : > > I'm running a WSGI app under apache/mod_wsgi and I've noticed that > > whenever I restart the server after making a code change it takes a very > >

  1   2   >