IIS6+web2py+MSSQL

56 views
Skip to first unread message

Kirby Turner

unread,
Feb 24, 2009, 10:26:27 PM2/24/09
to web...@googlegroups.com
Hi All,

There is a possibility I can convince a customer of mind to switch
from ASP.NET MVC to web2py. The catch? It must run under IIS 6 with
SQL Server 2005. Are there others hosting production web2py apps
under IIS 6 with MSSQL 2005? If so, how was the setup experience?
Difficult, easy? Any unexpected gotcha?

I searched the mail group and read the other IIS related threads so my
gut tells me there are not a lot of people using web2py with IIS. But
maybe I'm wrong.

Thanks,
-KIRBY

Paul Eden

unread,
Feb 24, 2009, 10:42:17 PM2/24/09
to web...@googlegroups.com
I don't have any production experience yet with web2py under IIS but I
do know that it hypothetically runs because the cherrypy webserver
that web2py runs on is wsgi compatible and there is a wsgi adapter for
IIS (http://code.google.com/p/isapi-wsgi/).

I have used MSSQL 2005 with python using the pymssql module and with
pyodbc both with great results. Pymssql is easier to setup, but uses
a deprecated MS C library for MSSQL.

Paul
--
Best Regards,

Paul Eden

"...and a little looking out for the other guy too."
- Mr. Smith

mdipierro

unread,
Feb 25, 2009, 12:19:03 AM2/25/09
to web2py Web Framework
According to this

http://code.google.com/p/isapi-wsgi/wiki/ISAPISimpleHandlerDocs

the iis-wsgi adapter is single threaded. If this means what I think it
means I would not use it.

You can, instead use fastCGI which is provided by Microsoft

http://www.iis.net/downloads/default.aspx?tabid=34&g=6&i=1521

web2py includes an adaptor and it is documented in AlterEgo

MSSQL is the least tested database back-end and the weirdest of them
all. It does not support pagination. we made it work in web2py with a
trick but it is still slower and more inefficient than any other
database backend. This will eventually be improved. Mind that this is
not a web2py issue. mssql does not support pagination even if you use
ASP.NET.

Massimo

Kirby Turner

unread,
Feb 25, 2009, 6:39:39 AM2/25/09
to web...@googlegroups.com
Thanks for the responses Paul and Massimo.

Sounds like my best next step is to setup a web2py app under IIS with
MSSQL and see what happens before making the final sell to the
customer. I'm confident that if it works, performance is good, and
the setup isn't too difficult I can develop the application in less
time using web2py. Note, I will not have access to the production
server so the setup must be performed by the customer's IT stafff,
which is why I need to make sure it is not difficult, i.e., their
staff can handle it.

Regarding isapi-wsgi, version 0.2 is single threaded. Version 0.3,
which was recently released, has been modified to overcome the
limitation. From the project's home page:

"Current status: The isapi_wsgi handler has been modified to overcome
the limitations of the single threaded version of the handler. The new
version provides two handlers:

* ISAPISimpleHandler - a new handler instance is created per
request
* ISAPIThreadPoolHandler - requests use the thread pool

Also the isapi_wsgi virtual directory can be accessed via it's root
url. "

http://code.google.com/p/isapi-wsgi/

Sounds promising.

Thanks again folks!

-KIRBY

mdipierro

unread,
Feb 25, 2009, 8:50:28 AM2/25/09
to web2py Web Framework
Please, if you succeed in this (and I am sure you will) send us some
instructions on how to reproduce it.

Paul Eden

unread,
Feb 25, 2009, 9:05:19 AM2/25/09
to web...@googlegroups.com
+1 on that!

Paul

Kirby Turner

unread,
Feb 25, 2009, 9:59:42 AM2/25/09
to web...@googlegroups.com
Will do. I'm close to having it working. Just getting a strange
import error on _socket. I posted a separate thread on that problem,
though it's not really a web2py issue.

-KIRBY

Kirby Turner

unread,
Feb 26, 2009, 9:07:11 AM2/26/09
to web...@googlegroups.com
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


isapi-wsgihandler.py

mdipierro

unread,
Feb 26, 2009, 11:25:49 AM2/26/09
to web2py Web Framework
Try change

sys.argv = ['']

into

sys.argv = ['web2py.py']

and

application=ExecuteOnCompletion2(gluon.main.wsgibase, callback)

into

application=gluon.main.wsgibase

You'd lose the ability to run cron jobs but once the problem is
isolated we can fix it.
Let us know.

Massimo

On Feb 26, 8:07 am, Kirby Turner <ki...@thecave.com> wrote:
> 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.4http://python.org
>
> Python for Windows Extensionshttp://sourceforge.net/projects/pywin32/
>
> isapi-wsgihttp://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&grou...
> isapi-wsgihandler.py
> 1KViewDownload
>
>

Kirby Turner

unread,
Feb 26, 2009, 2:39:29 PM2/26/09
to web...@googlegroups.com
Thanks Massimo. Another step closer. I made the recommended changes
and now I get a new 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\rewrite.py", line 129, in <lambda>
wsgibase_new=lambda e,r: wsgibase(filter_in(e),r)
File "gluon\rewrite.py", line 50, in filter_in
key=e['REMOTE_ADDR']+':'+path
KeyError: 'REMOTE_ADDR'

I tested from both the local machine and a remote machine and got the
same message.

-KIRBY

mdipierro

unread,
Feb 26, 2009, 3:04:50 PM2/26/09
to web2py Web Framework
Does hits help?

http://www.usenet-forums.com/php-language/24828-remote_addr-iis.html
http://wiki.pylonshq.com/display/pylonscookbook/Serving+a+Pylons+app+with+IIS

It seems in IIS ISAPI environment variables are not the environment
being bassed.

Massimo

Kirby Turner

unread,
Feb 26, 2009, 3:38:37 PM2/26/09
to web...@googlegroups.com
Unfortunately it doesn't help but gives me something more to
research. I'll also post a message to the isapi-wsgi group to see if
someone there has encountered this issue before.

Thanks,
-KIRBY

Kirby Turner

unread,
Feb 26, 2009, 3:55:26 PM2/26/09
to web...@googlegroups.com
Found this.

http://code.google.com/p/isapi-wsgi/issues/detail?id=2

Turns out to be a known bug with isapi-wsgi. There is a suggested fix
that I'm trying now.

-KIRBY

phecker

unread,
Feb 26, 2009, 3:58:51 PM2/26/09
to web2py Web Framework
Hello Kirby,

I am using web2py as a service on Windows Server 2008 and IIS 7 in
combination with the Helicon ISAP_Rewrite-module.

=> http://www.isapirewrite.com/

If you like, I can give you some more information.

_p_

On 26 Feb., 21:38, Kirby Turner <ki...@thecave.com> wrote:
> Unfortunately it doesn't help but gives me something more to  
> research.  I'll also post a message to the isapi-wsgi group to see if  
> someone there has encountered this issue before.
>
> Thanks,
> -KIRBY
>
> On Feb 26, 2009, at 3:04 PM, mdipierro wrote:
>
>
>
>
>
> > Does hits help?
>
> >http://www.usenet-forums.com/php-language/24828-remote_addr-iis.html
> >http://wiki.pylonshq.com/display/pylonscookbook/Serving+a+Pylons+app+...

mdipierro

unread,
Feb 26, 2009, 4:09:41 PM2/26/09
to web2py Web Framework
... and you kept this powerful secret to yourself until now? Just
kidding... could you post some intructions on AlterEgo?

Massimo

Kirby Turner

unread,
Feb 26, 2009, 4:58:29 PM2/26/09
to web...@googlegroups.com
Thanks _p_.

I just might have to go that route. I will let you know.

-KIRBY

Kirby Turner

unread,
Feb 26, 2009, 5:02:36 PM2/26/09
to web...@googlegroups.com
The suggested fix did work! But now I'm encountering an error with
wsgiref.py.

I'm out snowboarding today and tomorrow so it will probably be this
weekend before I can return to the detective work.

-KIRBY

phecker

unread,
Feb 27, 2009, 12:19:18 PM2/27/09
to web2py Web Framework
Just finished:

Using web2py with IIS, MSSQL and Helicon ISAP_Rewrite 3 on Windows
Server 2003/2008

=> http://mdp.cti.depaul.edu/AlterEgo/default/show/207

_p_

Paul Eden

unread,
Feb 27, 2009, 12:22:21 PM2/27/09
to web...@googlegroups.com
Thanks!

Kirby Turner

unread,
Mar 1, 2009, 8:05:20 AM3/1/09
to web...@googlegroups.com
Big thanks!

-KIRBY

mdipierro

unread,
Mar 1, 2009, 10:00:51 AM3/1/09
to web2py Web Framework
Great. Post approved!
Reply all
Reply to author
Forward
0 new messages