Query

FIXME: Describe here how searching works in general.

beacon.query(**args)
Query the database. This function will raise an exception if the client is not connected and the server is not running for a connect. The function returns an InProgress object with a Query object as result.

Methods

This object feels like a list, you can iterate over the results, access items based on position and get the length of the results.

Query.get(filter=None)

Get the result.

Parameters:
  • filter – filter function set by L{register_filter} to use on the result. If a filter is used the result type may be different.
Returns:

(filtered) list of Items

Query.__iter__()

Iterate through the results.

Returns:Iterator over Items
Query.__getitem__(pos)

Get a specific item in the results list.

Returns:Item on that position in the list, raises an IndexError if the list is shorter than pos
Query.index(item)
Get index of an item in the results. This function will raise an exception if the item is not in the results.
Query.__len__()
Get length of results.

Monitoring

FIXME: Describe monitoring here

Query.monitor(enable=True)
Turn on/off query monitoring
beacon.monitor(directory)

Monitor a directory with subdirectories for changes. This is done in the server and will keep the database up to date.

Parameters:
  • directory – directory path name

Signal changed

Emited when the query result changes.

Signal process

This signal is emited during initial scanning.

Arguments:
  • pos – position
  • max – maximum results

Signal up-to-date

This signal is emited after initial scanning.

Filter

FIXME: Describe filter here

beacon.register_filter(name, function)

Register a filter for L{Query} or L{wrap} to process a list of items.

Parameters:
  • name – unique name for the filter
  • function – filter function
beacon.wrap(items, filter)

Wrap the given list of items with the given filter function

Parameters:
  • items – list of items
  • filter – name of the filter, see L{register_filter}

Table Of Contents

Previous topic

Database Attributes

Next topic

Beacon Item

This Page

Quick search