Skip to content

Commit

Permalink
Merge tardyp/buildbot:plugin (PR #1491)
Browse files Browse the repository at this point in the history
  • Loading branch information
djmitche committed Jan 18, 2015
2 parents dff50ee + 9b4902f commit 1a5079f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions master/buildbot/www/plugin.py
Expand Up @@ -26,6 +26,9 @@ def __init__(self, modulename, description):
self.static_dir = pkg_resources.resource_filename(modulename, "/static")
self.resource = static.File(self.static_dir)

def setMaster(self, master):
self.master = master

def __repr__(self):
return ("www.plugin.Application(version=%(version)s, "
"description=%(description)s, "
Expand Down
1 change: 1 addition & 0 deletions master/buildbot/www/service.py
Expand Up @@ -125,6 +125,7 @@ def setupSite(self, new_config):
log.msg("initializing www plugin %r" % (key,))
if key not in self.apps:
raise RuntimeError("could not find plugin %s; is it installed?" % (key,))
self.apps.get(key).setMaster(self.master)
root.putChild(key, self.apps.get(key).resource)
known_plugins = set(new_config.www.get('plugins', {})) | set(['base'])
for plugin_name in set(self.apps.names) - known_plugins:
Expand Down
3 changes: 2 additions & 1 deletion master/docs/developer/www.rst
Expand Up @@ -428,7 +428,8 @@ The entrypoint must contain a twisted.web Resource, that is populated in the web
The front-end part of the plugin system automatically loads `/<pluginname>/scripts.js` and `/<pluginname>/styles.css` into the angular.js application.
The scripts.js files can register itself as a dependency to the main "app" module, register some new states to $stateProvider, or new menu items via glMenuProvider.
The entrypoint being a Resource, nothing forbids plugin writers to add more REST apis in `/<pluginname>/api`.
The entrypoint containing a Resource, nothing forbids plugin writers to add more REST apis in `/<pluginname>/api`.
For that, a reference to the master singleton is provided in ``master`` attribute of the Application entrypoint.
You are even not restricted to twisted, and could even `load a wsgi application using flask, django, etc <http://twistedmatrix.com/documents/13.1.0/web/howto/web-in-60/wsgi.html>`_.
.. _Routing:
Expand Down

0 comments on commit 1a5079f

Please sign in to comment.