Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Don't call `setUser` on transaction if there is no user logged in. Th…

…is could

cause the username set on the transaction to be a strange string: " None".
  • Loading branch information...
commit 6e24757958c797ef411fb87dc147c93e04336f1a 1 parent 228ff03
@chrisrossi chrisrossi authored
View
1  .gitignore
@@ -12,3 +12,4 @@ dist/
nosetests.xml
pyramid_tm/coverage.xml
env*/
+venv/
View
6 CHANGES.txt
@@ -1,3 +1,9 @@
+Unreleased
+----------
+
+- Don't call `setUser` on transaction if there is no user logged in. This could
+ cause the username set on the transaction to be a strange string: " None".
+
0.7 (2012-12-30)
----------------
View
3  pyramid_tm/__init__.py
@@ -58,7 +58,8 @@ def tm_tween(request):
if attempts != 1:
request.make_body_seekable()
t = manager.get()
- t.setUser(userid, '')
+ if userid:
+ t.setUser(userid, '')
t.note(request.path_info)
response = handler(request)
if manager.isDoomed():
View
7 pyramid_tm/tests.py
@@ -56,7 +56,7 @@ def setUp(self):
self.request = DummyRequest()
self.response = DummyResponse()
self.registry = DummyRegistry()
-
+
def _callFUT(self, handler=None, registry=None, request=None, txn=None):
if handler is None:
def handler(request):
@@ -114,7 +114,7 @@ class Conflict(TransientError):
def handler(request, count=count):
raise Conflict
self.assertRaises(Conflict, self._callFUT, handler=handler)
-
+
def test_handler_isdoomed(self):
txn = DummyTransaction(True)
self._callFUT(txn=txn)
@@ -229,6 +229,7 @@ class DummyTransaction(TransactionManager):
committed = False
aborted = False
_resources = []
+ username = None
def __init__(self, doomed=False, retryable=False):
self.doomed = doomed
@@ -248,7 +249,7 @@ def get(self):
return self
def setUser(self, name, path='/'):
- self.username = name
+ self.username = "%s %s" % (path, name)
def isDoomed(self):
return self.doomed
Please sign in to comment.
Something went wrong with that request. Please try again.