473,396 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Question about wsgi.input

I'm sorry if this is off-topic, i couldn't find a mailing list OR forum for
WSGI (and #wsgi wasn't very helpful).

i played around with StringIO, and apparently if you write to a stringio the
position gets set to the end of the write, so if you read from it again,
without using seek, you won't read what comes next, you'll skip to the end
of the write. and if you write without seeking to the end first, you'll
overwrite part of the string if the reading hasn't caught up.

WSGI says that wsgi.input should block if there's more data to be read from
the socket, until that data is available. so when the server writes to the
file object, what happens to the file position? if i were writing a WSGI
app, i would just seek() to the last place my read ended at just to make
sure. but i'm making a server, so i need to know whether i should leave the
position at the end of the write, when it blocks (or for that matter, if i'm
writing while it's still reading), or at the end of the previous read?

thanks for any help.

Jun 27 '08 #1
4 2656
inhahe schrieb:
I'm sorry if this is off-topic, i couldn't find a mailing list OR forum for
WSGI (and #wsgi wasn't very helpful).

i played around with StringIO, and apparently if you write to a stringio the
position gets set to the end of the write, so if you read from it again,
without using seek, you won't read what comes next, you'll skip to the end
of the write. and if you write without seeking to the end first, you'll
overwrite part of the string if the reading hasn't caught up.

WSGI says that wsgi.input should block if there's more data to be read from
the socket, until that data is available. so when the server writes to the
file object, what happens to the file position? if i were writing a WSGI
app, i would just seek() to the last place my read ended at just to make
sure. but i'm making a server, so i need to know whether i should leave the
position at the end of the write, when it blocks (or for that matter, if i'm
writing while it's still reading), or at the end of the previous read?
I'm not sure exactly about what you are talking here - but generally,
wsgi.input should be considerd being a pipe. One (the server) simply
writes into it. The WSGI-app just reads. No seek.

Diez
Jun 27 '08 #2
at the end of the previous read?

At the end of the previous read.

Web-SIG is the mailing list for WSGI and related stuff.

- Brian

Jun 27 '08 #3
That's what I would have thought, just seems strange since it seems to imply
that if I use StringIO or cStringIO, then whenever i write to it i have to
save the position, seek to the end, write, and then seek to the position i
saved. Are there any other classes that are more suitable for pipes, but
qualify as 'file-like objects'?

"Diez B. Roggisch" <de***@nospam.web.dewrote in message
news:6a*************@mid.uni-berlin.de...
inhahe schrieb:
>I'm sorry if this is off-topic, i couldn't find a mailing list OR forum
for WSGI (and #wsgi wasn't very helpful).

i played around with StringIO, and apparently if you write to a stringio
the position gets set to the end of the write, so if you read from it
again, without using seek, you won't read what comes next, you'll skip to
the end of the write. and if you write without seeking to the end first,
you'll overwrite part of the string if the reading hasn't caught up.

WSGI says that wsgi.input should block if there's more data to be read
from the socket, until that data is available. so when the server writes
to the file object, what happens to the file position? if i were writing
a WSGI app, i would just seek() to the last place my read ended at just
to make sure. but i'm making a server, so i need to know whether i
should leave the position at the end of the write, when it blocks (or for
that matter, if i'm writing while it's still reading), or at the end of
the previous read?

I'm not sure exactly about what you are talking here - but generally,
wsgi.input should be considerd being a pipe. One (the server) simply
writes into it. The WSGI-app just reads. No seek.

Diez

Jun 27 '08 #4
inhahe schrieb:
That's what I would have thought, just seems strange since it seems to imply
that if I use StringIO or cStringIO, then whenever i write to it i have to
save the position, seek to the end, write, and then seek to the position i
saved. Are there any other classes that are more suitable for pipes, but
qualify as 'file-like objects'?
Who uses StringIO for what? if you have two processes (server and
application), you can of course use a pipe of some sort. If you write a
WSGI-server that is supposed to pass the wsgi.input to an application,
just use StringIO with the completely initialized data - there is no
writing in-between.

Diez
Jun 27 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Thomas W | last post by:
Will there be a WSGI-server like BaseHTTPServer etc in the standard distro? I think that would increase the adoptation of the WSGI-standard. A new web-framework for python pops up every other week...
2
by: Ben Finney | last post by:
Howdy all, I'm trying to implement some new functionality for an existing PHP web application. Rather than writing a whole lot of stuff in PHP, and looking toward a future when more of the...
1
by: seberino | last post by:
I love idea of WSGI and hope it succeeds. It seems to be helpful for person tempted to write his own framework.....they can now just mix and match existing components with WSGI //instead//. I...
11
by: Gregory Piñero | last post by:
So I keep hearing more and more about this WSGI stuff, and honestly I still don't understand what it is exactly and how it differs from CGI in the fundamentals (Trying to research this on the web...
7
by: Ben Finney | last post by:
Howdy all, I'm working on a web application that is starting to gain a lot of back-end code written in Python. However, all the current interface code is written in legacy PHP. I'd like to...
0
by: richmoore44 | last post by:
Hi, I've just written a python WSGI middleware class to mitigate XSS flaws, it's released under the python license. I've attached the docs below. Cheers Rich.
2
by: Adam Atlas | last post by:
I'm trying to figure out if there's any defined behaviour in PEP 333 for instances where an application returns an iterable as usual without error, but that iterable's next() method eventually...
8
by: Ron Garret | last post by:
The wsgiref module in Python 2.5 seems to be empty: $ python Python 2.5 (r25:51908, Mar 1 2007, 10:09:05) on darwin Type "help", "copyright", "credits" or "license" for more information. ...
1
by: Ivan Voras | last post by:
Hi, Is there a straightforward way to convert an XML-RPC server application (written for SimpleXMLRPCServer) to use WSGI so that it can be used as s fastcgi server? By "straightforward" I mean...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.