[Sugar-devel] Searching for datastore entries by title
Bert Freudenberg
bert at freudenbergs.de
Tue Sep 15 19:51:30 EDT 2009
I want to find a datastore entry with a specific title and mime_type.
But it returns *all* entries with that mimetype instead. Here's the log:
1253058031.600170 DEBUG root: datastore.find
dbus.Dictionary({dbus.String(u'mime_type'): dbus.String(u'application/
x-squeak-project'), dbus.String(u'title'): dbus.String(u'The Hole')},
signature=dbus.Signature('ss'))
1253058031.600731 DEBUG root: parse_query
dbus.Dictionary({dbus.String(u'mime_type'): dbus.String(u'application/
x-squeak-project'), dbus.String(u'title'): dbus.String(u'The Hole')},
signature=dbus.Signature('ss')) None
1253058031.600886 WARNING root: Unknown term:
dbus.String(u'title')=dbus.String(u'The Hole')
1253058031.601042 WARNING root: Unknown term(s):
{dbus.String(u'mime_type'): dbus.String(u'application/x-squeak-
project'), dbus.String(u'title'): dbus.String(u'The Hole')}
1253058031.601170 DEBUG root: queries: ['Xapian::Query(FMapplication/x-
squeak-project)']
1253058031.602399 DEBUG org.laptop.sugar.DataStore: find():
0.0017540454864501953
What does "unknown term" mean? It seams to get ignored. But it's in
the log quite often, not only from my query, that does not sound
right, something seems broken:
1253057661.236064 DEBUG root: datastore.find
dbus.Dictionary({dbus.String(u'limit'): dbus.Int32(5,
variant_level=1), dbus.String(u'order_by'):
dbus.Array([dbus.String(u'+timestamp')],
signature=dbus.Signature('s'), variant_level=1),
dbus.String(u'activity'): dbus.String(u'org.laptop.Pippy',
variant_level=1)}, signature=dbus.Signature('sv'))
1253057661.236569 DEBUG root: parse_query
dbus.Dictionary({dbus.String(u'activity'):
dbus.String(u'org.laptop.Pippy', variant_level=1)},
signature=dbus.Signature('sv')) None
1253057661.236753 WARNING root: Unknown term(s):
{dbus.String(u'activity'): dbus.String(u'org.laptop.Pippy',
variant_level=1)}
1253057661.236886 DEBUG root: queries:
['Xapian::Query(FAorg.laptop.Pippy)']
1253057661.240903 DEBUG org.laptop.sugar.DataStore: find():
0.0045418739318847656
My test program (run in Pippy) and its output was this:
=================================
def unwrap(x):
if isinstance(x, list): return map(unwrap, x)
if isinstance(x, tuple): return tuple(map(unwrap, x))
if isinstance(x, dict): return dict([(unwrap(k), unwrap(v)) for
k, v in x.iteritems()])
for t in [unicode, str, long, int, float, bool]:
if isinstance(x, t): return t(x)
return x
import dbus
datastore = dbus.SessionBus().get_object('org.laptop.sugar.DataStore',
'/org/laptop/sugar/DataStore')
(items,count) = datastore.find(
{
'title':'The Hole',
'mime_type':'application/x-squeak-project'
},
dbus.Array(['title'], signature='s'),
byte_arrays=True)
print count
print unwrap(items)
=================================
5
[{u'title': 'DBus Explorer'}, {u'title': 'The Hole'}, {u'title': 'keep
test'}, {u'title': 'keep test'}, {u'title': 'keep test'}]
=================================
So it did filter out non-matching mimetypes but retained all titles.
This is in jhbuild as of yesterday.
- Bert -
More information about the Sugar-devel
mailing list