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


Python http.urlquote_plus方法代碼示例

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


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

示例1: make_query_parameter

# 需要導入模塊: from django.utils import http [as 別名]
# 或者: from django.utils.http import urlquote_plus [as 別名]
def make_query_parameter(self,
                             predicate,
                             obj,
                             item_type=False):
        """ makes a query parameter depending on the value
            of the predicate slug
        """
        if 'http://' in predicate or 'https://' in predicate:
            predicate = urlquote_plus(predicate)
        if 'http://' in obj or 'https://' in obj:
            obj = urlquote_plus(obj)
        dc_terms_obj = DCterms()
        if predicate in dc_terms_obj.DC_SLUG_TO_FIELDS:
            # there's a query parameter for this dc-terms metadata
            query = dc_terms_obj.DC_SLUG_TO_FIELDS[predicate]
            query += '=' + obj
        elif item_type == 'predicates':
            query = 'prop=' + obj
        elif item_type == 'types':
            query = 'obj=' + obj
        else:
            query = 'prop=' + predicate + '---' + obj
        return query 
開發者ID:ekansa,項目名稱:open-context-py,代碼行數:25,代碼來源:templating.py

示例2: get

# 需要導入模塊: from django.utils import http [as 別名]
# 或者: from django.utils.http import urlquote_plus [as 別名]
def get(self, request, *args, **kwargs):
        def unwhitespace(val):
            return " ".join(val.split())
        if 'ps_q' in request.GET:
            # Keeping Unicode in URL, replacing space with '+'.
            query = uri_to_iri(urlquote_plus(unwhitespace(request.GET['ps_q'])))
            params = {'query': query} if query else None
            return HttpResponseRedirect(reverse_lazy('search', kwargs=params))
        query = kwargs['query'] or ''  # Avoiding query=None
        self.query = unwhitespace(unquote_plus(query))
        # Exclude places whose owner blocked unauthenticated viewing.
        if not request.user.is_authenticated:
            self.queryset = self.queryset.exclude(owner__pref__public_listing=False)
        return super().get(request, *args, **kwargs) 
開發者ID:tejoesperanto,項目名稱:pasportaservo,代碼行數:16,代碼來源:listing.py

示例3: encode_url_context_path

# 需要導入模塊: from django.utils import http [as 別名]
# 或者: from django.utils.http import urlquote_plus [as 別名]
def encode_url_context_path(self, context):
        """ encodes a context path for a URL, retains
            the path '/' characters
        """
        if '/' in context:
            context_ex = context.split('/')
        else:
            context_ex = [context]
        quote_context_list = []
        for c_part in context_ex:
            url_c_part = urlquote_plus(c_part)
            quote_context_list.append(url_c_part)
        return '/'.join(quote_context_list) 
開發者ID:ekansa,項目名稱:open-context-py,代碼行數:15,代碼來源:models.py

示例4: get_prev_marker

# 需要導入模塊: from django.utils import http [as 別名]
# 或者: from django.utils.http import urlquote_plus [as 別名]
def get_prev_marker(self):
        """Returns the identifier for the first object in the current data set
        for APIs that use marker/limit-based paging.
        """
        return http.urlquote_plus(self.get_object_id(self.data[0])) \
            if self.data else '' 
開發者ID:CiscoSystems,項目名稱:avos,代碼行數:8,代碼來源:base.py

示例5: get_marker

# 需要導入模塊: from django.utils import http [as 別名]
# 或者: from django.utils.http import urlquote_plus [as 別名]
def get_marker(self):
        """Returns the identifier for the last object in the current data set
        for APIs that use marker/limit-based paging.
        """
        return http.urlquote_plus(self.get_object_id(self.data[-1])) \
            if self.data else '' 
開發者ID:CiscoSystems,項目名稱:avos,代碼行數:8,代碼來源:base.py

示例6: __call__

# 需要導入模塊: from django.utils import http [as 別名]
# 或者: from django.utils.http import urlquote_plus [as 別名]
def __call__(self, request):
        if is_public_path(request.path):
            return self.get_response(request)

        if request.user.is_anonymous:
            return HttpResponseRedirect(
                "/MAAS/?next=%s" % urlquote_plus(request.path)
            )

        return self.get_response(request) 
開發者ID:maas,項目名稱:maas,代碼行數:12,代碼來源:middleware.py

示例7: create_opengraph

# 需要導入模塊: from django.utils import http [as 別名]
# 或者: from django.utils.http import urlquote_plus [as 別名]
def create_opengraph(self):
        """ creates opengraph metadata to facilitate snippets for
            social media sites
        """
        rp = RootPath()
        base_url = rp.get_baseurl()
        if isinstance(self.project_hero_uri, str):
            self.og_image = self.project_hero_uri
        else:
            if self.observations is not False:
                for obs in self.observations:
                    if obs.media_link_count >0:
                        for link in obs.media_links:
                            self.og_image = link.media[0].thumbnail
                            break
        if self.content is not False:
            # use a preview or a thumbnail image as the og_image
            # also maybe a short description
            if 'preview' in self.content and self.fullimage:
                if isinstance(self.content['preview'], str):
                    self.og_image = self.content['preview']
            elif 'thumbnail' in self.content:
                if isinstance(self.content['thumbnail'], str):
                    self.og_image = self.content['thumbnail']
            else:
                # don't use any image
                pass
            if 'sum_text' in self.content:
                # we have summary text, so use it
                if len(self.content['sum_text']) > 0:
                    self.og_description = self.content['sum_text']
        if not isinstance(self.og_image, str):
            if isinstance(self.item_category_icon, str):
                # we don't have an og_image yet, but we do have a category icon,
                # so use that
                self.og_image = self.item_category_icon
            else:
                # use the default Open Context icon
                rp = RootPath()
                base_url = rp.get_baseurl()
                self.og_image = base_url + self.OPEN_CONTEXT_ICON
            # do this anyway, since small pictures do not work.
            self.og_image = base_url + self.OPEN_CONTEXT_ICON
        if isinstance(self.og_image, str):
            # if the base URL is not in the sting, we need to use a proxy
            if base_url not in self.og_image:
                proxy_url = base_url + '/entities/proxy/'
                proxy_url += urlquote_plus(self.og_image)
                self.og_image = proxy_url
        self.og_title = self.citation.cite_title
        if not isinstance(self.og_description, str):
            self.og_description = ''
            if isinstance(self.item_category_label, str) and self.act_nav == 'subjects':
                self.og_description += self.item_category_label
            if self.act_nav in self.ITEM_TYPE_DESCRIPTIONS:
                if self.og_description == '':
                    self.og_description = 'A'
                self.og_description += ' ' + self.ITEM_TYPE_DESCRIPTIONS[self.act_nav]
            if self.act_nav != 'projects' and isinstance(self.project.label, str):
                self.og_description += '; part of the ' + self.project.label
                self.og_description += ' data publication.' 
開發者ID:ekansa,項目名稱:open-context-py,代碼行數:63,代碼來源:templating.py


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