Installing Plasma.Service *.operations file
Thomas Olsen
tanghus at gmail.com
Thu Dec 23 12:19:02 CET 2010
On Thursday 23 December 2010 00:40:59 Aaron J. Seigo wrote:
> On Wednesday, December 22, 2010, Thomas Olsen wrote:
> > Except that it doesn't work until it's installed in
> > ~/.kde/share/apps/plasma/services. I thought I had messed up my code but
> > it works again after I copied it there.
>
> no, that's quite wrong: packages should never install files outside of
> themselves ...
>
> bet the Python DataEngine bindings are messed up and don't check for the
> file in the "services" location.
>
> *looks*
>
> yes, that's it. *grumble*
>
> the Javascript bindings have a class called JavaScriptService which does
> this:
>
> void JavaScriptService::registerOperationsScheme()
> {
> if (!m_dataEngine) {
> return;
> }
>
> const QString path = m_dataEngine.data()->filePath("services", name() +
> ".operations");
>
> if (path.isEmpty()) {
> kDebug() << "Cannot find operations description:" << name() <<
> ".operations";
> m_dataEngine.clear();
> return;
> }
>
> QFile file(path);
> setOperationsScheme(&file);
> }
>
> since the Service does not know about the DataEngine (and can't, at least
> not in a reliable fasion; it can be told about the DataEngine, but only
> after its too late .. and using the QObject hierarchy is just too error
> prone and would invalidate valid use cases where the DataEngine isn't an
> ancestor), the ScriptEngine needs to provide a service subclass that does
> as the above.
>
> you may be able to work around that in your Python code by creating a
> Plasma::Service subclass yourself which does the above? it realy does
> belong in the Python ScriptEngine, in any case, but that's beyond my
> python mojo to do :)
I got it working but only with an ugly hack as seen below:
class UrlShortenerService(Plasma.Service):
def __init__(self, engine):
Plasma.Service.__init__(self, engine)
self.engine = engine
self.setName("urlshortener")
def createJob(self, operation, parameters):
return UrlShortenerJob(self.destination(), operation, parameters, self)
def registerOperationsScheme(self):
if not self.engine:
print "UrlShortenerService. No engine found"
return
basename = self.name() + ".operations"
# This doesn't work:
#path = self.engine.package().filePath("services", basename)
# This ugly hack works:
path = self.engine.package().path() + "contents/services/" + basename
if path.isEmpty():
print "Cannot find operations description:", "%s.operations" % str(self.name())
return
ofile = QFile(path)
self.setOperationsScheme(ofile)
BTW: You had m_dataEngine.data() and m_dataEngine.clear(). Neither of these seem to
exists, or am I working on the wrong object?
--
Best regards / med venlig hilsen
Thomas Olsen
Dropbox and my thumb drive had an epic battle. Dropbox won. http://db.tt/T0p6d6L
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 230 bytes
Desc: This is a digitally signed message part.
Url : http://mail.kde.org/pipermail/plasma-devel/attachments/20101223/35763164/attachment.sig
More information about the Plasma-devel
mailing list