[Sugar-devel] [PATCH Browse] Store empty strings instead of None in the places sqlite database.
Manuel Quiñones
manuq at laptop.org
Wed Mar 28 11:59:02 EDT 2012
The SQL model sets "text" as the fields type for uri and title.
However, sqlite uses a dynamic type sistem [1] and our Place class was
initializing those attributes with None. As a consequence, when the
user types something in the toolbar entry, and a search is made to
show a drop-down list for autocomplete, the drop-down list is being
filled with None, but is defined as Gtk.ListStore(str, str). This is
provoking a GTK+ error that crashes the activity in the XO, as bug #3400
documents.
In order to keep backwards compatibility, if the database returns None
for does fields, they are translated to empty strings in
_place_from_row() method of place.SqliteStore .
[1] http://sqlite.org/datatype3.html
Signed-off-by: Manuel Quiñones <manuq at laptop.org>
Signed-off-by: Simon Schampijer <simon at laptop.org>
---
places.py | 12 ++++++++++--
1 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/places.py b/places.py
index 8b98c79..5001b43 100644
--- a/places.py
+++ b/places.py
@@ -24,9 +24,9 @@ _store = None
class Place(object):
- def __init__(self, uri=None):
+ def __init__(self, uri=''):
self.uri = uri
- self.title = None
+ self.title = ''
self.bookmark = False
self.gecko_flags = 0
self.visits = 0
@@ -121,6 +121,14 @@ class SqliteStore(object):
def _place_from_row(self, row):
place = Place()
+ # Return uri and title as empty strings instead of None.
+ # Previous versions of Browse were allowing to store None for
+ # those fields in the places database. See ticket #3400 .
+ if row[0] == None:
+ row = tuple([''] + list(row[1:]))
+ if row[1] == None:
+ row = tuple([row[0], ''] + list(row[2:]))
+
place.uri, place.title, place.bookmark, place.gecko_flags, \
place.visits, place.last_visit = row
--
1.7.7.6
More information about the Sugar-devel
mailing list