我在使用. _ _ 每次我尝试使用数据库例如设置默认值时:mod_wsgi
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"
并引发了同样的异常。我不明白为什么会发生这种情况以及如何避免这种错误。有任何想法吗?