Skip to content

Commit

Permalink
Adds compatibility with Morepath 0.13
Browse files Browse the repository at this point in the history
  • Loading branch information
Denis Krienbühl committed Apr 6, 2016
1 parent 4af0164 commit 868014d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 22 deletions.
3 changes: 1 addition & 2 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ CHANGES
0.6 (unreleased)
================

- Nothing changed yet.

- Adds compatibility with Morepath 0.13.

0.5 (2015-08-17)
================
Expand Down
4 changes: 2 additions & 2 deletions more/transaction/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ def get_transaction_settings():

@TransactionApp.tween_factory(over=morepath.EXCVIEW)
def transaction_tween_factory(app, handler, transaction=transaction):
attempts = app.registry.settings.transaction.attempts
commit_veto = app.registry.settings.transaction.commit_veto
attempts = app.settings.transaction.attempts
commit_veto = app.settings.transaction.commit_veto

def transaction_tween(request):
manager = transaction.manager
Expand Down
27 changes: 10 additions & 17 deletions more/transaction/tests/test_transaction.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import morepath

from transaction import TransactionManager
from transaction.interfaces import TransientError
from morepath import setup
from more.transaction import TransactionApp
from more.transaction.main import (transaction_tween_factory,
default_commit_veto)
Expand All @@ -10,10 +11,7 @@

def test_multiple_path_variables():

config = setup()

class TestApp(TransactionApp):
testing_config = config
attempts = 0

@TestApp.path('/{type}/{id}')
Expand All @@ -37,8 +35,8 @@ def get_retry_attempts():
return 2

import more.transaction
config.scan(more.transaction)
config.commit()
morepath.scan(more.transaction)
morepath.commit(TestApp)

client = Client(TestApp())
response = client.get('/document/1')
Expand Down Expand Up @@ -71,7 +69,7 @@ class Conflict(TransientError):
count = []
response = DummyResponse()
app = DummyApp()
app.registry.settings.transaction.attempts = 3
app.settings.transaction.attempts = 3

def handler(request, count=count):
count.append(True)
Expand Down Expand Up @@ -153,7 +151,7 @@ def handler(request):

def test_500_with_default_commit_veto():
app = DummyApp()
app.registry.settings.transaction.commit_veto = default_commit_veto
app.settings.transaction.commit_veto = default_commit_veto

response = DummyResponse()
response.status = '500 Bad Request'
Expand All @@ -178,7 +176,7 @@ def handler(request):
return response

app = DummyApp()
app.registry.settings.transaction.commit_veto = None
app.settings.transaction.commit_veto = None

txn = DummyTransaction()
publish = transaction_tween_factory(app, handler, txn)
Expand All @@ -196,7 +194,7 @@ def test_commit_veto_true():
def veto_true(request, response):
return True

app.registry.settings.transaction.commit_veto = veto_true
app.settings.transaction.commit_veto = veto_true

response = DummyResponse()

Expand All @@ -219,7 +217,7 @@ def test_commit_veto_false():
def veto_false(request, response):
return False

app.registry.settings.transaction.commit_veto = veto_false
app.settings.transaction.commit_veto = veto_false

response = DummyResponse()

Expand Down Expand Up @@ -263,14 +261,9 @@ def __init__(self):
self.commit_veto = None


class DummyRegistry(object):
def __init__(self):
self.settings = DummySettingsSectionContainer()


class DummyApp(object):
def __init__(self):
self.registry = DummyRegistry()
self.settings = DummySettingsSectionContainer()


class DummyTransaction(TransactionManager):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
zip_safe=False,
install_requires=[
'setuptools',
'morepath >= 0.7',
'morepath >= 0.13',
'transaction',
],
extras_require=dict(
Expand Down

0 comments on commit 868014d

Please sign in to comment.