Exemple #1
0
def get_url_patterns():
    res = _init_url_patterns()
    for appname in settings.INSTALLED_APPS:
        appmodule = import_module(appname)
        is_lucterios_ext = False
        for _, modname, ispkg in pkgutil.iter_modules(appmodule.__path__):
            if (modname[:5] == 'views') and not ispkg:
                view = import_module(appname + '.' + modname)
                for obj in inspect.getmembers(view):
                    try:
                        if obj[1].url_text != '':
                            if inspect.isclass(obj[1]):
                                is_lucterios_ext = True
                                as_view_meth = getattr(obj[1], "as_view")
                                res.append(
                                    url(r"^%s$" % obj[1].url_text,
                                        as_view_meth()))
                    except AttributeError:
                        pass
            elif settings.APPLIS_MODULE == appmodule:
                is_lucterios_ext = True
        if not is_lucterios_ext:
            try:
                patterns = getattr(import_module('%s.urls' % appname),
                                   'urlpatterns', None)
                if isinstance(patterns, (list, tuple)):
                    for url_pattern in patterns:
                        module_items = appname.split('.')
                        if module_items[0] == 'lucterios':
                            continue
                        if module_items[0] == 'django':
                            res.append(url_pattern)
                        else:
                            res.append(
                                url(
                                    r"^%s/%s" %
                                    (module_items[-1],
                                     url_pattern.pattern._regex[1:]),
                                    url_pattern.callback, None,
                                    url_pattern.pattern.name))
            except ImportError:
                pass
    print("PluginManager.get_instance")
    for plugin_item in PluginManager.get_instance():
        for view_item in plugin_item.views:
            res.append(url(r"^%s$" % view_item.url_text, view_item.as_view()))
    try:
        from django.contrib.admin.sites import site
        res.append(url(r'^accounts/login/$', site.login))
    except ImportError:
        pass
    res.extend(staticfiles_urlpatterns())
    logging.getLogger('lucterios.core.init').debug("Urls:" + '\n'.join(
        str(res_item) for res_item in res))
    Signal.call_signal("auditlog_register")
    LucteriosAuditlogModelRegistry.main_enabled()
    return res
Exemple #2
0
def get_url_patterns():
    url_patterns = UrlPatterns()
    for appname in settings.INSTALLED_APPS:
        if not url_patterns.add_lct_application(appname):
            url_patterns.add_ext_application(appname)
    url_patterns.add_plugins()
    url_patterns.add_extra_url()
    logging.getLogger('lucterios.core.init').debug("Urls:" + '\n'.join(str(res_item) for res_item in url_patterns))
    Signal.call_signal("auditlog_register")
    LucteriosAuditlogModelRegistry.main_enabled()
    return url_patterns