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

Commit

Permalink
provide interface for database to get transaction manager
Browse files Browse the repository at this point in the history
  • Loading branch information
vangheem committed Dec 28, 2016
1 parent 96749aa commit b24f3a5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/plone.server/plone/server/commands/migrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,11 @@ def run(self, arguments, settings, app):
app, to_version=arguments.to_version,
from_version=installed_versions.get(app))
if len(_migrations) > 0:
trns = db.get_transaction_manager()
if not arguments.dry_run and not arguments.report:
db.tm_.begin()
trns.begin()
migrate.run_site_migrations(site, _migrations, db)
if not arguments.dry_run and not arguments.report:
db.tm_.commit()
trns.commit()

self.report(arguments, sites, apps)
5 changes: 4 additions & 1 deletion src/plone.server/plone/server/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,9 @@ def __init__(self, id, db):
self._conn = None
self.tm_ = RequestAwareTransactionManager()

def get_transaction_manager(self):
return self.tm_

def open(self):
tm_ = RequestAwareTransactionManager()
return self._db.open(transaction_manager=tm_)
Expand Down Expand Up @@ -221,7 +224,7 @@ def keys(self):
return list(self.conn.root().keys())

def __setitem__(self, key, value):
""" This operation can only be done throw HTTP request
""" This operation can only be done through HTTP request
We can check if there is permission to delete a site
XXX TODO
Expand Down
6 changes: 5 additions & 1 deletion src/plone.server/plone/server/interfaces/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ class IApplication(Interface):


class IDatabase(Interface):
pass
def get_transaction_manager():
pass

def open():
pass


class IStaticFile(Interface):
Expand Down

0 comments on commit b24f3a5

Please sign in to comment.