Page 1 of 1

Developing a plugin - need some help with WebUI part

Posted: Sat Jun 09, 2012 11:11 pm
by GyroTech
As the title says, I'm developing a plugin. The core functionality is working great, and the GtkUI part is functioning fine too.

The WebUI part is really throwing me off however, as I don't often use JavaScript and I have never used the ExtJS framework before and don't really have any idea what I'm doing for it.
I have looked over the code for official and 3rd party plugins that have WebUI sections, but it differs greatly from the skeleton code that gets generated that I don't even know where to start taking it apart!

All I need is a preferences page that can modify the config data used by the plugin. So far I can have the basic preferences page, but I can't use the exported get_config and set_config to change the plugin's profile data.

The current source is: https://github.com/TimJones/Deluge-Move ... ee/develop
and my diff just to try and load & display a config setting:

Code: Select all

	onRender: function(ct, position) {
		Deluge.ux.preferences.MoveOnRemovePage.superclass.onRender.call(this, ct, position);
		this.form.layout = new Ext.layout.FormLayout();
		this.form.layout.setContainer(this);
		this.form.doLayout();
	},
	
	onApply: function() {
		// build settings object
		var config = { }

		config['move_to'] = this.moveTo.getValue();

		deluge.client.moveonremove.set_config(config);
	},

	onOk: function() {
		this.onApply();
	},

	afterRender: function() {
		Deluge.ux.preferences.MoveOnRemovePage.superclass.afterRender.call(this);
		this.updateConfig();
	},

	updateConfig: function() {
		deluge.client.moveonremove.get_config({
			success: function(config) {
				this.moveTo.setValue(config['move_to']);
			},
			scope: this
		});
	}
This is pretty much grafted from what I could understand of the official plugins, stripped to the bare minimum. It fails trying to access the deluge.client.moveonremove object and a little console.log'ing reveals that deluge.client doesn't have a moveonremove object. I get no warnings or errors from registering the plugin and the preferences page loads and displays as it should...

Any help is appreciated.

Re: Developing a plugin - need some help with WebUI part

Posted: Sun Jun 10, 2012 12:34 am
by Cas
One thing I notice is a spelling mistake for config here:

Code: Select all

this.moveTo.setValue(onfig['move_to']);

Re: Developing a plugin - need some help with WebUI part

Posted: Sun Jun 10, 2012 7:16 am
by GyroTech
Unfortunately that seems to be a transcription error, the typo doesn't exist in the source (and I've updated my post to reflect this).

I think it's more likely to be something wrong with the loading or registering of the plugin as when I inspect the deluge.client object, it has child objects of whatever plugins are loaded (i.e. webui, scheduler, etc...) but not for my plugin, and therefore RPC exported functions cannot be called.

Re: Developing a plugin - need some help with WebUI part

Posted: Sun Jun 10, 2012 11:14 am
by Cas
I tested the code and it works fine in webui, getting and setting config.

Re: Developing a plugin - need some help with WebUI part

Posted: Sun Jun 10, 2012 6:53 pm
by GyroTech
OK, thanks a bunch for testing my code. The fact that you said it was working for you made me suspect my development setup had become 'muddied', so I went about cleaning as much up as I could - stopping short of a reinstall of Python.

After pulling down the deluge sources from git again and building the 1.3-stable branch I now cannot build my plugin in develop mode. When I try python setup.py build develop --install-dir=.\temp I get this output:

Code: Select all

running build
running build_py
running develop
error: <path to deluge source\install>\deluge.egg-info\PKG-INFO: Too many open files
I even tried creating a new empty plugin with the create_plugin.py script, but that fails with the same error.

Building the egg seems to work fine in both cases...

Re: Developing a plugin - need some help with WebUI part

Posted: Sun Jun 10, 2012 11:58 pm
by Cas
That error is a python/os issue and could be a result of running deluged on the same machine with a lot of torrents because libtorrent keeps file descriptors open. The solution on linux would be to increase the ulimit but don't know what would apply for Windows.

Re: Developing a plugin - need some help with WebUI part

Posted: Tue Jun 12, 2012 8:43 am
by GyroTech
This is just a VM test machine so there was no actual torrenting on the system, nor was it doing anything other than building the plugin.
Odd thing is the machine quite happily builds deluge itself from scratch, and I´m sure that far more files have to be opened for that to complete!!

Either way when I have time I´ll fire up the Linux VM I have and try again in that... Thanks for your help btw.

Re: Developing a plugin - need some help with WebUI part

Posted: Sun Jun 17, 2012 10:08 am
by GyroTech
So, after rebuilding my dev machine from the ground up, I was able to get everything to build again.

After, I found that - solely using the WebUI - if I enable the plugin and the restart the daemon backend, my plugin would function correctly. Is this the expected behaviour?? or does it signify I'm missing some 'activation' call somewhere??