def test_basic_conf(self): settings.WIRECLOUD_PLUGINS = () core_plugins = len(get_plugins()) core_features = len(get_active_features()) core_classic_javascripts = len(get_extra_javascripts('classic')) core_smartphone_javascripts = len(get_extra_javascripts('smartphone')) core_classic_extensions = len(get_widget_api_extensions('classic', {})) core_smartphone_extensions = len( get_widget_api_extensions('smartphone', {})) settings.WIRECLOUD_PLUGINS = ( 'wirecloud.platform.tests.plugins.WirecloudTestPlugin1', 'wirecloud.platform.tests.plugins.WirecloudTestPlugin2', ) clear_cache() self.assertEqual(len(get_plugins()), core_plugins + 2) self.assertEqual(len(get_active_features()), core_features + 2) self.assertEqual(len(get_extra_javascripts('classic')), core_classic_javascripts + 2) self.assertEqual(len(get_extra_javascripts('smartphone')), core_smartphone_javascripts + 1) self.assertEqual(len(get_widget_api_extensions('classic', {})), core_classic_extensions + 1) self.assertEqual(len(get_widget_api_extensions('smartphone', {})), core_smartphone_extensions + 0)
def cached_javascript_catalog(request): packages = ['wirecloud.commons', 'wirecloud.catalogue', 'wirecloud.platform'] for plugin in get_plugins(): packages.append(plugin.__module__) return javascript_catalog(request, "djangojs", packages)
def plugins(request): plugins = get_plugins() context = {} for plugin in plugins: context.update(plugin.get_django_template_context_processors()) return context
def get_platform_context_current_values(user): plugins = get_plugins() values = {} for plugin in plugins: values.update(plugin.get_platform_context_current_values(user)) return values
def get_workspace_context_current_values(workspace, user): plugins = get_plugins() values = {} for plugin in plugins: values.update(plugin.get_workspace_context_current_values(workspace, user)) return values
def cached_javascript_catalog(request): packages = [ 'wirecloud.commons', 'wirecloud.catalogue', 'wirecloud.platform' ] for plugin in get_plugins(): packages.append(plugin.__module__) return javascript_catalog(request, "djangojs", packages)
def get_workspace_context_current_values(workspace, user): plugins = get_plugins() values = {} for plugin in plugins: values.update( plugin.get_workspace_context_current_values(workspace, user)) return values
def get_market_classes(): global _market_classes if _market_classes is None: _market_classes = {} plugins = get_plugins() for plugin in plugins: _market_classes.update(plugin.get_market_classes()) return _market_classes
def get_workspace_context_definitions(): global _wirecloud_workspace_context_definitions if _wirecloud_workspace_context_definitions is None: plugins = get_plugins() context = {} for plugin in plugins: context.update(plugin.get_workspace_context_definitions()) _wirecloud_workspace_context_definitions = context return _wirecloud_workspace_context_definitions
def get_templates(view): global _wirecloud_templates if view not in _wirecloud_templates: plugins = get_plugins() templates = [] for plugin in plugins: templates.extend(plugin.get_templates(view)) _wirecloud_templates[view] = templates return _wirecloud_templates[view]
def test_basic_conf(self): settings.WIRECLOUD_PLUGINS = () core_plugins = len(get_plugins()) core_features = len(get_active_features()) core_classic_javascripts = len(get_extra_javascripts('classic')) core_smartphone_javascripts = len(get_extra_javascripts('smartphone')) core_classic_extensions = len(get_widget_api_extensions('classic', {})) core_smartphone_extensions = len(get_widget_api_extensions('smartphone', {})) settings.WIRECLOUD_PLUGINS = ( 'wirecloud.platform.tests.plugins.WirecloudTestPlugin1', 'wirecloud.platform.tests.plugins.WirecloudTestPlugin2', ) clear_cache() self.assertEqual(len(get_plugins()), core_plugins + 2) self.assertEqual(len(get_active_features()), core_features + 2) self.assertEqual(len(get_extra_javascripts('classic')), core_classic_javascripts + 2) self.assertEqual(len(get_extra_javascripts('smartphone')), core_smartphone_javascripts + 1) self.assertEqual(len(get_widget_api_extensions('classic', {})), core_classic_extensions + 1) self.assertEqual(len(get_widget_api_extensions('smartphone', {})), core_smartphone_extensions + 0)
def get_templates(view): global _wirecloud_templates if view not in _wirecloud_templates: plugins = get_plugins() templates = {} for plugin in plugins: templates.update(plugin.get_templates(view)) _wirecloud_templates[view] = templates return _wirecloud_templates[view]
def cached_javascript_catalog(request): language = request.GET.get(LANGUAGE_QUERY_PARAMETER) if not (language and check_for_language(language)): language = get_language() locale = to_locale(language) packages = ['wirecloud.commons', 'wirecloud.catalogue', 'wirecloud.platform'] for plugin in get_plugins(): packages.append(plugin.__module__.rsplit('.', 1)[0]) for theme in get_available_themes(): packages.append(theme) catalog, plural = get_javascript_catalog(locale, 'djangojs', packages) return render_javascript_catalog(catalog, plural)
def _handle(self, *args, **options): updated = False self.verbosity = int(options.get('verbosity', 1)) with atomic(): wirecloud_user, created = User.objects.get_or_create(username='******', defaults={'password': '******'}) if created: updated = True self.log('Creating a wirecloud user... DONE', 1) for plugin in get_plugins(): result = plugin.populate(wirecloud_user, self.log) updated = updated or result if not updated: self.log('Already up-to-date.', 1)
def _handle(self, *args, **options): updated = False self.verbosity = int(options.get('verbosity', 1)) with atomic(): wirecloud_user, created = User.objects.get_or_create( username='******', defaults={'password': '******'}) if created: updated = True self.log('Creating a wirecloud user... DONE', 1) for plugin in get_plugins(): result = plugin.populate(wirecloud_user, self.log) updated = updated or result if not updated: self.log('Already up-to-date.', 1)
def __iter__(self): import wirecloud.catalogue import wirecloud.commons import wirecloud.platform from wirecloud.platform.plugins import get_plugins NOSE_ARGS = [os.getcwd()] NOSE_ARGS.append(os.path.dirname(wirecloud.commons.__file__)) if self._instance_type == 'platform': NOSE_ARGS.append(os.path.dirname(wirecloud.catalogue.__file__)) NOSE_ARGS.append(os.path.dirname(wirecloud.platform.__file__)) elif self._instance_type == 'catalogue': NOSE_ARGS.append(os.path.dirname(wirecloud.catalogue.__file__)) for plugin in get_plugins(): plugin_path = os.path.dirname(sys.modules[plugin.__module__].__file__) NOSE_ARGS.append(plugin_path) return NOSE_ARGS.__iter__()