[mod_python] Importing modules with mod_python

Graham Dumpleton graham.dumpleton at gmail.com
Fri Oct 17 18:58:14 EDT 2008


2008/10/18 Tiago Becker <tiagobecker at gmail.com>:
> Hello.
>
>
> I'm trying to use sqlalchemy with mod_python, but im getting a strange
> behavior when i try to use the function sessionmaker. Here is the error:
>
> AttributeError: 'module' object has no attribute 'sessionmaker'
>
>
> on the line:
>
> Session = sqlalchemy.orm.sessionmaker(
> autoflush=False, transactional=False)
>
>
>
> I've tried various methods to import the function with no sucess. Works fine
> on the console. Heres what i tried (changing the call to sessionmaker
> acordingly)
>
> import sqlalchemy, sqlalchemy.orm
>
> from  sqlalchemy.orm import *
>
> from  sqlalchemy.orm.session import *
>
> orm = apache.import_module('sqlalchemy.orm')
>
> orm = apache.import_module('sqlalchemy.orm.session')

Add debug which prints out the value of:

  sqlalchemy.orm.__file__

Ensure that the code file being used is actually the version you
expect to be used. Look at the source code for that file and verify
that the 'sessionmaker' function is actually in it. If you have
multiple versions of sqlalchemy installed, it could be picking up the
wrong one.

Graham


More information about the Mod_python mailing list