[pkg-fso-commits] [SCM] FSO frameworkd Debian packaging branch, debian, updated. upstream/0.9.5.5-717-g0f98819
Daniele Ricci
daniele.athome at gmail.com
Sat Aug 6 08:20:09 UTC 2011
The following commit has been merged in the debian branch:
commit 5e5970b487d61fb221a3bd0948b6a2f43ea9ad4b
Author: Daniele Ricci <daniele.athome at gmail.com>
Date: Mon Oct 18 22:17:03 2010 +0200
opimd: some small fixes
Signed-off-by: Daniele Ricci <daniele.athome at gmail.com>
diff --git a/framework/subsystems/opimd/db_handler.py b/framework/subsystems/opimd/db_handler.py
index 04ea24e..8518f4a 100644
--- a/framework/subsystems/opimd/db_handler.py
+++ b/framework/subsystems/opimd/db_handler.py
@@ -75,9 +75,9 @@ def regex_matches(string, pattern):
logger.error("While matching regex (pattern = %s, string = %s) got: %s",unicode(pattern), unicode(string), exp)
return 0
-def dict_factory(cursor, row, skip_field = None):
+def dict_factory(description, row, skip_field = None):
d = {}
- for idx, col in enumerate(cursor.description):
+ for idx, col in enumerate(description):
if col[0] != skip_field:
d[col[0]] = row[idx]
return d
@@ -156,10 +156,10 @@ class DbHandler(object):
cur.execute(self.get_create_type_index(type))
self.con.commit()
- cur.execute("select value from info where field_name = 'version'")
+ cur.execute("SELECT value FROM info WHERE field_name = 'version'")
version_info = cur.fetchone()
if version_info == None:
- cur.execute("insert into info values(?, ?)", ('version', _SQLITE_DATABASE_VERSION))
+ cur.execute("INSERT INTO info VALUES(?, ?)", ('version', _SQLITE_DATABASE_VERSION))
self.con.commit()
elif version_info[0] != _SQLITE_DATABASE_VERSION:
raise Exception("Database version mismatch, needed %s, current is %s" % (_SQLITE_DATABASE_VERSION, version_info[0]))
@@ -348,7 +348,7 @@ class DbHandler(object):
continue
if '_limit' in query_desc:
- query = query + " LIMIT ?"
+ query = "SELECT * FROM (" + query + ") LIMIT ?"
params.append(int(query_desc['_limit']))
return {'Query':query, 'Parameters':params}
@@ -366,18 +366,21 @@ class DbHandler(object):
map[field] = name
return map
- def get_full_result(self, raw_result, join_parameters, cursor = None):
+ def get_full_result(self, raw_result, join_parameters, description = None):
if raw_result == None:
return None
#convert from a list of tuples of ids to a list of ids
ids = map(lambda x: x[0], raw_result)
- if cursor:
+
+ # if we have 'description' we can pass other columns to get_content()
+ # to be included in the returned result set through dbus response
+ if description:
try:
columns = map(lambda x: x[0], cursor.description)
skip_field = columns[0]
except:
skip_field = None
- other_fields = map(lambda x: dict_factory(cursor, x, skip_field), raw_result)
+ other_fields = map(lambda x: dict_factory(description, x, skip_field), raw_result)
else:
other_fields = []
@@ -397,7 +400,7 @@ class DbHandler(object):
cur = self.con.cursor()
cur.execute(query['Query'], query['Parameters'])
- res = self.get_full_result(cur.fetchall(), join_parameters, cur)
+ res = self.get_full_result(cur.fetchall(), join_parameters, cur.description)
cur.close()
return res
@@ -441,6 +444,7 @@ class DbHandler(object):
pass
tmp['Path'] = self.domain.id_to_path(id)
tmp['EntryId'] = id
+ # include any other custom field from query
try:
for field, value in other_fields[row_index].iteritems():
tmp[field] = value
diff --git a/framework/subsystems/opimd/pimd_messages.py b/framework/subsystems/opimd/pimd_messages.py
index 4edcf78..6003dff 100644
--- a/framework/subsystems/opimd/pimd_messages.py
+++ b/framework/subsystems/opimd/pimd_messages.py
@@ -133,12 +133,12 @@ class QueryManager(DBusFBObject):
query['sql'] = """
SELECT m.""" + db_prefix + """_id """ + db_prefix + """_id,
(
- SELECT count(*) FROM """ + db_prefix + """_phonenumber
+ SELECT COUNT(*) FROM """ + db_prefix + """_phonenumber
WHERE field_name = 'Peer'
- and value = p1.value
+ AND value = p1.value
) TotalCount,
(
- SELECT count(*) FROM
+ SELECT COUNT(*) FROM
(
""" + db_prefix + """_boolean b
JOIN
@@ -165,7 +165,7 @@ SELECT m.""" + db_prefix + """_id """ + db_prefix + """_id,
WHERE t.field_name = 'Timestamp' AND
t.value IN (
- SELECT max(timestamp) timestamp FROM (
+ SELECT MAX(timestamp) timestamp FROM (
(
SELECT date_t.""" + db_prefix + """_id AS """ + db_prefix + """_id, date_t.value AS timestamp FROM
""" + db_prefix + """_date AS date_t
@@ -541,8 +541,8 @@ class MessagesFSO(object):
else:
entry['Direction'] = 'out'
- if status == 'read': entry['New'] = 1
- if status == 'sent': entry['New'] = 0
+ if status in ('read', 'sent'):
+ entry['New'] = 0
entry['Peer'] = number
--
FSO frameworkd Debian packaging
More information about the pkg-fso-commits
mailing list