Re: psycopg used in a ASP page fails

From: Jason Erickson <jerickso(at)stickpeople(dot)com>
To: Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com>
Cc: Barend Köbben <kobben(at)itc(dot)nl>, "psycopg(at)postgresql(dot)org" <psycopg(at)postgresql(dot)org>
Subject: Re: psycopg used in a ASP page fails
Date: 2011-02-16 20:37:02
Message-ID: 20110216121352.V69731@stickpeople.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: psycopg

On Wed, 16 Feb 2011, Daniele Varrazzo wrote:

> 2011/2/16 Barend Kbben <kobben(at)itc(dot)nl>:
>> Hi Daniele,
>>
>>> Well, that sucks! But I think it may be your problem. Have
>>> you installed psycopg using easy_install?
>>
>> No. It's a Win32 install on a Windows Server 2003 box with IIS 6.0 (hence
>> the ASP). Your fix suggests that also ASP might have the problem that the
>> ASP engine has no write permission on a path, the one you mention to be
>> "PYTHON_EGG_INSTALL". Is there any way to find out where this (or its
>> equivalent) would be on Windows? Can't find it in windows Environment
>> variables and really don't know here else to look :-((
>
> If you haven't used easy install, the above issue should not apply: it
> seems only related to egg packages.
>
> I can only suggest you to try the psycopg 2.4 beta2 installation
> provided by Jason, where he has addressed dll compatibility problems.
> I personally don't have recent experience in debugging dll problems on
> windows.
>
> Please report which version of psycopg and python you are using in
> your message, thanks. It seems that things got more complex starting
> from python 2.6. Consider the option of compiling psycopg with mingw
> as explained in
> <http://psycopg.lighthouseapp.com/projects/62710/tickets/20>.
>
> -- Daniele

Instead of 'import psycopg2', does the following code work when run as an
ASP script?:
----------------------------------------------------------
from psycopg2._psycopg import __version__
----------------------------------------------------------

For craziness sakes, does the following code work in ASP land?:
----------------------------------------------------------
from psycopg2 import tz
----------------------------------------------------------

Also, verify that the following file exist (which it should, since it
works other ways):
%PYTHON_INSTALL_DIR%\Lib\site-packages\psycopg2\tz.py

Also, can you verify that there is not a psycopg directory or psycopg.py
file in that same directory?
%PYTHON_INSTALL_DIR%\Lib\site-packages\psycopg2

You didn't mention what version of python you are using?

With an ASP script, can you also try this code (I'm assuming that
Response.Write is similar to print, change otherwise):
----------------------------------------------------------
import sys
Reponse.Write(sys.path)
----------------------------------------------------------
This code will print the 'search' path for python modules. This search
path should be the same as when you run the python interpreter by hand,
tho maybe ASP is adding something to it?? Verify that they are the same.

Can you also verify that it is finding the correct 'module' with the
following asp code:
----------------------------------------------------------
import imp
f, filename, description = imp.find_module('psycopg2')
Response.Write('psycopg2 file location: '+filename)
----------------------------------------------------------
What it prints should be the path to the psycopg2 install directory.
Verify that it is pointing to the correct directory where you installed
psycopg2, and that the file tz.py is in that directory.

This is interesting because of where it fails. First off, it is finding a
psycopg2 directory, as it is importing (or trying to import) __init__.
Second, it is not failing on loading the dll, but failing on a step before
loading the dll, where it is loading a module inside the psycopg2 package
(tz). It is almost as if the sys.path is different between ASP land and
normal land, causing the issue.

It is possible that it is similar to the manifest issue that we see with
modwsgi, but I'm thinking not. Please try the beta version at:
http://www.stickpeople.com/projects/python/win-psycopg/devel/
as well.

-jason

In response to

Responses

Browse psycopg by date

  From Date Subject
Next Message Jason Erickson 2011-02-16 21:00:46 Re: RELEASE: psycopg 2.4 beta 2
Previous Message Daniele Varrazzo 2011-02-16 15:25:00 Re: psycopg used in a ASP page fails