Commit 35a22887 authored by Vincent Pelletier's avatar Vincent Pelletier

CMFActivity.Activity.SQLBase: Const-ify row2key.

parent 94db4215
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
from collections import defaultdict from collections import defaultdict
from itertools import product from itertools import product
import operator
import sys import sys
import transaction import transaction
from random import getrandbits from random import getrandbits
...@@ -72,6 +73,9 @@ def sort_message_key(message): ...@@ -72,6 +73,9 @@ def sort_message_key(message):
_DequeueMessageException = Exception() _DequeueMessageException = Exception()
_ITEMGETTER0 = operator.itemgetter(0)
_IDENTITY = lambda x: x
def render_datetime(x): def render_datetime(x):
return "%.4d-%.2d-%.2d %.2d:%.2d:%09.6f" % x.toZone('UTC').parts()[:6] return "%.4d-%.2d-%.2d %.2d:%.2d:%09.6f" % x.toZone('UTC').parts()[:6]
...@@ -525,12 +529,10 @@ CREATE TABLE %s ( ...@@ -525,12 +529,10 @@ CREATE TABLE %s (
continue continue
column_list, to_sql = dependency_tester_dict[dependency_name] column_list, to_sql = dependency_tester_dict[dependency_name]
if len(column_list) == 1: if len(column_list) == 1:
def row2key(row): row2key = _ITEMGETTER0
key, = row
return key
dependency_sql = to_sql(dependency_value_dict.keys(), quote) dependency_sql = to_sql(dependency_value_dict.keys(), quote)
else: else:
row2key = lambda x: x row2key = _IDENTITY
# XXX: generated SQL could be simpler: for example, a dependency input # XXX: generated SQL could be simpler: for example, a dependency input
# as # as
# ('foo', ('bar', 'baz')) # ('foo', ('bar', 'baz'))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment