moksha/middleware/extensionpoint.py | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-)
New commits: commit 633f93cfcee082ae517d326edd469847c90c0674 Merge: 0710ae1... dff14a2... Author: John (J5) Palmieri johnp@redhat.com Date: Wed Feb 4 12:00:43 2009 -0500
Merge branch 'master' of git+ssh://johnp@git.fedorahosted.org/git/moksha
diff --cc moksha/middleware/extensionpoint.py index c770796,14a426e..bc75d90 --- a/moksha/middleware/extensionpoint.py +++ b/moksha/middleware/extensionpoint.py @@@ -71,21 -71,12 +71,22 @@@ class MokshaExtensionPointMiddleware(ob info : {'consumes':['build_message'], 'author': 'John (J5) Palmieri johnp@redhat.com', 'version': '0.1', - 'name': 'Hello World Message' + 'name': 'Hello World Message'}
""" - def __init__(self, application, module='moksha', dir='plugins/extensions'): + def __init__(self, application, + entry_point='moksha.extension_point', + test_dir=None): + """ + :application: WSGI application to wrap + :extension_point: the python extry point which specifies modules to + scan for JavaScript extension_points + :test_dir: a directory to scan for JavaScript extension_points which + are being tested before they are added to the module + """ + log.info('Creating MokshaExtensionPointMiddleware') + self.application = application
# if debug is False condense javascript to optimize self.__debug = config.get('moksha.extension_points.debug')
commit 0710ae181d5216eb726aae45a1cbe969f99246f9 Author: John (J5) Palmieri johnp@redhat.com Date: Wed Feb 4 11:59:33 2009 -0500
user modules as entry points to find the javascript extension point directories
diff --git a/moksha/middleware/extensionpoint.py b/moksha/middleware/extensionpoint.py index 50d687a..c770796 100644 --- a/moksha/middleware/extensionpoint.py +++ b/moksha/middleware/extensionpoint.py @@ -71,18 +71,34 @@ class MokshaExtensionPointMiddleware(object): info : {'consumes':['build_message'], 'author': 'John (J5) Palmieri johnp@redhat.com', 'version': '0.1', - 'name': 'Hello World Message' + 'name': 'Hello World Message'}
""" - def __init__(self, application, module='moksha', dir='plugins/extensions'): + def __init__(self, application, + entry_point='moksha.extension_point', + test_dir=None): + """ + :application: WSGI application to wrap + :extension_point: the python extry point which specifies modules to + scan for JavaScript extension_points + :test_dir: a directory to scan for JavaScript extension_points which + are being tested before they are added to the module + """ + log.info('Creating MokshaExtensionPointMiddleware')
# if debug is False condense javascript to optimize self.__debug = config.get('moksha.extension_points.debug') self.__extension_cache = {} + self.application = application + + if test_dir: + self.load_extension_dir(test_dir)
- # FIXME: figure out a way to load extensions like we load entry points - self.load_extensions(module, dir) + for ep in pkg_resources.iter_entry_points(entry_point): + mod = ep.load() + dir = os.path.dirname(mod.__file__) + self.load_extension_dir(dir)
def chunk_code(self, js, filename): start = js.find('{') @@ -157,9 +173,8 @@ class MokshaExtensionPointMiddleware(object): code.append(c.code) self.__extension_cache[exttype] = code
- def load_extensions(self, module, dir): - real_dir = pkg_resources.resource_filename(module, dir) - for root, dirs, files in os.walk(real_dir): + def load_extension_dir(self, dir): + for root, dirs, files in os.walk(dir): for name in files: if name.endswith('js'): path = os.path.join(root, name)
moksha-commits@lists.fedorahosted.org