[Web-SIG] My experiences implement WSGI on java/j2ee/jython.

Phillip J. Eby pje at telecommunity.com
Mon Aug 30 05:01:40 CEST 2004


At 09:22 PM 8/29/04 -0500, Ian Bicking wrote:
>One question: should the application iterable be a Python 2.2 style 
>iterable?  I.e., it is up to Python 2.1 servers to implement the Python 
>2.2 iterator protocol themselves?  Or, should the application be 
>responsible to return an iterator, appropriate for the Python version?

How about we just add a "Using WSGI with earlier Python Versions" 
subsection to the application/implementation notes?

It would simply note that a WSGI server/gateway intended to work pre-2.2 
*must* use only a 'for' loop to iterate over an iterable returned by the 
application, and that applications needing to work pre-2.2 would have to 
implement the old-style iteration protocol.

It is *not* necessary for either the server or application to go through 
any special contortions to emulate the 2.2 iterator protocol, because 
current versions of Python still support the old iterator protocol.  See 
PEP 234:

  """For backwards compatibility, the PyObject_GetIter() function
     implements fallback semantics when its argument is a sequence that
     does not implement a tp_iter function: a lightweight sequence
     iterator object is constructed in that case which iterates over
     the items of the sequence in the natural order."""

('iter(ob)' is basically just Python for 'PyObject_GetIter(ob)' in C.)



More information about the Web-SIG mailing list