无法让 Pylons 与 mongokit 一起使用
我尝试按照以下指南将 mongokit 集成到 pylons 中:http://namlook.github。 com/mongokit/pylons.html
当我使用 Paster 提供服务时,它会抛出错误:
File "/home/ciferkey/Projects/runnr-site/runnrsite/config/environment.py", line 29, in load_environment
config['pylons.app_globals'] = app_globals.Globals(config)
TypeError: __init__() takes exactly 1 argument (2 given)
如果我将一个虚拟参数扔到 Globals 的 init 中:
def __init__(self, foo):
那么它不再抛出错误,而是而是抛出:
File "/usr/lib/pymodules/python2.6/pylons/configuration.py", line 141, in __getitem__
return dict.__getitem__(self, name)
KeyError: 'db_host'
现在这是引用 lib/app_globals.py 中的行,指南告诉您要输入:
self.connection = Connection(
host = config['db_host'],
port = int(config['db_port']),
)
我知道我要用实际信息替换 db_host 和 db_port,但无论我尝试什么,它都会抛出同样的错误。关于为什么会发生这种情况有什么想法吗?
I've tried following the guide for intergrating mongokit into pylons thats here: http://namlook.github.com/mongokit/pylons.html
When I go to serve with paster it throws the error:
File "/home/ciferkey/Projects/runnr-site/runnrsite/config/environment.py", line 29, in load_environment
config['pylons.app_globals'] = app_globals.Globals(config)
TypeError: __init__() takes exactly 1 argument (2 given)
if I throw a dummy parameter into the init for Globals:
def __init__(self, foo):
then it no longer throw the error but instead throws:
File "/usr/lib/pymodules/python2.6/pylons/configuration.py", line 141, in __getitem__
return dict.__getitem__(self, name)
KeyError: 'db_host'
Now this is referencing the lines in lib/app_globals.py that the guide tells you to put in:
self.connection = Connection(
host = config['db_host'],
port = int(config['db_port']),
)
and i understand that I'm to replace db_host and db_port with the actual information, but no matter what I try it throws the same error. Any ideas as to why this is happening?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你尝试过Mongoengine吗?我目前正在将它用于我自己的 Pylons 项目,发现它非常易于设置和使用。 http://www.cleverkoala.com/2010/ 09/如何将 mongoengine 集成到 pylons/
Have you tried Mongoengine? I'm currently using it for my own Pylons project and found it very easy to setup and use. http://www.cleverkoala.com/2010/09/how-to-integrate-mongoengine-into-pylons/