> 
> On Thu, 22 May 2008, Bill Janssen wrote:
> 
> > I'm trying to figure out an issue here which sounds sort of similar.
> >
> > I've got a class in UpLib:
> >
> >   class UpLibQueryParser (PythonMultiFieldQueryParser):
> >
> > in one of the methods (getFieldQuery), it needs to reparse the input,
> > so I create a new instance of my class:
> >
> >         newparser = self.__class__(self.fields, self.getAnalyzer())
> >
> > and then cast it to a QueryParser so that I can call "parse()" on it:
> >
> >         qp = QueryParser.cast_(newparser)
> >
> > But I get an exception at this point:
> >
> >  File "/local/share/UpLib-1.7.4/code/uplib/indexing.py", line 320, in 
> > getFieldQuery
> >    qp = QueryParser.cast_(newparser)
> > TypeError: <UpLibQueryParser: [EMAIL PROTECTED]>
> >
> > Above, I'm using "self.__class__" because I also create subclasses of
> > this class, and I want an instance of the most specific subclass
> > created.
> 
> How about using type(self)(...) instead ?
> 
> Andi..

Well, I print out the instance that's created, and it is the right
class, so I think there is a bug in the cast_ mechanism (maybe
PythonMultiFieldQueryParser doesn't know it inherits from QueryParser?
After all, one is a Python class, and the other a Java class).  But I
tried using "type(self)" as you suggest, and I get the same TypeError.

Bill
_______________________________________________
pylucene-dev mailing list
pylucene-dev@osafoundation.org
http://lists.osafoundation.org/mailman/listinfo/pylucene-dev

Reply via email to