當前位置: 首頁>>代碼示例>>Python>>正文


Python urlresolvers.RegexURLResolver方法代碼示例

本文整理匯總了Python中django.core.urlresolvers.RegexURLResolver方法的典型用法代碼示例。如果您正苦於以下問題:Python urlresolvers.RegexURLResolver方法的具體用法?Python urlresolvers.RegexURLResolver怎麽用?Python urlresolvers.RegexURLResolver使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在django.core.urlresolvers的用法示例。


在下文中一共展示了urlresolvers.RegexURLResolver方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_01_nb_of_route

# 需要導入模塊: from django.core import urlresolvers [as 別名]
# 或者: from django.core.urlresolvers import RegexURLResolver [as 別名]
def test_01_nb_of_route(self):
        urls = ApiUrls.get_urls()
        # check the nb of defined ressources should be the same as the
        # number of route + 1 done by tastypie
        self.assertEqual(len(urls), self.nb_route + 1)
        self.assertTrue(isinstance(urls.pop(0), RegexURLPattern))

        event_url = urls.pop(0)
        self.assertTrue(isinstance(event_url, RegexURLResolver))
        # XXX depend on the version of tastypie: only use one or both method:
        #     prepend_urls/override_urls
        self.assertIn(len(event_url.url_patterns),
                      [self.nb_route_for_event, self.nb_route_for_event + 2])

        for url in urls:
            self.assertTrue(isinstance(url, RegexURLResolver))
            self.assertEqual(len(url.url_patterns),
                             self.nb_default_route_by_ressource) 
開發者ID:Gandi,項目名稱:baobab,代碼行數:20,代碼來源:test_route.py

示例2: get_all_view_names

# 需要導入模塊: from django.core import urlresolvers [as 別名]
# 或者: from django.core.urlresolvers import RegexURLResolver [as 別名]
def get_all_view_names(self, urlpatterns, parent_regex=''):
        for pattern in urlpatterns:
            if isinstance(pattern, RegexURLResolver):
                regex = '' if pattern._regex == "^" else pattern._regex
                self.get_all_view_names(urlpatterns=pattern.url_patterns, parent_regex=parent_regex + regex)
            elif isinstance(pattern, RegexURLPattern) and self._is_drf_view(pattern) and not self._is_format_endpoint(pattern):
                api_endpoint = ApiEndpoint(pattern, parent_regex, self.drf_router)
                self.endpoints.append(api_endpoint) 
開發者ID:manosim,項目名稱:django-rest-framework-docs,代碼行數:10,代碼來源:api_docs.py

示例3: inner_get_resolver

# 需要導入模塊: from django.core import urlresolvers [as 別名]
# 或者: from django.core.urlresolvers import RegexURLResolver [as 別名]
def inner_get_resolver(urlconf, layout):
    # Loading this upon module import causes problems, so we're going to be
    # lazy about it
    from ..gro_api.urls import get_current_urls

    return urlresolvers.RegexURLResolver(
        r'^/', FakeURLConfModule(get_current_urls())
    ) 
開發者ID:OpenAgricultureFoundation,項目名稱:gro-api,代碼行數:10,代碼來源:patch_resolvers.py

示例4: outer_get_resolver

# 需要導入模塊: from django.core import urlresolvers [as 別名]
# 或者: from django.core.urlresolvers import RegexURLResolver [as 別名]
def outer_get_resolver(urlconf):
    return inner_get_resolver(urlconf, system_layout.current_value)

# Monkey patching `django.core.urlresolvers.get_resolver` doesn't completely
# solve the problem in Django 1.8.3 because
# `django.core.handlers.base.BaseHandler` creates a new
# `django.core.urlresolvers.RegexURLResolver` on every request. This is
# addressed by ticket #14200 (https://code.djangoproject.com/ticket/14200).
# A patch for this problem has been written and accepted, and should appear in
# the next Django release. Until then, we essentially apply the accepted patch
# ourselves by monkey patching `BaseHandler.get_response`. 
開發者ID:OpenAgricultureFoundation,項目名稱:gro-api,代碼行數:13,代碼來源:patch_resolvers.py

示例5: __init__

# 需要導入模塊: from django.core import urlresolvers [as 別名]
# 或者: from django.core.urlresolvers import RegexURLResolver [as 別名]
def __init__(self, conf):
        self.resolver = RegexURLResolver(r'^', conf) 
開發者ID:jlmadurga,項目名稱:django-telegram-bot,代碼行數:4,代碼來源:resolver.py

示例6: handle_message

# 需要導入模塊: from django.core import urlresolvers [as 別名]
# 或者: from django.core.urlresolvers import RegexURLResolver [as 別名]
def handle_message(self, message, bot_service):
        """
        Process incoming message generating a response to the sender.
        
        :param message: Generic message received from provider
        :param bot_service: Service Integration
        :type bot_service: IntegrationBot :class:`IntegrationBot <permabots.models.bot.IntegrationBot>`

        .. note:: Message content will be extracted by IntegrationBot
        """
        urlpatterns = []
        state_context = {}
        chat_state = bot_service.get_chat_state(message)
        for handler in caching.get_or_set_related(self, 'handlers', 'response', 'request', 'target_state'):
            if handler.enabled:
                source_states = caching.get_or_set_related(handler, 'source_states')
                if chat_state:
                    state_context = chat_state.ctx
                if not source_states or (chat_state and chat_state.state in source_states):
                        urlpatterns.append(handler.urlpattern())
                    
        resolver = RegexURLResolver(r'^', urlpatterns)
        try:
            resolver_match = resolver.resolve(bot_service.message_text(message))
        except Resolver404:
            logger.warning("Handler not found for %s" % message)
        else:
            callback, callback_args, callback_kwargs = resolver_match
            logger.debug("Calling callback:%s for message %s with %s" % 
                         (callback, message, callback_kwargs))
            text, keyboard, target_state, context = callback(self, message=message, service=bot_service.identity, 
                                                             state_context=state_context, **callback_kwargs)
            if target_state:
                self.update_chat_state(bot_service, message, chat_state, target_state, context)
            keyboard = bot_service.build_keyboard(keyboard)
            bot_service.send_message(bot_service.get_chat_id(message), text, keyboard, message) 
開發者ID:jlmadurga,項目名稱:permabots,代碼行數:38,代碼來源:bot.py

示例7: find_url_callbacks

# 需要導入模塊: from django.core import urlresolvers [as 別名]
# 或者: from django.core.urlresolvers import RegexURLResolver [as 別名]
def find_url_callbacks(urls_module):
    urlpatterns = urls_module.urlpatterns
    hid_list = [urls_module.__name__]
    for pattern in urlpatterns:
        if isinstance(pattern, RegexURLPattern):
            hid_list.append(pattern.callback.__module__)
        elif isinstance(pattern, RegexURLResolver):
            hid_list += find_url_callbacks(pattern.urlconf_module)
    return hid_list 
開發者ID:Lithium876,項目名稱:ConTroll_Remote_Access_Trojan,代碼行數:11,代碼來源:django-import-finder.py


注:本文中的django.core.urlresolvers.RegexURLResolver方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。