On Tue, Jan 10, 2012 at 5:14 PM, Álvaro J. Iradier <airad...@gmail.com> wrote: > Hi, > > I was trying to distribute an application with web2py binary for > windows, but I required the PostgreSQL driver. So I copied the > psycopg2 files to site-packages in the web2py binary folder. > > If I start a shell from an application, I can import psycopg2 and > connect to the database. However, it looks like the DAL does not > recognize the psycopg2 driver. I am getting the error: > > > Traceback (most recent call last): > File "gluon/restricted.py", line 204, in restricted > File "C:/Users/airadier/Downloads/web2py_win/web2py/applications/ > init/models/10_db.py", line 13, in <module> > File "gluon/dal.py", line 4749, in __init__ > RuntimeError: Failure to connect, tried 5 times: > Traceback (most recent call last): > File "gluon/dal.py", line 4736, in __init__ > File "gluon/dal.py", line 1867, in __init__ > RuntimeError: Unable to import driver > > My guess is when DAL is being initialized, the site-packages folder is > not yet in the sys.path, so the following fails: > > try: > import psycopg2 > from psycopg2.extensions import adapt as psycopg2_adapt > drivers.append('PostgreSQL') > except ImportError: > logger.debug('no psycopg2 driver') > > Is there a reason for this? Is it a bug or a feature?
Mmm, site-packages seems to be added in main.py, befor dal is imported, calling the function create_missing_folders . If I'm correct, it should see the psycopg2 module > Is there other way to acomplish these? I think you could download and install python, psycopg and web2py from source, and then use py2exe to make an installer. BTW, I'm working on pg8000 support, a pure python postgresql interface, you can see the changes in my clone: http://code.google.com/r/reingart-web2py/source/detail?r=3837efb84b1f you can download with mercurial: hg clone https://reing...@code.google.com/r/reingart-web2py/ hg update pg8000 If you try it, please tell me if you find any issue. With this changes, you'll not need anything else (nor even psycopg2, and pg8000 is inside contrib) > And is it allowed to distribute a binary web2py including the PostgreSQL > driver? Psycopg2 has a LGLP licence, the same as web2py, and the license of libq IIRC is the same as PostgreSQL: BSD so it shouldn't be an issue: http://initd.org/psycopg/license/ pg8000 has also a BSD-like license > Thanks in advance. Best regards, Mariano Reingart http://www.sistemasagiles.com.ar http://reingart.blogspot.com