Python django.urls 模块,get_mod_func() 实例源码

我们从Python开源项目中,提取了以下13个代码示例,用于说明如何使用django.urls.get_mod_func()

项目:NarshaTech    作者:KimJangHyeon    | 项目源码 | 文件源码
def _get_view_func(view):
        urlconf = get_urlconf()
        if get_resolver(urlconf)._is_callback(view):
            mod, func = get_mod_func(view)
            try:
                # Separate the module and function, e.g.
                # 'mymodule.views.myview' -> 'mymodule.views', 'myview').
                return getattr(import_module(mod), func)
            except ImportError:
                # Import may fail because view contains a class name, e.g.
                # 'mymodule.views.ViewContainer.my_view', so mod takes the form
                # 'mymodule.views.ViewContainer'. Parse it again to separate
                # the module and class.
                mod, klass = get_mod_func(mod)
                return getattr(getattr(import_module(mod), klass), func)
            except AttributeError:
                # PY2 generates incorrect paths for views that are methods,
                # e.g. 'mymodule.views.ViewContainer.my_view' will be
                # listed as 'mymodule.views.my_view' because the class name
                # can't be detected. This causes an AttributeError when
                # trying to resolve the view.
                return None
项目:Scrum    作者:prakharchoudhary    | 项目源码 | 文件源码
def _get_view_func(view):
        urlconf = get_urlconf()
        if get_resolver(urlconf)._is_callback(view):
            mod, func = get_mod_func(view)
            try:
                # Separate the module and function, e.g.
                # 'mymodule.views.myview' -> 'mymodule.views', 'myview').
                return getattr(import_module(mod), func)
            except ImportError:
                # Import may fail because view contains a class name, e.g.
                # 'mymodule.views.ViewContainer.my_view', so mod takes the form
                # 'mymodule.views.ViewContainer'. Parse it again to separate
                # the module and class.
                mod, klass = get_mod_func(mod)
                return getattr(getattr(import_module(mod), klass), func)
            except AttributeError:
                # PY2 generates incorrect paths for views that are methods,
                # e.g. 'mymodule.views.ViewContainer.my_view' will be
                # listed as 'mymodule.views.my_view' because the class name
                # can't be detected. This causes an AttributeError when
                # trying to resolve the view.
                return None
项目:django    作者:alexsukhrin    | 项目源码 | 文件源码
def _get_view_func(view):
        urlconf = get_urlconf()
        if get_resolver(urlconf)._is_callback(view):
            mod, func = get_mod_func(view)
            try:
                # Separate the module and function, e.g.
                # 'mymodule.views.myview' -> 'mymodule.views', 'myview').
                return getattr(import_module(mod), func)
            except ImportError:
                # Import may fail because view contains a class name, e.g.
                # 'mymodule.views.ViewContainer.my_view', so mod takes the form
                # 'mymodule.views.ViewContainer'. Parse it again to separate
                # the module and class.
                mod, klass = get_mod_func(mod)
                return getattr(getattr(import_module(mod), klass), func)
            except AttributeError:
                # PY2 generates incorrect paths for views that are methods,
                # e.g. 'mymodule.views.ViewContainer.my_view' will be
                # listed as 'mymodule.views.my_view' because the class name
                # can't be detected. This causes an AttributeError when
                # trying to resolve the view.
                return None
项目:Gypsy    作者:benticarlos    | 项目源码 | 文件源码
def _get_view_func(view):
        urlconf = get_urlconf()
        if get_resolver(urlconf)._is_callback(view):
            mod, func = get_mod_func(view)
            try:
                # Separate the module and function, e.g.
                # 'mymodule.views.myview' -> 'mymodule.views', 'myview').
                return getattr(import_module(mod), func)
            except ImportError:
                # Import may fail because view contains a class name, e.g.
                # 'mymodule.views.ViewContainer.my_view', so mod takes the form
                # 'mymodule.views.ViewContainer'. Parse it again to separate
                # the module and class.
                mod, klass = get_mod_func(mod)
                return getattr(getattr(import_module(mod), klass), func)
            except AttributeError:
                # PY2 generates incorrect paths for views that are methods,
                # e.g. 'mymodule.views.ViewContainer.my_view' will be
                # listed as 'mymodule.views.my_view' because the class name
                # can't be detected. This causes an AttributeError when
                # trying to resolve the view.
                return None
