473,699 Members | 2,534 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2678
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.w eb.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
1275
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 and more and more support WSGI. Why not focus on getting an optimized, production-grade fully documented WSGI-server into the distro? Right now the BaseHTTPServer seems to be usable for development and testing, not production environment. Perhaps...
2
1399
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 application can be rewritten more sanely, I'd like to write a Python program that generates the content and serves it up to the existing application via HTTP. The existing architecture is as expected:
1
1231
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 not sure what WSGI offers the web beginner. Aren't they still better off learning an existing web framework first before attacking WSGI?
11
1833
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 now) What I'm most confused about is how it affects me. I've been writing small CGI programs in Python for a while now whenever I have a need for a web program. Is CGI now considered "Bad"? I've just always found it easier to write something...
7
1820
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 slowly introduce new features as Python WSGI programs. Is it possible to write a Python WSGI program that talks to a PHP program as its "back end"? Where can I find out how to do this, preferably with examples?
0
1208
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
1187
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 raises an exception. Since any data theretofore returned by the iterable must be assumed to have already been written to the client, thus making it impossible to replace the response with a 500 error or somesuch, does the gateway just absorb the...
8
2306
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. So... is wsgi considered ready for production use, or is it still on the bleeding edge? And if the former, which implementation should one use?
1
2104
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 something simple, without using some external framework. Alternatively, I don't really care about WSGI, so something that makes it work as fastcgi directly will also be ok.
0
9199
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8945
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6550
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5889
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4392
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4641
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3075
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2366
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2016
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.