I have a problem using flask-zodb in a simple Flask app deployed with mod_wsgi
.
Every time I try to use the DB for example setting defaults:
from flaskext.zodb import zodb, List
db = ZODB(app)
app.config.from_pyfile( settings.py ) # here I have defined ZODB_STORAGE = "/home/username/webapps/myapp/htdocs/Data.fs"
@app.before_request
def set_db_defaults():
if entries not in db:
db[ entries ] = List()
或者在类似:
@app.route( /add , methods=[ POST ])
def add_entry():
db[ entries ].append(request.form)
flash( New entry was successfully posted )
return redirect(url_for( show_entries ))
我犯了以下错误:
[Sat May 19 16:52:30 2012] [error] [client 127.0.0.1]
self._lock_file = LockFile(file_name + .lock )
[Sat May 19 16:52:30 2012] [error] [client 127.0.0.1] File
"/home/userame/.virtualenvs/myapp/lib/python2.7/site-packages/zc/lockfile/__init__.py",
line 76, in __init__
[Sat May 19 16:52:30 2012] [error] [client 127.0.0.1] _lock_file(fp)
[Sat May 19 16:52:30 2012] [error] [client 127.0.0.1] File
"/home/username/.virtualenvs/myapp/lib/python2.7/site-packages/zc/lockfile/__init__.py",
line 59, in _lock_file
[Sat May 19 16:52:30 2012] [error] [client 127.0.0.1] raise
LockError("Couldn t lock %r" % file.name)
[Sat May 19 16:52:30 2012] [error] [client 127.0.0.1] LockError:
Couldn t lock /home/username/webapps/myapp/htdocs/Data.fs.lock
应用软件在开发令人羡慕的状态中运作良好, 我不认为有前意识问题, 因为我想设置:
ZODB_STORAGE = "/tmp"
也提出了同样的例外。我不明白为什么会发生这种情况以及如何避免这种错误。有什么想法吗?