项目:ims    作者:ims-team    | 项目源码 | 文件源码
def _get_view_func(view):
        urlconf = get_urlconf()
        if get_resolver(urlconf)._is_callback(view):
            mod, func = get_mod_func(view)
            try:
                # Separate the module and function, e.g.
                # 'mymodule.views.myview' -> 'mymodule.views', 'myview').
                return getattr(import_module(mod), func)
            except ImportError:
                # Import may fail because view contains a class name, e.g.
                # 'mymodule.views.ViewContainer.my_view', so mod takes the form
                # 'mymodule.views.ViewContainer'. Parse it again to separate
                # the module and class.
                mod, klass = get_mod_func(mod)
                return getattr(getattr(import_module(mod), klass), func)
            except AttributeError:
                # PY2 generates incorrect paths for views that are methods,
                # e.g. 'mymodule.views.ViewContainer.my_view' will be
                # listed as 'mymodule.views.my_view' because the class name
                # can't be detected. This causes an AttributeError when
                # trying to resolve the view.
                return None
项目:lifesoundtrack    作者:MTG    | 项目源码 | 文件源码
def _get_view_func(view):
        urlconf = get_urlconf()
        if get_resolver(urlconf)._is_callback(view):
            mod, func = get_mod_func(view)
            try:
                # Separate the module and function, e.g.
                # 'mymodule.views.myview' -> 'mymodule.views', 'myview').
                return getattr(import_module(mod), func)
            except ImportError:
                # Import may fail because view contains a class name, e.g.
                # 'mymodule.views.ViewContainer.my_view', so mod takes the form
                # 'mymodule.views.ViewContainer'. Parse it again to separate
                # the module and class.
                mod, klass = get_mod_func(mod)
                return getattr(getattr(import_module(mod), klass), func)
            except AttributeError:
                # PY2 generates incorrect paths for views that are methods,
                # e.g. 'mymodule.views.ViewContainer.my_view' will be
                # listed as 'mymodule.views.my_view' because the class name
                # can't be detected. This causes an AttributeError when
                # trying to resolve the view.
                return None
项目:django-open-lecture    作者:DmLitov4    | 项目源码 | 文件源码
def _get_view_func(view):
        urlconf = get_urlconf()
        if get_resolver(urlconf)._is_callback(view):
            mod, func = get_mod_func(view)
            try:
                # Separate the module and function, e.g.
                # 'mymodule.views.myview' -> 'mymodule.views', 'myview').
                return getattr(import_module(mod), func)
            except ImportError:
                # Import may fail because view contains a class name, e.g.
                # 'mymodule.views.ViewContainer.my_view', so mod takes the form
                # 'mymodule.views.ViewContainer'. Parse it again to separate
                # the module and class.
                mod, klass = get_mod_func(mod)
                return getattr(getattr(import_module(mod), klass), func)
            except AttributeError:
                # PY2 generates incorrect paths for views that are methods,
                # e.g. 'mymodule.views.ViewContainer.my_view' will be
                # listed as 'mymodule.views.my_view' because the class name
                # can't be detected. This causes an AttributeError when
                # trying to resolve the view.
                return None
项目:travlr    作者:gauravkulkarni96    | 项目源码 | 文件源码
def _get_view_func(view):
        urlconf = get_urlconf()
        if get_resolver(urlconf)._is_callback(view):
            mod, func = get_mod_func(view)
            try:
                # Separate the module and function, e.g.
                # 'mymodule.views.myview' -> 'mymodule.views', 'myview').
                return getattr(import_module(mod), func)
            except ImportError:
                # Import may fail because view contains a class name, e.g.
                # 'mymodule.views.ViewContainer.my_view', so mod takes the form
                # 'mymodule.views.ViewContainer'. Parse it again to separate
                # the module and class.
                mod, klass = get_mod_func(mod)
                return getattr(getattr(import_module(mod), klass), func)
            except AttributeError:
                # PY2 generates incorrect paths for views that are methods,
                # e.g. 'mymodule.views.ViewContainer.my_view' will be
                # listed as 'mymodule.views.my_view' because the class name
                # can't be detected. This causes an AttributeError when
                # trying to resolve the view.
                return None
项目:liberator    作者:libscie    | 项目源码 | 文件源码
def _get_view_func(view):
        urlconf = get_urlconf()
        if get_resolver(urlconf)._is_callback(view):
            mod, func = get_mod_func(view)
            try:
                # Separate the module and function, e.g.
                # 'mymodule.views.myview' -> 'mymodule.views', 'myview').
                return getattr(import_module(mod), func)
            except ImportError:
                # Import may fail because view contains a class name, e.g.
                # 'mymodule.views.ViewContainer.my_view', so mod takes the form
                # 'mymodule.views.ViewContainer'. Parse it again to separate
                # the module and class.
                mod, klass = get_mod_func(mod)
                return getattr(getattr(import_module(mod), klass), func)
            except AttributeError:
                # PY2 generates incorrect paths for views that are methods,
                # e.g. 'mymodule.views.ViewContainer.my_view' will be
                # listed as 'mymodule.views.my_view' because the class name
                # can't be detected. This causes an AttributeError when
                # trying to resolve the view.
                return None
