Python “错误”;找不到映射器上配置的绑定";用于炼金术和塔架

Python “错误”;找不到映射器上配置的绑定";用于炼金术和塔架,python,sqlalchemy,pylons,Python,Sqlalchemy,Pylons,我不确定我做错了什么来保证这条信息。如果您对我的配置有任何帮助,我们将不胜感激 """The application's model objects""" import sqlalchemy as sa from sqlalchemy import orm from project.model import meta def now(): return datetime.datetime.now() def init_model(engine): """Call me be

我不确定我做错了什么来保证这条信息。如果您对我的配置有任何帮助,我们将不胜感激

"""The application's model objects"""
import sqlalchemy as sa
from sqlalchemy import orm

from project.model import meta

def now():
    return datetime.datetime.now()

def init_model(engine):
    """Call me before using any of the tables or classes in the model"""
    sm = orm.sessionmaker(autoflush=True, autocommit=True, bind=engine)
    meta.Session.configure(bind=engine)
    meta.engine = engine
    meta.Session = orm.scoped_session(sm)

class User(object):
    pass

t_user = sa.Table("User", meta.metadata,
sa.Column("id", sa.types.Integer, primary_key=True),
sa.Column("name", sa.types.String(100), nullable=False),
sa.Column("first_name", sa.types.String(100), nullable=False),
sa.Column("last_name", sa.types.String(100), nullable=False),
sa.Column("email", sa.types.String(100), nullable=False),
sa.Column("password", sa.types.String(32), nullable=False)
)

orm.mapper(User,t_user)
从python控制台,我正在执行:

from project.model import *

mr_jones = User()
meta.Session.add(mr_jones)
mr_jones.name = 'JR Jones'
meta.Session.commit()
我收到的错误是:

sqlalchemy.exc.UnboundExecutionError: Could not locate a bind configured on mapper Mapper|User|User or this Session

感谢您的帮助。

此问题已解决。我不知道从CLI使用挂架时,必须包括整个环境:

from paste.deploy import appconfig
from pylons import config

from project.config.environment import load_environment

conf = appconfig('config:development.ini', relative_to='.')
load_environment(conf.global_conf, conf.local_conf)

from project.model import *

在此之后,数据库查询将毫无问题地执行。

如果要通过
pip
分发包安装它,那么
project.config.environment
模块的名称是什么?