[PyKDE] DCOPExObj bug?

Jim Bublitz jbublitz at nwinternet.com
Thu Dec 1 00:57:23 GMT 2005


On Wednesday 30 November 2005 15:41, Danny Pansters wrote:
> Hi,
>
> I'm working on a PyKDE app and have been adding a dcop interface like such:
>
> def __init__(self, obj, id):
> 	DCOPExObj.__init__(self, id)
> 	self.addMethod("void quit()", obj.slotQuit)
>
> where obj is the mainwindow instance that has all the relevant methods
> (most equal actions).
>
> Using kdcop and the dcop CLI, it seems that although the methods are
> executed alright, kdcop complains: "DCOP call failed. Application is still
> registered with DCOP; I do not know why this call failed." And on the
> console:
>
> Traceback (most recent call last):
>   File "/usr/local/lib/python2.4/site-packages/dcopexport.py", line 96, in
> process
>     dcop_add (s, result)
> TypeError: argument 2 of dcop_add() has an invalid type
>
> When trying with example_decopexport.py the same happens with the set
> method (the gets work OK), e.g.
>
> %dcop petshop-46787 "dead parrot" setParrotType "Big Bird"
> call failed
> %dcop petshop-46787 "dead parrot" getParrotType
> Big Bird
>
> I think dcopexport.py has a bug when a void or otherwise non-QString(List)
> type is returned?
>
> System: FreeBSD-6.0, KDE 3.4.3, PyKDE 20051013

The error appears to be in extensions/dcopexport.py (or 
site-packages/dcopexport.py after installation). The code (around line 96) 
that marshalls the return values doesn't handle a 'void' return correctly. I 
think this is something related either to KDE or sip versions being used, 
because it doesn't throw an error with sip 4.1.1/KDE 3.3 but does with sip 
4.3/KDE 3.4, although the error I get is "can't use None as argument 1" in 
the same line.

The easiet fix is in dcopexport.py. Insert the # marked if statement at line 
88 and indent the block beginning with "s ="

  #marshall the result as 'replyData'
  if self.method.rtype != "void":   ######
     s = QDataStream (replyData, IO_WriteOnly)
     if self.method.rtype in numericTypes:
        dcop_add (s, result, self.method.rtype)
     elif self.method.rtype in stringTypes and isinstance (result, str):
        dcop_add (s, eval ("%s('''%s''')" % (self.method.rtype, result)))
     elif self.method.rtype.startswith ("QMap") or        
             self.method.rtype.startswith ("QValueList"):
        dcop_add (params, args [i], self.argtypes [i])
     else:
        dcop_add (s, result)

Make sure you modify the 'site-packages' version of the file (don't need to 
reinstall then).

That works for me - let me know if it works for you.

Jim




More information about the PyQt mailing list