add support for "boot" plugins. these plugins are loaded specially

and are not included in the main metadata
This commit is contained in:
Kevin Dangoor 2010-04-30 23:26:49 -04:00
Родитель 9187238507
Коммит 41e55aef46
4 изменённых файлов: 40 добавлений и 5 удалений

Просмотреть файл

@ -71,6 +71,7 @@ c.pw_secret = "This phrase encrypts passwords."
c.static_dir = path.getcwd() / ".." / "bespinclient" / "tmp" / "static"
c.plugin_path = []
c.loader_name = "bespin.tiki"
c.template_file_dir = None
@ -205,7 +206,9 @@ def set_profile(profile):
path=client_plugin_path / "supported"),
dict(name="thirdparty",
path=client_plugin_path / "thirdparty"),
dict(name="labs", path=client_plugin_path / "labs")]
dict(name="labs", path=client_plugin_path / "labs"),
dict(name="boot", path=client_plugin_path / "boot",
skip_unless_only=True)]
if profile == "test":
# this import will install the bespin_test store

Просмотреть файл

@ -1218,6 +1218,26 @@ def _plugin_response(response, path=None, plugin_list=None, log_user=None):
def register_plugins(request, response):
return _plugin_response(response)
@expose(r'^/plugin/register/boot$', 'GET', auth=False)
def register_boot_plugin(request, response):
for item in c.plugin_path:
if item["name"] == "boot":
break
if item["name"] != "boot":
raise BadRequest("No boot code available")
plugin_list = plugins.find_plugins([item])
output = ""
for plugin in plugin_list:
output += """
%s.register('::%s', %s);
""" % (c.loader_name, plugin.name, simplejson.dumps(plugin.metadata))
response.content_type = "text/javascript"
response.body = output
return response()
@expose(r'^/plugin/register/user$', 'GET', auth=True)
def register_user_plugins(request, response):
pluginInfo, project = get_user_plugin_info(request.user)
@ -1384,9 +1404,9 @@ def _wrap_script(plugin_name, script_path, script_text):
else:
module_name = "index"
return """; tiki.module('%s:%s', function(require, exports, module) {%s
;}); tiki.script('%s:%s');""" % (plugin_name, module_name,
script_text, plugin_name, script_path)
return """; %s.module('%s:%s', function(require, exports, module) {%s
;}); %s.script('%s:%s');""" % (c.loader_name, plugin_name, module_name,
script_text, c.loader_name, plugin_name, script_path)
urlmatch = re.compile(r'^(http|https)://')

Просмотреть файл

@ -39,6 +39,7 @@ import re
from urlparse import urlparse
import time
import zipfile
import logging
import simplejson
@ -54,6 +55,8 @@ from bespin.filesystem import NotAuthorized, get_project, FileNotFound
leading_slash = re.compile("^/")
log = logging.getLogger("bespin.plugins")
def get_user_plugin_info(user):
if not user:
return None, None
@ -180,6 +183,11 @@ def find_plugins(search_path=None):
if search_path is None:
search_path = config.c.plugin_path
if len(search_path) > 1:
search_path = [item for item in search_path
if not item.get("skip_unless_only")]
return base_find_plugins(search_path, cls=Plugin)
def lookup_plugin(name, search_path=None):
@ -187,6 +195,10 @@ def lookup_plugin(name, search_path=None):
if search_path is None:
search_path = config.c.plugin_path
if len(search_path) > 1:
search_path = [item for item in search_path
if not item.get("skip_unless_only")]
return base_lookup_plugin(name, search_path, cls=Plugin)
def install_plugin(f, url, settings_project, path_entry, plugin_name=None):

Просмотреть файл

@ -531,7 +531,7 @@ def test_plugin_install_from_gallery():
assert response.content_type == "application/json"
data = loads(response.body)
assert "single_file_plugin3" in data
assert "scripts" in data["single_file_plugin3"]
assert "tiki:resources" in data["single_file_plugin3"]
project = get_project(macgyver, macgyver, "BespinSettings")
sfp3_dir = project.location / "plugins/single_file_plugin3.js"