On 06/25/2010 12:03 PM, Wichert Akkerman wrote:
> I am using repoze.zodbconn in a BFG application but I suspect it is not
> working as it should be: as soon as multiple requests come in at the
> same time I get a lot of locking errors and broken results:
>
> LockError: Couldn't lock
> '/Users/wichert/Work/code/buildout/blackbox/var/Data.fs.lock'
>
> The way I've setup repoze.zodbconn is
>
>       from repoze.zodbconn.finder import PersistentApplicationFinder
>       from myproject import appmaker
>       finder = PersistentApplicationFinder(settings["zodb.url"], appmaker)
>       def get_root(request):
>           return finder(request.environ)
>       return get_root

According to the docs[1], your code should look more like this:

       from repoze.zodbconn.finder import PersistentApplicationFinder
       from myproject import appmaker
       finder = PersistentApplicationFinder(settings["zodb.url"],
           appmaker)
       app = finder(request.environ)
       return app

OTOH, personally, I don't think this is a good pattern.  I think the 
right idea is to open the connection in the WSGI stack [2].  That way, 
other WSGI components can use the connection, and you can guarantee that 
the connection gets closed.  repoze.zodbconn supports both patterns.

Shane

[1] http://docs.repoze.org/zodbconn/narr.html#helper-creating-a-root-object

[2] 
http://docs.repoze.org/zodbconn/narr.html#connecting-to-zodb-in-a-wsgi-pipeline
_______________________________________________
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev

Reply via email to