[Xapian-discuss] Using a subclass of MatchSpy in Python bindings
Doctor Munchkin
doctormunchkin at gmail.com
Wed Dec 1 13:18:40 GMT 2010
Hi everyone,
I've searched the mail archives and I haven't been able to find a
solution to this. I want to subclass a MatchSpy in the Python bindings
and have Enquire use it. However, when I try to do so, I get a
TypeError raised. The following example illustrates this:
>>> import xapian
>>> database = xapian.Database(dbpath)
>>> class MyMatchSpy(xapian.MatchSpy):
... def __init__(self):
... pass
... def __call__(self, *args, **kw):
... print "called with", args, kw
...
>>> ms = MyMatchSpy()
>>> enquire = xapian.Enquire(database)
>>> enquire.add_matchspy(ms)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.6/dist-packages/xapian/__init__.py", line
6920, in _enquire_match_spy_add
_enquire_add_matchspy_orig(self, decider)
TypeError: in method 'Enquire_add_matchspy', argument 2 of type
'Xapian::MatchSpy *'
Am I missing something obvious here, or is swig misbehaving? The above
works if ms is an instance of xapian.ValueCountMatchSpy, but I need to
implement something different to this.
I'm running the latest Xapian from Debian sid:
>>> xapian.version_string()
'1.2.3'
Thanks,
Munchkin
More information about the Xapian-discuss
mailing list