在塔中使用具有声明性语法的repoze.what

|| 我正在用Pylons编写应用程序,我想添加一个授权方案。我选择了repoze.what。我遵循了Pylons食谱中的教程: http://wiki.pylonshq.com/display/pylonscookbook/Authorization+with+repoze.what 问题是在“ 0”中,我需要包括“用户”,“组”和“权限”的模型。在模型中使用声明式基础,当我要部署时会给我一个错误:
sqlalchemy.exc.UnboundExecutionError: No engine is bound to this Table\'s MetaData.
Pass an engine to the Table via autoload_with=<someengine>, or associate the MetaData
with an engine via metadata.bind=<someengine>
我在这里发现了类似的问题: Pylons中具有自动加载(反射)功能的SQLAlchemy声明性语法 我在
__init__.py
的单独文件中声明了所有授权模型。我也遵循上述问题的所有指示,但仍然存在问题。 有人找到解决方案了吗?     
已邀请:
        我想我找到了解决方案。我只是在包含授权模型的模块中创建引擎,并将其绑定到元数据。我不知道为什么init_model不能单独执行此操作。因此,这不是声明性语法的问题。对造成的不便表示歉意。     
        在模型“ 2”中,您需要将引擎绑定到会话。
def init_model(engine):
    \"\"\"Call me before using any of the tables or classes in the model\"\"\"
    ## Reflected tables must be defined and mapped here
    #global reflected_table
    #reflected_table = sa.Table(\"Reflected\", meta.metadata, autoload=True,
    #                           autoload_with=engine)
    #orm.mapper(Reflected, reflected_table)

    session = orm.sessionmaker(bind=engine, autoflush=True, autocommit=False)
    meta.metadata.bind = engine
    meta.engine = engine
    meta.Session = orm.scoped_session(session)
资源: http://docs.pylonsproject.org/projects/pylons_framework/dev/advanced_models.html     

要回复问题请先登录注册