项目:CSCE482-WordcloudPlus    作者:ggaytan00    | 项目源码 | 文件源码
def _get_view_func(view):
        urlconf = get_urlconf()
        if get_resolver(urlconf)._is_callback(view):
            mod, func = get_mod_func(view)
            try:
                # Separate the module and function, e.g.
                # 'mymodule.views.myview' -> 'mymodule.views', 'myview').
                return getattr(import_module(mod), func)
            except ImportError:
                # Import may fail because view contains a class name, e.g.
                # 'mymodule.views.ViewContainer.my_view', so mod takes the form
                # 'mymodule.views.ViewContainer'. Parse it again to separate
                # the module and class.
                mod, klass = get_mod_func(mod)
                return getattr(getattr(import_module(mod), klass), func)
            except AttributeError:
                # PY2 generates incorrect paths for views that are methods,
                # e.g. 'mymodule.views.ViewContainer.my_view' will be
                # listed as 'mymodule.views.my_view' because the class name
                # can't be detected. This causes an AttributeError when
                # trying to resolve the view.
                return None
项目:producthunt    作者:davidgengler    | 项目源码 | 文件源码
def get_context_data(self, **kwargs):
        view = self.kwargs['view']
        urlconf = get_urlconf()
        if get_resolver(urlconf)._is_callback(view):
            mod, func = get_mod_func(view)
            view_func = getattr(import_module(mod), func)
        else:
            raise Http404
        title, body, metadata = utils.parse_docstring(view_func.__doc__)
        if title:
            title = utils.parse_rst(title, 'view', _('view:') + view)
        if body:
            body = utils.parse_rst(body, 'view', _('view:') + view)
        for key in metadata:
            metadata[key] = utils.parse_rst(metadata[key], 'model', _('view:') + view)
        kwargs.update({
            'name': view,
            'summary': title,
            'body': body,
            'meta': metadata,
        })
        return super(ViewDetailView, self).get_context_data(**kwargs)
项目:django-rtc    作者:scifiswapnil    | 项目源码 | 文件源码
def _get_view_func(view):
        urlconf = get_urlconf()
        if get_resolver(urlconf)._is_callback(view):
            mod, func = get_mod_func(view)
            try:
                # Separate the module and function, e.g.
                # 'mymodule.views.myview' -> 'mymodule.views', 'myview').
                return getattr(import_module(mod), func)
            except ImportError:
                # Import may fail because view contains a class name, e.g.
                # 'mymodule.views.ViewContainer.my_view', so mod takes the form
                # 'mymodule.views.ViewContainer'. Parse it again to separate
                # the module and class.
                mod, klass = get_mod_func(mod)
                return getattr(getattr(import_module(mod), klass), func)
            except AttributeError:
                # PY2 generates incorrect paths for views that are methods,
                # e.g. 'mymodule.views.ViewContainer.my_view' will be
                # listed as 'mymodule.views.my_view' because the class name
                # can't be detected. This causes an AttributeError when
                # trying to resolve the view.
                return None
项目:LatinSounds_AppEnviaMail    作者:G3ek-aR    | 项目源码 | 文件源码
def _get_view_func(view):
        urlconf = get_urlconf()
        if get_resolver(urlconf)._is_callback(view):
            mod, func = get_mod_func(view)
            try:
                # Separate the module and function, e.g.
                # 'mymodule.views.myview' -> 'mymodule.views', 'myview').
                return getattr(import_module(mod), func)
            except ImportError:
                # Import may fail because view contains a class name, e.g.
                # 'mymodule.views.ViewContainer.my_view', so mod takes the form
                # 'mymodule.views.ViewContainer'. Parse it again to separate
                # the module and class.
                mod, klass = get_mod_func(mod)
                return getattr(getattr(import_module(mod), klass), func)
            except AttributeError:
                # PY2 generates incorrect paths for views that are methods,
                # e.g. 'mymodule.views.ViewContainer.my_view' will be
                # listed as 'mymodule.views.my_view' because the class name
                # can't be detected. This causes an AttributeError when
                # trying to resolve the view.
                return None