Re: [Rhythmbox-devel] Python API question



On Sat, 2007-02-17 at 14:20 +1100, James "Doc" Livingston wrote:
> On Tue, 2007-02-13 at 00:28 +1100, James "Doc" Livingston wrote:
> > db = shell.props.db
> > query = db.query_new()
> > db.query_append (query, [rhythmdb.QUERY_PROP_EQUALS,
> > rhythmdb.PROP_ARTIST, "The Living End"])
> >
> > What you should be able to do is call "qm = db.query_model_new(query)"
> > to create a new query model with a given query. Creating it works fine
> > at the moment, but it doesn't actually put anything in the query model -
> > I'm planning to look into that tomorrow.
> 
> Oops, after creating the query mode you need to do a
> "db.do_full_query_async_parsed (qm, query)". I've checked this works by
> doing "qm.iter_n_children(None)" which reports that I have 75 tracks
> matching the criteria.

I've got the evaluate_query() example to run, but not yet got a query
model to work... is that bit in SVN?

shell.props.shell_player.get_playing_entry() returns None if nothing's
playing, which leads to a TypeError being thrown when the query is
executed. Perhaps evaluate_query() should be wrapped so as not to fail?

> There are several API improvements we could easyly make, such as having
> queries know what db they belong to. This would mean you would write
> "query.foo()" instead of "db.query_foo()". Also automatically running
> the query for the model, and being able to pass criteria to the query
> constructor.  How does the following look, and can you think of anything
> nicer?
> 
> db = shell.props.db
> query = rhythmdb.Query(db,
>     [rhythmdb.QUERY_PROP_EQUALS, rhythmdb.PROP_ARTIST, "The Living End"])
> qm = rhythmdb.QueryModel(db, query)

Because queries are associated with a rhythmdb object, why not something
like:

db = shell.props.db
query = db.Query([rhythmdb.QUERY_PROP_EQUALS, rhythmdb.PROP_ARTIST,
		"The Living End"])
qm = db.QueryModel(query)

Although bunching the last two into a single method might be nice as
well, as in:

db = shell.props.db
qm = db.run_query([...])

-- 
Tim Retout <tim retout co uk>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]