Configure apache to run python scripts
I need to configure apache to run python scripts. I followed the steps mentioned in this site (http://www.thesitewizard.com/archive/ addcgitoapache.shtml). But I am not able to run python scripts from Firefox, I got a forbidden error "you do not have permission to access the file in the server" when I try to run the script form Firefox browser. Somebody please help me. -- http://mail.python.org/mailman/listinfo/python-list
Re: Configure apache to run python scripts
On Jul 23, 4:42 pm, Bruno Desthuilliers wrote: > joe jacob a écrit : > > > I need to configure apache to run python scripts. I followed the steps > > mentioned in this site (http://www.thesitewizard.com/archive/ > > addcgitoapache.shtml). But I am not able to run python scripts from > > Firefox, I got a forbidden error "you do not have permission to > > access the file in the server" when I try to run the script form > > Firefox browser. Somebody please help me. > > http://httpd.apache.org/docs//howto/cgi.html > > with 'your_apache_version_here' in 1.3, 2.0, 2.2 > > FWIW, your problem relates to apache and permissions, not to Python. > > HTH I got it right, I configured the apache incorrectly. Now I can execute the python scripts. Thanks for the response. -- http://mail.python.org/mailman/listinfo/python-list
Configuring apache to execute python scripts using mod_python handler
I configured apache to execute python scripts using mod_python handler. I followed below mentioned steps to configure apache. 1. In http.conf I added AddHandler mod_python .py PythonHandler mptest PythonDebug On 2. Then I added the line "LoadModule python_module modules/ mod_python.so" to http.conf. Then I tried execute the python script mentioned below from browser. from mod_python import apache def handler(req): req.content_type = 'text/plain' req.write("Hello World!") return apache.OK Then I am getting the following error Traceback (most recent call last): File "D:\softwares\Python25\Lib\site-packages\mod_python \importer.py", line 1537, in HandlerDispatch default=default_handler, arg=req, silent=hlist.silent) File "D:\softwares\Python25\Lib\site-packages\mod_python \importer.py", line 1202, in _process_target module = import_module(module_name, path=path) File "D:\softwares\Python25\Lib\site-packages\mod_python \importer.py", line 304, in import_module return __import__(module_name, {}, {}, ['*']) ImportError: No module named mptest I am using Apache 2.2.4, python 2.5 and mod_python-3.3.1.win32-py2.5- Apache2.2. I am able to execute python scripts by configuring apache to execute the cgi scripts. But I want to execute it using mod_python as it is faster compared to cgi mode. Someone please help me on this issue. -- http://mail.python.org/mailman/listinfo/python-list
Re: Configuring apache to execute python scripts using mod_python handler
On Aug 13, 9:44 pm, 7stud <[EMAIL PROTECTED]> wrote: > On Aug 13, 5:16 am, joe jacob <[EMAIL PROTECTED]> wrote: > > > > > I configured apache to execute python scripts using mod_python > > handler. I followed below mentioned steps to configure apache. > > > 1. In http.conf I added > > > > > AddHandler mod_python .py > > PythonHandler mptest > > PythonDebug On > > > > > 2. Then I added the line "LoadModule python_module modules/ > > mod_python.so" to http.conf. > > > Then I tried execute the python script mentioned below from browser. > > > from mod_python import apache > > def handler(req): > > req.content_type = 'text/plain' > > req.write("Hello World!") > > return apache.OK > > > Then I am getting the following error > > > Traceback (most recent call last): > > > File "D:\softwares\Python25\Lib\site-packages\mod_python > > \importer.py", line 1537, in HandlerDispatch > > default=default_handler, arg=req, silent=hlist.silent) > > > File "D:\softwares\Python25\Lib\site-packages\mod_python > > \importer.py", line 1202, in _process_target > > module = import_module(module_name, path=path) > > > File "D:\softwares\Python25\Lib\site-packages\mod_python > > \importer.py", line 304, in import_module > > return __import__(module_name, {}, {}, ['*']) > > > ImportError: No module named mptest > > > I am using Apache 2.2.4, python 2.5 and mod_python-3.3.1.win32-py2.5- > > Apache2.2. > > > I am able to execute python scripts by configuring apache to execute > > the cgi scripts. But I want to execute it using mod_python as it is > > faster compared to cgi mode. Someone please help me on this issue. > > 1) In the mod_python tutorial it says: > > --- > 2.4 Testing > > ... > ... > > 2. Add the following Apache directives, which can appear in either the > main server configuration file, or .htaccess. If you are going to be > using the .htaccess file, you will not need the tag below > (the directory then becomes the one in which the .htaccess file is > located), ***and you will need to make sure the AllowOverride > directive applicable to this directory has at least FileInfo > specified. (The default is None, which will not work.) > > > AddHandler mod_python .py > PythonHandler mptest > PythonDebug On > > > > Note the last sentence in the directions above. I explain what is > needed for that part at the link in (2) below. Also note the > directory listed in the opening tag: > > /some/directory/htdocs/test > > That specifies a sub directory of htdocs. That's because the htdocs > directory has its own tag in httpd.conf, which specifies > the things you can to with it. If you look around in httpd.conf, you > will see the tag that applies to htdocs. Mine looks like > this: > > > ... > ... > > > The mod_python Testing tutorial wants you to create your own sub > directory in htdocs, so that you can specify your own rules for that > directory. You're probably getting errors because you have two > tags in your httpd.conf file for the htdocs directory, and > the second tag is overwriting the first one. > > 2) You can see the latter part of this thread for what I did to get > mptest.py to work: > > http://groups.google.com/group/comp.lang.python/browse_thread/thread/... > > 3) I put any tags I added to httpd.conf below the first > tag in http.conf, which is this one: > > > > so that the ones lower down in the file will override the previous > tags if there is a conflict. Thank you very much I got it working. -- http://mail.python.org/mailman/listinfo/python-list
Python web frameworks
There are a lot of web frameworks for python like django, mod_python, spyce, turbo gears, Zope, Cherrypy etc. Which one is the best in terms of performance and ease of study. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python web frameworks
On Nov 21, 10:15 am, Graham Dumpleton <[EMAIL PROTECTED]> wrote: > On Nov 21, 1:37 pm, BartlebyScrivener <[EMAIL PROTECTED]> wrote: > > > > > On Nov 20, 3:39 pm, Graham Dumpleton <[EMAIL PROTECTED]> > > wrote: > > > > This only holds if actually hosted on Apache. As Django these days > > > supports WSGI interface there is nothing to stop it being run with > > > other hosting solutions that support WSGI. So, you could host it under > > > paster or CherryPy WSGI servers. You could even run it under CGI if > > > you were really desperate using a CGI-WSGI adapter. So, it isn't > > > strictly correct to say it is as a multiprocess framework specifically > > > for mod_python, although the developers will admit in the first > > > instance that they didn't design the internals with multithreading in > > > mind. That said, there aren't believed to be any multithreading issues > > > in Django itself at this time. > > > > People keep pushing this barrow about the GIL and multithreading being > > > a huge problem, when in the context of Apache it is isn't, at least > > > not to the degree people make out. The reason for this is that when > > > using worker MPM it sill acts as a multi process web server even > > > though each process is also multithreaded. Within those worker MPM > > > child processes there is also a lot going on that doesn't involve > > > Python code nor the GIL, for example initial request process and > > > serving up of static files etc. > > > > Result is that the Python GIL is no impediment when using Apache on > > > UNIX to making good use of multiple processors or cores, even when > > > Apache worker MPM is used. > > > I understand about a fifth of this exchange but I'm glad it's here so > > I can follow links and search on the terminology. I couldn't tell from > > earlier posts if mod_python was good or bad. > > Version 3.3 of mod_python fixed up a lot of issues that existed with > older versions of mod_python. There are still a lot of issues in > mod_python unfixed. > > https://issues.apache.org/jira/browse/MODPYTHON > > In the main people will not run into these issues, of if they do, the > incidence of them causing a direct or significant impact is low, or > with people just tolerating the problems. > > If you want to be where hosting with Apache is heading, then look at > mod_wsgi (http://www.modwsgi.org) instead. People will say I am biased > because I wrote it, but I was also the main person who did the more > recent work on fixing up mod_python and am more aware than others of > what problems still exist in mod_python. > > To be frank, unless some white knight comes along and dives into > mod_python and fixes up the remaining issues, then you probably will > not see any significant future updates to mod_python and it will just > stagnate. I certainly will not be devoting much time to mod_python any > more. > > Part of the problem with mod_python is that the code base has grown > over time and is long overdue for a complete rethink, which is in part > what mod_wsgi was about, ie., making the code and configuration a lot > simpler and safer for use in web hosting environments. > > Thus mod_wsgi takes aspects of what mod_python does, combining it with > aspects of how FASTCGI solutions work. This gives the option of > embedding a Python application in Apache for maximum speed, or using > daemon processes as means of being able to better separate multiple > applications. > > Most importantly, mod_wsgi supports WSGI directly, making it > reasonably trivial to run any Python web framework or application > which supports the WSGI standard. > > > The Django book says: "Apache with mod_python currently is the most > > robust setup for using Django on a production server." > > > Is that true? > > I would say that that is now debatable. Overall mod_wsgi is probably a > better package in terms of what it has to offer. Only thing against > mod_wsgi at this point is peoples willingness to accept something that > is new in conjunction with Linux distributions and web hosting > companies being slow to adopt new packages. > > Various people are quite happily using mod_wsgi. Users of mod_wsgi > range from people trying to run it in memory constrained VPS systems, > right up to major sites serving up to between 3-4 million hits a day. > > There have been a few odd things come up since the initial release > which have since been fixed, but the core is showing itself to be very > solid. > > Graham Thanks everyone for the response. From the posts I understand that Django and pylons are the best. By searching the net earlier I got the same information that Django is best among the frameworks so I downloaded it and I found it very difficult to configure. I referred the djangobook. Is pylons better in terms of performance and ease of study compared to Django. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python web frameworks
On Nov 21, 10:27 pm, Steven Bethard <[EMAIL PROTECTED]> wrote: > Jeff wrote: > > On Nov 21, 6:25 am, Bruno Desthuilliers > [EMAIL PROTECTED]> wrote: > >> joe jacob a écrit : > >> (snip) > > >>> Thanks everyone for the response. From the posts I understand that > >>> Django and pylons are the best. By searching the net earlier I got the > >>> same information that Django is best among the frameworks so I > >>> downloaded it and I found it very difficult to configure. > >> ??? > > >> It's been a couple of years since I last used Django, but I don't > >> remember any specific complexity wrt/ configuration. > > > The only difficulties I have had have been with serving static media. > > Specifically, in the differences in setup between the development > > environment and production, and setting it up so that I don't have to > > make any changes to the code in order to roll out upgrades to a > > product. > > I ran into this same problem. I wish it was simply a matter of starting > the django project on another server, but a bunch of paths and URLs > always seem to need to be changed. (I end up having to modify my > urls.py files because I go from being at the URL root on the development > server to being in a subdirectory on the actual server.) > > Other that those issues though, I've really enjoyed working in Django. > > STeVe- Hide quoted text - > > - Show quoted text - Thanks everyone for the response. I installed Django and configured apache to execute the python scripts. I am learning it now. -- http://mail.python.org/mailman/listinfo/python-list
Re: XOR encryption
On Jan 18, 4:11 pm, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > On Fri, 18 Jan 2008 03:06:51 -0800, joe jacob wrote: > > I wrote a python script to perform XOR encryption on a text and write > > the encrypted text to a file. But when I try to read the file as the > > encrypted text contains an EOF in between the file is read only to the > > first EOF and remaining part of the text is not read. > > You have to open the file in binary mode ('rb'/'wb') instead of text mode > ('r'/'w') to stop Windows from interpreting the EOF character this way. > > Ciao, > Marc 'BlackJack' Rintsch Thanks a lot for the information now it is working fine. -- http://mail.python.org/mailman/listinfo/python-list
XOR encryption
I wrote a python script to perform XOR encryption on a text and write the encrypted text to a file. But when I try to read the file as the encrypted text contains an EOF in between the file is read only to the first EOF and remaining part of the text is not read. I used the text "hello world" and code 109. The ASCII value of w is 119 which is XOR ed with 109 gives EOF (ascii 26). So when I read the file next time and decrypts it with 109; I'm getting result as "hello " as the encrypted w is considered as EOF and remaining pare is not read. I'm posting the code below. Please give me some inputs ot sort this out. name='a.txt' f1=open(name,"w") text='hello world' data=[] code=109 coded="" for i in range(0,len(text)): coded = coded+chr(ord(text[i]) ^ code) f1.write(coded) print coded f1.close() f1=open(name,"r") while 1: char = f1.read(1) if not char: break else: char = chr(ord(char) ^ int(code)) data.append(char) f1.close() print data -- http://mail.python.org/mailman/listinfo/python-list
wxpython
I am trying to open a file containing non displayable characters like contents an exe file. The is is with the below mentioned code: self.text_ctrl_1.SetValue(file_content) If the file_content contains non displayable characters I am getting an error like this: Traceback (most recent call last): File "C:\Documents and Settings\joe_jacob\Desktop\notepad.py", line 102, in open_file self.text_ctrl_1.SetValue(file_content) File "D:\softwares\Python25\Lib\site-packages\wx-2.8-msw-unicode\wx \_controls.py", line 1708, in SetValue return _controls_.TextCtrl_SetValue(*args, **kwargs) File "D:\softwares\Python25\lib\encodings\cp1252.py", line 15, in decode return codecs.charmap_decode(input,errors,decoding_table) UnicodeDecodeError: 'charmap' codec can't decode byte 0x90 in position 2: character maps to I am trying to create an encryption program so if I open any file even if it is an exe file it should display in text ctrl. What is this problem with this ? How can I rectify this? -- http://mail.python.org/mailman/listinfo/python-list
Designing website
Hi All, I am planning to design a website using windows, apache, mysql, python. But I came to know that python cgi is very slow. I came across mod_python also but no good documentation are available for learning mod_python. Suggest me a good solution for this as I don't know other languages like PHP; I prefer python. -- http://mail.python.org/mailman/listinfo/python-list
Re: wxpython
On Jan 24, 4:20 pm, Tim Golden <[EMAIL PROTECTED]> wrote: > [Tim Golden] > > > > >> wxPython is trying to interpret your byte stream as a Unicode > >> text stream encoded as cp1252. But it's not, so it gives up > >> in a heap. One solution is to pass the repr of file_content. > >> Another solution is for you to prefilter the text, replacing > >> non-printables by their hex value or by some marker. Not much > >> in it, really. > > >> > >> import random > >> file_content = "".join ( > >>chr (random.randint (0, 255)) for i in range (1000) > >> ) > >> munged_text = "".join ( > >> c if 32 <= ord (c) <= 126 else hex (ord (c)) for c in file_content > >> ) > > >> print repr (file_content) > >> print munged_text > >> > > >> TJG > > [joe jacob] > > > If I open an exe file in notepad, I can see some junk characters. I'm > > trying to develop a program like an editor which can encrypt a file > > opened by it. I need to open files like exe or jpeg etc in the editor > > and after encryption the encrypted data should be displayed in the > > editor. I developed the editor but when I tried to open an windows exe > > file in it I am getting the above mentioned error as the characters > > contained in it are non unicode. > > Hi, Joe. I've copied this back to the list (and I encourage you to > do the same when replying) since the more people see the issue, > the more chances you've got of a useful answer! > > To try to address what you're saying here: notepad.exe makes some > choice or other when confronted by the byte stream in a file which > you open. I don't know what that choice is, or how it tries to cope > with encoded unicode text, but whatever it does by the choice of > its developers. The "some junk characters" are one of several > possible representations of the not-ordinary-characters which your > file contains. > > If you're writing your own editor or file display, you have to make > similar choices, which includes understanding what possibilities are > offered by the toolset you're employing -- in this case, wxPython. > > > The wxPython wx.TextCtrl expects to be fed with Unicode text. If > you pass it a string instead, it tries to decode it according to > the system's default encoding, here cp1252. If it can't, it doesn't > display "junk characters": it just gives an error. > > > If you want junk characters, then you'll either have to explicitly > pass in the characters you want displayed or do the kind of thing > I suggested above to indicate their hex value, or find another > control (or an option of the wx.TextCtrl) which will attempt to do > the work for you when displaying raw bytes. > > I'm afraid I'm not a wxPython expert so maybe someone else has > suggestions. But the most important thing is that you understand > what's happening here and why you can't just say "I want it to > do what Notepad does". > > TJG Thanks for the information. I'll try to manage it some how. -- http://mail.python.org/mailman/listinfo/python-list