<div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">---------- Messaggio inoltrato ----------<br>From: Richard Dale <<a href="mailto:richard.j.dale@gmail.com" target="_blank">richard.j.dale@gmail.com</a>><br>
To: <a href="mailto:plasma-devel@kde.org" target="_blank">plasma-devel@kde.org</a><br>Date: Thu, 11 Feb 2010 18:37:55 +0000<br>Subject: Re: [PATCH] Support for arbitrary main script names in Python plasmoids<br>On Thu, Feb 11, 2010 at 6:02 PM, Luca Beltrame <<a href="mailto:einar@heavensinferno.net" target="_blank">einar@heavensinferno.net</a>> wrote:<br>
> Hello,<br>
><br>
> currently if you use Python plasmoids the main script *must* be named<br>
> "main.py" because it is hardcoded into pyappletscripts.py. When using a<br>
> different mainscript in the .desktop file (like Plasmate does) this will<br>
> ensure the plasmoid will not run (you get a NameError exception).<br>
Well currently in Plasmate there is not way to specifiy the main<br>
script (or main class).<br></blockquote><div><br>Actually, the main script and main class names are taken from the project name; if you create a<br>RubyClock project, Plasmate will create a rubyclock.rb file, with a MainRubyClock class inside it :)<br>
</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
The Ruby plasmoid implementation doesn't use the Ruby equivalent of<br>
__dict__, but simply derives the main class name from the main script<br>
name. So I wasn't sure is you should specifiy a main *class* name in<br>
Plasmate like FooBar which would give a main script name of<br>
foo_bar.rb. Or whether you should give a main script name of<br>
foo_bar.rb the Plasmate form from which the class 'FooBar' is then<br>
derived.<br>
<br>
Currently in Plasmate the name of the applet is used to derive both<br>
the module (like a namespace), and the name of the class, which I<br>
think is wrong. For example, if you call your applet FooBar you get:<br>
<br>
module FooBar<br>
class FooBar< PlasmaScripting::Applet<br>
...<br></blockquote><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
I would rather the class was called 'Main' if you don't specifiy a main script.<br></blockquote><div><br>I'm sorry, but this is wrong: I've taken care of avoiding it since the beginning<br>(I also reverted, a couple of days ago, a commit[1] that did exactly what you just<br>
described ). Plasmate creates by default a <br><br>Main<ProjectName> class for ruby and python plasmoids.<br><br>So we don't have naming collision :)<br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
For Python, what if there are several classes in the the python main<br>
script file - how do you tell which one is for the applet you want to<br>
instantiate?<br>
<br>
<br>
> The attached patch fixes this by retrieving the mainscript file, stripping it<br>
> to its name and then using Python introspection (__dict__) to pass the right<br>
> module name to the CreateApplet call.<br>
><br>
> After applying, old plasmoids (using main.py) and new ones (using *any name*)<br>
> seem to work correctly.<br>
><br>
> OK to commit? Should this also be backported?<br>
><br>
> _______________________________________________<br>
> Plasma-devel mailing list<br>
> <a href="mailto:Plasma-devel@kde.org" target="_blank">Plasma-devel@kde.org</a><br>
> <a href="https://mail.kde.org/mailman/listinfo/plasma-devel" target="_blank">https://mail.kde.org/mailman/listinfo/plasma-devel</a><br>
><br>
><br></blockquote><div><br>[1] <a href="http://websvn.kde.org/trunk/playground/base/plasma/plasmate/templates/mainPlasmoid.rb">http://websvn.kde.org/trunk/playground/base/plasma/plasmate/templates/mainPlasmoid.rb</a><br>
</div></div>