Writing a CGI to query DB

2007-11-09 Thread Bighead
Hi,

I am currently working on a CGI deployed on an Apache server, which,
given an arbitrary SQL, fetches raw data from a remote DB server and
return them in a HTML page. This CGI works fine on quick SQLs.

But when I try to run a slow SQL on this CGI, through a Squid Proxy, I
always get the Error message from Squid: Zero Sized Reply, after 5
minutes.

The SQL itself is correct, since I have tried it directly on the DB
server. So what do you think might cause the problem? Thank you.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Writing a CGI to query DB

2007-11-10 Thread Bighead
On Nov 10, 7:18 pm, TheFlyingDutchman <[EMAIL PROTECTED]> wrote:
> On Nov 9, 8:33 pm, Bighead <[EMAIL PROTECTED]> wrote:
>
> > Hi,
>
> > I am currently working on a CGI deployed on an Apache server, which,
> > given an arbitrary SQL, fetches raw data from a remote DB server and
> > return them in a HTML page. This CGI works fine on quick SQLs.
>
> > But when I try to run a slow SQL on this CGI, through a Squid Proxy, I
> > always get the Error message from Squid: Zero Sized Reply, after 5
> > minutes.
>
> > The SQL itself is correct, since I have tried it directly on the DB
> > server. So what do you think might cause the problem? Thank you.
>
> Slow SQL = query that takes a long time? How long does the query take
> if you run it on the same machine as the DB server without a Squid
> Proxy?


It takes 10 minutes to run this SQL. Squid's error message pops up in
about 5 minutes.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Writing a CGI to query DB

2007-11-10 Thread Bighead
On Nov 11, 6:20 am, paulC <[EMAIL PROTECTED]> wrote:
> On 10 Nov, 04:33, Bighead <[EMAIL PROTECTED]> wrote:
>
> > Hi,
>
> > I am currently working on a CGI deployed on an Apache server, which,
> > given an arbitrary SQL, fetches raw data from a remote DB server and
> > return them in a HTML page. This CGI works fine on quick SQLs.
>
> > But when I try to run a slow SQL on this CGI, through a Squid Proxy, I
> > always get the Error message from Squid: Zero Sized Reply, after 5
> > minutes.
>
> > The SQL itself is correct, since I have tried it directly on the DB
> > server. So what do you think might cause the problem? Thank you.
>
> This sounds a lot like an apache server configuration problem. From
> the squid FAQ;
>
> 11.51 Why do I sometimes get ``Zero Sized Reply''?
>
> This happens when Squid makes a TCP connection to an origin server,
> but for some reason, the connection is closed before Squid reads any
> data. Depending on various factors, Squid may be able to retry the
> request again. If you see the ``Zero Sized Reply'' error message, it
> means that Squid was unable to retry, or that all retry attempts also
> failed.
>
> The apache server has a default TimeOut of 300 seconds.
>
> This question might be more usefully answered by the apache user
> group.
>
> Regards, Paul Clinch


Thank you.
TimeOut of 300 seconds, does it mean that the connection will be
closed by remote Apache server if the server does not provide any data
in 300 seconds? So I can just let the server generate data
continuously, and the connection will not be cut off, right?

-- 
http://mail.python.org/mailman/listinfo/python-list


About the slot declaration decorator in PyQt4

2008-07-14 Thread Bighead
I remember when I did UI Design in PyQt4 for the first time, I found a
manual. In it, no "connect" was used. Instead, an OO approach is
applied, new UI classes inherit from old ones, and all the slot
functions are automatically connected to some signals, using a
decorator. In the __init__ function of our newly written class,
"connect" is not invoked.

I like this style...

Unfortunately, I cannot find that manual now So anyone have read
something like that before? If so, could you tell me where can I find
that manual please? Thank you :)
--
http://mail.python.org/mailman/listinfo/python-list


Re: About the slot declaration decorator in PyQt4

2008-07-14 Thread Bighead
On Jul 15, 2:04 am, "Sebastian \"lunar\" Wiesner"
<[EMAIL PROTECTED]> wrote:
> Bighead <[EMAIL PROTECTED]>:
>
> > I remember when I did UI Design in PyQt4 for the first time, I found a
> > manual. In it, no "connect" was used. Instead, an OO approach is
> > applied, new UI classes inherit from old ones, and all the slot
> > functions are automatically connected to some signals, using a
> > decorator. In the __init__ function of our newly written class,
> > "connect" is not invoked.
>
> > I like this style...
>
> > Unfortunately, I cannot find that manual now So anyone have read
> > something like that before? If so, could you tell me where can I find
> > that manual please? Thank you :)
>
> I guess, you're referring to QtCore.pyqtSignature and
> QtCore.QMetaObject.connectSlotsByName.
>
> Seehttp://www.riverbankcomputing.co.uk/static/Docs/PyQt4/pyqt4ref.html#t...
>
> Especially "3.7.3   Connecting Slots By Name"
>
> Hih
>
> --
> Freedom is always the freedom of dissenters.
>   (Rosa Luxemburg)

Oh yes, that's it! connectSlotsByName. That is the reason I though Qt
was easy to use.

This will be much easier :) Thank you very much.
--
http://mail.python.org/mailman/listinfo/python-list


Re: common elements between list of lists and lists

2008-07-17 Thread Bighead
On Jul 17, 4:30 pm, antar2 <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I am a beginner in python.
> following program prints the second element in list of lists 4 for the
> first elements in list 4 that are common with the elements in list 5
>
> list4 = [['1', 'a'],['4', 'd'],['8', 'g']]
> list5 = ['1', '2', '3']
>
> for j in list4:
> for k in list5:
> if j[0] == k:
> print j[1]
>
> Result: a
>
> I would like to do the same thing starting with following lists, where
> the numbers in list 5 are without ''. Is there a way to convert
> integers in a list to integers in '' ? This is based on a situation
> where I want to find common numbers between a list and a list of lists
> where the numbers in the list are without '' and the numbers in the
> list of lists are with ''
>
> list4 = [['1', 'a'],['4', 'd'],['8', 'g']]
> list5 = [1, 2, 3]
>
> This might be a stupid question, but anyway, thanks for your answer
> It is not my first post on this site. In some way it is not possible
> to react on the messages that I receive to thank the persons that
> react. Anyway, thanks a lot

By "integer without ''" you mean integers not embraced by single
quotes, right?

Actually, '1' is a string,  not an integer. If you want to normalize
the first elements of all the lists in list4, just use int() to
convert them.

That is:

list4 = [['1', 'a'],['4', 'd'],['8', 'g']]
list5 = ['1', '2', '3']

set5 = set(map(int, list5))
list4 = [[int(i[0]), i[1]] for i in list4]

for j in list4:
  if j[0] in set5: print j[1]

You can have a try :)
--
http://mail.python.org/mailman/listinfo/python-list