1
0
mirror of https://github.com/django/django.git synced 2025-07-05 10:19:20 +00:00

[soc2009/multidb] Change a conditional to be more idiomatic.

git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2009/multidb@11421 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Alex Gaynor 2009-08-09 02:52:45 +00:00
parent 5fe110e149
commit 50ad53dbca
2 changed files with 12 additions and 1 deletions

View File

@ -14,6 +14,11 @@ from django.test.client import Client
from django.utils import simplejson from django.utils import simplejson
from django.utils.encoding import smart_str from django.utils.encoding import smart_str
try:
all
except NameError:
from django.utils.itercompat import all
normalize_long_ints = lambda s: re.sub(r'(?<![\w])(\d+)L(?![\w])', '\\1', s) normalize_long_ints = lambda s: re.sub(r'(?<![\w])(\d+)L(?![\w])', '\\1', s)
normalize_decimals = lambda s: re.sub(r"Decimal\('(\d+(\.\d*)?)'\)", lambda m: "Decimal(\"%s\")" % m.groups()[0], s) normalize_decimals = lambda s: re.sub(r"Decimal\('(\d+(\.\d*)?)'\)", lambda m: "Decimal(\"%s\")" % m.groups()[0], s)
@ -433,7 +438,8 @@ def connections_support_transactions():
Returns True if all connections support transactions. This is messy Returns True if all connections support transactions. This is messy
because 2.4 doesn't support any or all. because 2.4 doesn't support any or all.
""" """
return len([None for conn in connections.all() if conn.settings_dict['DATABASE_SUPPORTS_TRANSACTIONS']]) == len(connections.all()) return all(conn.settings_dict['DATABASE_SUPPORTS_TRANSACTIONS']
for conn in connections.all())
class TestCase(TransactionTestCase): class TestCase(TransactionTestCase):
""" """

View File

@ -73,3 +73,8 @@ def sorted(in_value):
out_value.sort() out_value.sort()
return out_value return out_value
def all(iterable):
for item in iterable:
if not item:
return False
return True