[Sugar-devel] Searching for datastore entries by title

Gary C Martin gary at garycmartin.com
Tue Sep 15 21:11:23 EDT 2009


Hi Bert,

On 16 Sep 2009, at 00:51, Bert Freudenberg wrote:

> 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',

Hmm FWIW, from my copy-from-journal experience, I though title was no  
longer supported (I opened a ticket about in 0.84 and it was closed as  
'not a bug' and the copy-from-journal script changed). I think you  
search with 'query' instead now... Might have happened as part of  
Tomeu's (much welcomed) re-write of the data-store for robustness,  
back in 0.84 I guess.

Regards,
--Gary



More information about the Sugar-devel mailing list