Skip to content
This repository has been archived by the owner on Apr 9, 2023. It is now read-only.

Commit

Permalink
Sync transactions II
Browse files Browse the repository at this point in the history
  • Loading branch information
bloodbare committed Nov 17, 2016
1 parent ce29d26 commit b2401a4
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 10 deletions.
2 changes: 1 addition & 1 deletion buildout.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,6 @@ eggs =
plone.example

[versions]
ZODB = 5.0.0
ZODB = 5.0.1
ZEO = 5.0.2

22 changes: 16 additions & 6 deletions src/plone.server/plone/server/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,9 +335,14 @@ def make_app(config_file=None, settings=None):
fs = ZODB.FileStorage.FileStorage(dbconfig['path'])

db = DB(fs)
alsoProvides(db.open().root(), IDataBase)
transaction.commit()
db.close()
try:
if not IDataBase.providedBy(root):
alsoProvides(db.open().root(), IDataBase)
transaction.commit()
except:
pass
finally:
db.close()
# Set request aware database for app
db = RequestAwareDB(dbconfig['path'], **config)
dbo = DataBase(key, db)
Expand All @@ -348,9 +353,14 @@ def make_app(config_file=None, settings=None):
cs = ClientStorage(address)
db = DB(cs)

alsoProvides(db.open().root(), IDataBase)
transaction.commit()
db.close()
try:
if not IDataBase.providedBy(root):
alsoProvides(db.open().root(), IDataBase)
transaction.commit()
except:
pass
finally:
db.close()

# Set request aware database for app
cs = ClientStorage(address)
Expand Down
15 changes: 12 additions & 3 deletions src/plone.server/plone/server/traversal.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,20 @@ async def handler(self, request):
async with locked(self.resource):
view_result = await self.view()
if isinstance(view_result, ErrorResponse):
await sync(request)(txn.abort)
if SHARED_CONNECTION is False:
txn.abort()
else:
await sync(request)(txn.abort)
elif isinstance(view_result, UnauthorizedResponse):
await sync(request)(txn.abort)
if SHARED_CONNECTION is False:
txn.abort()
else:
await sync(request)(txn.abort)
else:
await sync(request)(txn.commit)
if SHARED_CONNECTION is False:
txn.commit()
else:
await sync(request)(txn.commit)
except Unauthorized:
await sync(request)(txn.abort)
view_result = UnauthorizedResponse(
Expand Down

0 comments on commit b2401a4

Please sign in to comment.