Hi All, I feel close to having this working using IIS6+isapi-wsgi+web2py +mssql. I have encountered an issue within web2py and I'm not sure how to get around it. I'll talk about the error at the end of this message, but first here is the basics for setting up isapi-wsgi with web2py under IIS. I can provide better documentation later after I have everything working. (Note: I have only tested under IIS6.)
My goal is to use isapi-wsgi + web2py under IIS. To accomplish this you must install the following (in this order): Python 2.5.4 http://python.org Python for Windows Extensions http://sourceforge.net/projects/pywin32/ isapi-wsgi http://code.google.com/p/isapi-wsgi/ There is a known bug using Python for Windows Extensions through ISAPI using Python 2.6.1. This bug has been fixed in the [yet to be released] Python 2.6.2 and Python 3.0.1. This is really not an issue for web2py developers because web2py doesn't yet support these 2 versions of Python. Still it's good to know (for people like me<grin>). More information on the bug is available here: http://sourceforge.net/tracker/index.php?func=detail&aid=2609380&group_id=78018&atid=551954 I created a new handler called isapi-wsgihandler.py (see attached) that is based on web2py's own wsgihandler.py and added it to the root web2py directory. To install this ISAPI extension and setup a website under IIS, execute the following command line: python isapi-wsgihandler.py install This will setup a virtual directory under IIS called web2py. The virtual directory name is set in the isapi-wsgihandler.py and the local URL is: http://localhost/web2py/ To remove the site and uninstall the ISAPI extension from IIS, execute the following command line: python isapi-wsgihandler.py remove To see error messages and print statements while testing the website under IIS run Win32TraceUtil.py found in the directory C:\Python25\Lib \site-packages\win32\lib. Okay, that's it for the setup. Now on to the issues I encountered with web2py. I received an error within web2py that said sys.argv did not exists so I added the following to isapi-wsgihandler.py: sys.argv = [''] This fixed the problem but I'm not sure of the impact. After doing this I now get this error message: Traceback (most recent call last): File "C:\Python25\lib\wsgiref\handlers.py", line 92, in run self.result = application(self.environ, self.start_response) File "gluon\contrib\wsgihooks.py", line 33, in __call__ self.__callback(self.__environ) AttributeError: ExecuteOnCompletion2 instance has no attribute '_ExecuteOnCompletion2__environ' I'm not sure how to get around this issue. Any suggestions on a fix? That's the status so far. As I said I feel like this is very close to working, which will be great. Meanwhile, I'm still waiting to hear back from my customer with a yay or nah to use python + web2py instead of ASP.NET MVC. At the moment it looks like the customer is going to okay the move, which will make me very happy even if I have to host the app under IIS. Thanks, -KIRBY --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---
#!/usr/bin/python """ This is a WSGI handler for Apache Requires apache+mod_wsgi. In httpd.conf put something like: LoadModule wsgi_module modules/mod_wsgi.so WSGIScriptAlias / /path/to/wsgihandler.py """ import sys, os if hasattr(sys, "isapidllhandle"): import win32traceutil sys.path.insert(0,'') path=os.path.dirname(os.path.abspath(__file__)) if not path in sys.path: sys.path.append(path) os.chdir(path) sys.argv = [''] import gluon.main from gluon.contrib.wsgihooks import ExecuteOnCompletion2, callback application=ExecuteOnCompletion2(gluon.main.wsgibase, callback) ## or # application=gluon.main.wsgibase_with_logging import isapi_wsgi # The entry points for the ISAPI extension. def __ExtensionFactory__(): return isapi_wsgi.ISAPIThreadPoolHandler(application) if __name__=='__main__': # If run from the command-line, install ourselves. from isapi.install import * params = ISAPIParameters() # Setup the virtual directories - this is a list of directories our # extension uses - in this case only 1. # Each extension has a "script map" - this is the mapping of ISAPI # extensions. sm = [ ScriptMapParams(Extension="*", Flags=0) ] vd = VirtualDirParameters(Name="web2py", Description = "ISAPI-WSGI ISAPISimpleHandler web2py site", ScriptMaps = sm, ScriptMapUpdate = "replace" ) params.VirtualDirs = [vd] HandleCommandLine(params)