Closed Bug 558790 Opened 16 years ago Closed 16 years ago

Plugin prioritization

Categories

(Skywriter Graveyard :: Add-ons & Plugins, defect, P2)

Other
Other
defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: dangoor, Assigned: julian.viereck)

Details

Attachments

(2 files)

By default, when filling in extension points, Bespin will look for plugins in an effectively random order. Sometimes, it makes sense for a user to want to prefer one plugin over another. The user should be able to configure a list of plugins that are given preference (in the order they are listed). So, it would be something like this: set pluginorder ['vim', 'emacs'] With a setting like this, the keymapping provided by vim would be preferred to the keymapping provided by the emacs plugin. All other plugins would appear after those two. (Which means, for example, if a few plugins all defined commands called "moveRight", vim's is the one that wins.)
Append the request /plugin/request/user to send back the user's pluginorder as well as the deactivated plugins
Attachment #439523 - Flags: review?(kdangoor)
Thanks, Julian. A couple of comments on the diff: 1. there's an inconsistency in the definition of ordering and deactivated: + if pluginInfo is None: + pluginInfo = dict({"ordering": {}, "deactivated": {}}); + 'ordering' : pluginInfo.get("ordering", []), + 'deactivated': pluginInfo.get("deactivated", []) in the first snippet, they are dicts, in the second they are lists. I think they're supposed to be lists. 2. in Python, {} by itself creates a dict. You don't need to use the dict() constructor when you use {}. dict(foo="bar") is sometimes more pleasant to type than {"foo": "bar"} 3. minor point, but controllers.py has a _respond_json function that sets the content type and encodes the body. I'd suggest using that in register_user_plugins 4. get_user_plugin_info appears to have two different return types: a dictionary and a tuple. "if not user" it returns {}, otherwise it returns pluginInfo, project. This will actually break if there is no user passed in. The "if not user" case should probably return None, None for consistency. 5. The tests don't actually do anything to see if the values for ordering and deactivated get passed through on the whole, though, looks good given that you don't know python :) Kevin
> 3. minor point, but controllers.py has a _respond_json function that sets the > content type and encodes the body. I'd suggest using that in > register_user_plugins The problem is, that _respond_json only sends back the metadata but nothing else like the plugin ordering that is required for this special call. As I don't wanted to extend _respond_json to fit these needs, I've copied the code from there and made the additions.
I think you're thinking of _plugin_response. _respond_json is just a simple utility function that sets the content type and encodes the passed in data as json...
Thanks to the comments from Kevin, I've improved my patch. This patch has to be applied over the first patch provided in this bug.
Attachment #439874 - Flags: review?(kdangoor)
Attachment #439874 - Flags: review?(kdangoor) → review+
Attachment #439523 - Flags: review?(kdangoor) → review+
Implemented in bespinclient commit 669dcb7c2125 and bespinserver commit e0d26cfde19e.
Status: NEW → RESOLVED
Closed: 16 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: