Python Apache Handler
Does anyone have any good examples, or links thereto for using python as an Apache handler? And I should qualify all of this by saying I'm a python newbie, and while having experience with Apache, I've never done anything outside whats "in the box" . What I'm looking for is how one might use Python not from the CGI/ presentation side but more on the backend...i.e. for each page Apache serves up examine the request and update some headers, or add a cookie to the response. Or possibly use Python for writing a custom Apache logger. I've searched the web but typically end up with pages for mod_python and writing CGI scripts. And if you feel this is better posted in an Apache group vs. here, let me apologize up front. Thanks -- http://mail.python.org/mailman/listinfo/python-list
Mock Form Post
Let me qualify this by saying I'm very new to python. I'm doing some work with mod_python and in a function I have defined I am passing in the form and then iterating through the form keys. I'm currently writing my unit tests and I'm trying to mock up a form object with kids so I can emulate my true form post. So I'm attempting to mock up a class that I'm calling "_Fakeform". I'm lost on how I should do it though. I thought by creating a dictionary object with key value pairs that would satisfy my need but I'm not sure how to get at it when I pass my mocked class in. -- http://mail.python.org/mailman/listinfo/python-list
Re: Mock Form Post
On May 19, 3:40 pm, Scooter wrote: > Let me qualify this by saying I'm very new to python. I'm doing some > work with mod_python and in a function I have defined I am passing in > the form and then iterating through the form keys. I'm currently > writing my unit tests and I'm trying to mock up a form object with > kids so I can emulate my true form post. So I'm attempting to mock up > a class that I'm calling "_Fakeform". I'm lost on how I should do it > though. I thought by creating a dictionary object with key value pairs > that would satisfy my need but I'm not sure how to get at it when I > pass my mocked class in. 1 strike against me for poor proof reading. 1) While I did mention mod_python I didn't say I was referring to an HTML form. 2) I said I'm trying to mock up a form object with "kids". No idea how I messed that up, but it should be "keys" -- http://mail.python.org/mailman/listinfo/python-list
Streaming pdf with URLLib
I'm playing around with urllib, and httplib, trying to make something
of a pdf proxy.I have a pdf that lives on an internal web server, and
I would like to be able to stream it to my external server. (this is
just a test for a bigger process. Yes I could just copy the pdf to the
external box). I was playing with URLLib doing something like
#!/usr/bin/python
import urllib
u = urllib.urlopen('https://myinternal.server/pdfs/pdfstreamer.aspx')
print 'Content-type: application/pdf\n\n'
# print 'Content-type: application/x-msdownload; name=\"FileName\"\n
\n'
# print 'Content-Dispostion: attachment; filename=\"FileName\"\r\n\n'
pdfdoc = u.read()
print pdfdoc
Hitting my pdfstreamer.aspx app directly through a browser renders a
pdf just fine. So now I'm attempting to use this python app on an
external webserver, access it as a cgi, to pull the pdf, and then re-
render it, but at that point it just shows me the raw pdf in
the browser.
--
http://mail.python.org/mailman/listinfo/python-list
Split string but ignore quotes
I'm attempting to reformat an apache log file that was written with a custom output format. I'm attempting to get it to w3c format using a python script. The problem I'm having is the field-to-field matching. In my python code I'm using split with spaces as my delimiter. But it fails when it reaches the user agent because that field itself contains spaces. But that user agent is enclosed with double quotes. So is there a way to split on a certain delimiter but not to split within quoted words. i.e. a line might look like 2009-09-29 12:00:00 - GET / "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; GTB5; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.0.04506; .NET CLR 3.5.21022)" http://somehost.com 200 1923 1360 31715 - -- http://mail.python.org/mailman/listinfo/python-list
Quick compare string to list
I'm reading in a text file, and for each line in the file, I'm looking for the existence of phrases from a list. The list contains approx. 120 items currently but will most likely grow. This procedure itself is not the main function of my program and only grew out of the need to reformat certain phrases I'm finding in a file before re-outputting it. But as I suspected, this searching of the lists slows the whole process way way down. Was looking for ideas of a better way to do this. I basically have mylist=[] ... code that reads in the flat file into string 'flatfileString' ... for listitem in mylist: if flatfileString.count(listitem): ...whatever...I found it. -- http://mail.python.org/mailman/listinfo/python-list
