This forum has been archived. All content is frozen. Please use KDE Discuss instead.

How to subclass Plasma.Service in Python

Tags: None
(comma "," separated)
nik3nt3
Registered Member
Posts
5
Karma
0
OS
Hy

I want to pass some info (username, passwort and an url) to a DataEngine.

If I undersood the API[1] right, I will have to implement serviceForSource() in my DataEngine and return an instance of a subclass of Plasma.Service.

My problem:
If I create a subclass of Plasma.Service and try to instantiate it I get a runtime exception:
Code: Select all
TypeError: PyKDE4.plasma.Service cannot be instantiated or sub-classed


Sombody got a solution for this problem?

thx


- [1] http://api.kde.org/pykde-4.2-api/plasma ... rvice.html
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
You understood correctly. I do not know why that message appeared though, are you sure that your function definition returns a pointer?


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
nik3nt3
Registered Member
Posts
5
Karma
0
OS
I get the error when I instantiate my service-class:
Code: Select all
class MyService(Plasma.Service):
    def __init__(self, message):
        print "print ", message

I also tried to overwrite __init__(..) with different numbers of arguments (without luck).
Code: Select all
    def serviceForSource(self, sourceName):
        src = MyService("test")
        print "--- ", src
        return src

The error is thrown before the "print" statement.

...are you sure that your function definition returns a pointer?


Pointer in python - how would you do that?

Thanks for your reply
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
Unfortunately I do not know much about Python, but I do know that type instantiation errors usually occur when the type is protected like Plasma::Service is in C++.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
nik3nt3
Registered Member
Posts
5
Karma
0
OS


Bookmarks



Who is online

Registered users: Bing [Bot], daret, Google [Bot], sandyvee, Sogou [Bot]