在 pylons 中使用带有声明性语法的 repoze.what
我正在 Pylons 中编写一个应用程序,我想添加一个授权方案。我选择了repoze.what。我按照 Pylons 食谱中的教程进行操作:
http://wiki.pylonshq。 com/display/pylonscookbook/Authorization+with+repoze.what
问题是在 lib/auth.py
中我需要包含用户、组的模型和许可。在模型中使用声明性基础,当我想要部署时,它会给我一个错误:
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>
我在这里发现类似的问题:
SQLAlchemy 声明性语法与 Pylons 中的自动加载(反射)
我在单独的文件中声明了所有授权模型__init__.py
。我也遵循了上述问题的所有指示,但仍然有问题。 有人找到解决方案了吗?
I'm writing an application in Pylons and I want to add an authorization scheme. I've chosen repoze.what. I followed the tutorial from Pylons cookbook:
http://wiki.pylonshq.com/display/pylonscookbook/Authorization+with+repoze.what
The problem is that in lib/auth.py
I need to include models for User, Group and Permission. Using declarative base in model, it gives me an error when I want to deploy:
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>
I found similar problem here:
SQLAlchemy declarative syntax with autoload (reflection) in Pylons
I have all the models for authorization declared in a separate file from __init__.py
. I also followed all indications from above question but there is still something wrong.
Anyone found a solution?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我想我找到了解决方案。我只是在包含授权模型的模块中创建一个引擎,并将其绑定到元数据。我不知道为什么 init_model 不自己这样做。所以这不是声明性语法的问题。抱歉给您带来不便。
I think I found a solution. I just create an engine in the module that contains models for authorization and I bind it to the metadata. I have no idea why init_model does not do this on its own. So this is not a problem of declarative syntax. Sorry for inconvenience.
在模型
__init__.py
中,您需要将引擎绑定到会话。资源:
http://docs.pylonsproject.org/projects/pylons_framework/dev/advanced_models.html
In the model
__init__.py
you need to bind the engine to the session.Resources:
http://docs.pylonsproject.org/projects/pylons_framework/dev/advanced_models.html