[mod_python] Wierd pyPGSQL stuff with mod_python 3.1.2b

Julian Ciccale jciccale at mac.com
Mon Nov 24 09:32:57 EST 2003

Which python version are you using?

Are you sure the python interpreter that you use from the command line and the one that gets called wihthin httpd are the same?

Check it with
import sys
print sys.version

On Monday, November 24, 2003, at 07:02AM, Keith Randall <randallk at cpsc.ucalgary.ca> wrote:

>I have a script that works fine with mod_python 2.7.8 + apache 1.3.28,
>and I want to run it under apache 2.0.48 with mod_python 3.1.2b for
>the session handling stuff.
>When I try to connect to my postgresql database in the following way:
>from pyPgSQL import PgSQL
>pdb = PgSQL.connect( host = 'foo' , port='5432',database='foo',user='joe')
>Apache error_log says:
>PythonHandler mod_python.publisher: AttributeError: 'module' object has no attribute 'connect'
>and indeed when I do a dir(pgSQL), it lists the postgres-python datatypes but no connect function.
>When I do the same outside apache/mod_python I can see the connect function.
>Any thoughts?
>running within mod_python:
>['BooleanType', 'BufferType', 'BuiltinFunctionType',
>'BuiltinMethodType', 'ClassType', 'CodeType', 'ComplexType',
>'DateTime', 'DictProxyType', 'DictType', 'DictionaryType',
>'EllipsisType', 'FileType', 'FloatType', 'FrameType', 'FunctionType',
>'GeneratorType', 'InstanceType', 'IntType', 'LambdaType', 'ListType',
>'LongType', 'MethodType', 'ModuleType', 'NoneType',
>'NotImplementedType', 'ObjectType', 'SliceType', 'StringType',
>'StringTypes', 'TracebackType', 'TupleType', 'TypeType',
>'UnboundMethodType', 'UnicodeType', 'XRangeType', '__builtins__',
>'__doc__', '__file__', '__name__', 'copy', 'getdefaultencoding',
>'getrefcount', 'new', 'noWeakRef', 're', 'string', 'sys', 'weakref']
>running outside mod_python:
>['BAD_RESPONSE', 'BINARY', 'BOOLEAN', 'BooleanType', 'BufferType',
>'BuiltinFunctionType', 'BuiltinMethodType', 'COMMAND_OK',
>'CodeType', 'ComplexType', 'Connection', 'Cursor', 'DATETIME',
>'DBAPITypeObject', 'DataError', 'DatabaseError', 'Date',
>'DateFromTicks', 'DateTime', 'DateTimeDelta', 'DateTimeDeltaType',
>'DateTimeType', 'DictProxyType', 'DictType', 'DictionaryType',
>'EMPTY_QUERY', 'EllipsisType', 'Error', 'FATAL_ERROR', 'FileType',
>'FloatType', 'FrameType', 'FunctionType', 'GeneratorType',
>'INV_SEEK_SET', 'INV_WRITE', 'InstanceType', 'IntType',
>'IntegrityError', 'InterfaceError', 'InternalError', 'LambdaType',
>'ListType', 'LongType', 'MethodType', 'ModuleType', 'NONFATAL_ERROR',
>'NUMBER', 'NoneType', 'NotImplementedType', 'NotSupportedError',
>'OTHER', 'ObjectType', 'OperationalError', 'PG_ABSTIME', 'PG_ACLITEM',
>'PG_FLOAT', 'PG_FLOAT4', 'PG_FLOAT8', 'PG_False', 'PG_INET',
>'POLLING_READING', 'POLLING_WRITING', 'PQconndefaults', 'PQconnectdb',
>'PQftypeName', 'PQresStatus', 'PQresType', 'PgArray', 'PgBoolean',
>'PgBooleanFromInteger', 'PgBooleanFromString', 'PgBooleanType',
>'PgBytea', 'PgConnectionType', 'PgInt2', 'PgInt2Type', 'PgInt8',
>'PgInt8Type', 'PgLargeObject', 'PgLargeObjectType', 'PgMoney',
>'PgNumeric', 'PgOther', 'PgQuoteBytea', 'PgQuoteString',
>'PgResultSet', 'PgResultType', 'PgTypes', 'PgUnQuoteBytea',
>'PgVersion', 'PgVersionType', 'ProgrammingError', 'RESULT_DDL',
>'STRING', 'SliceType', 'StringType', 'StringTypes', 'TUPLES_OK',
>'Time', 'TimeFromTicks', 'Timestamp', 'TimestampFromTicks',
>'TracebackType', 'TupleType', 'TypeCache', 'TypeType',
>'UnboundMethodType', 'UnicodeType', 'Warning', 'XRangeType',
>'__builtins__', '__doc__', '__file__', '__name__', '_handleArray',
>'_quote', '_quoteall', 'apilevel', 'connect', 'copy',
>'dateTimeDelta2Interval', 'fetchReturnsList', 'getdefaultencoding',
>'getrefcount', 'libpq', 'make_PgResultSetClass', 'new',
>'noPostgresCursor', 'noWeakRef', 'paramstyle', 're', 're_4UP',
>'re_DQL', 're_DRI', 're_DRT', 'replace', 'string', 'sys',
>'threadsafety', 'version', 'weakref']
>LoadModule python_module /var/www2/modules/mod_python.so
><Directory /var/www2/htdocs/billing>  
>SetHandler python-program
>PythonHandler mod_python.publisher
>Mod_python mailing list
>Mod_python at modpython.org

More information about the Mod_python mailing list