Re: help with writing a python client


> I am trying to write a python client by examining the libbeagle api
> (since it looks like python module is just a wrapper).  So far I have
> this python test
> >>> import beagle
> >>> client = beagle.Client()
> >>> query = beagle.Query()
> >>> query.add_text('images')
> >>> resp = client.send_request(query)
> >>> resp
> <beagle.SearchTermResponse object at 0xb7da411c
> (BeagleSearchTermResponse at 0x81ee600)>
> >>>
> Problem is I can't figure out what to do with SearchTermResponse
> I have seen in the examples a method get_hits() but it seems that is
> on BeagleHitsAddedResponse.

You ignore SearchTermResponse in most of the cases. You might want to
look at the example code
or the code for deskbar and yaBi.

> What am I doing wrong to produce a SearchTermResponse instead of a
> BeagleHitsAddedResponse?
> BTW, I need synchronous requests because this is going in a web app.

You are doing nothing wrong. Querying is really an async process. You
get the SearchTermResponse initially (which most apps wont need and
can be ignored) and wait till you hear HitsAddedResponse or
FInishedResponse. If you want to make it look like sync, use some kind
of mutex to block the process till you receive FinishedResponse.

Since you mention webapp, just make sure the webapp allows you to run
a glib mainloop. I have faced this problem before - some execution
environments do not allow any other mainloop. Beagle requires a glib

- dBera

Debajyoti Bera @
beagle / KDE fan
Mandriva / Inspiron-1100 user

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