当前位置: 首页>>代码示例>>Python>>正文


Python views.Feed方法代码示例

本文整理汇总了Python中django.contrib.syndication.views.Feed方法的典型用法代码示例。如果您正苦于以下问题:Python views.Feed方法的具体用法?Python views.Feed怎么用?Python views.Feed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在django.contrib.syndication.views的用法示例。


在下文中一共展示了views.Feed方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _get_dynamic_attr

# 需要导入模块: from django.contrib.syndication import views [as 别名]
# 或者: from django.contrib.syndication.views import Feed [as 别名]
def _get_dynamic_attr(self, attname, obj, default=None):
        """
        Copied from django.contrib.syndication.views.Feed (v1.7.1)
        """
        try:
            attr = getattr(self, attname)
        except AttributeError:
            return default
        if callable(attr):
            num_args = len(signature(attr).parameters)
            if num_args == 0:
                return attr()
            if num_args == 1:
                return attr(obj)

            raise TypeError(
                "Number of arguments to _get_dynamic_attr needs to be 0 or 1"
            )
        return attr

    # NOTE: Not used by icalendar but required
    #       by the Django syndication framework. 
开发者ID:jazzband,项目名称:django-ical,代码行数:24,代码来源:views.py

示例2: __call__

# 需要导入模块: from django.contrib.syndication import views [as 别名]
# 或者: from django.contrib.syndication.views import Feed [as 别名]
def __call__(self, request, *args, **kwargs):
        """
        Copied from django.contrib.syndication.views.Feed

        Supports file_name as a dynamic attr.
        """
        try:
            obj = self.get_object(request, *args, **kwargs)
        except ObjectDoesNotExist:
            raise Http404("Feed object does not exist.")
        feedgen = self.get_feed(obj, request)
        response = HttpResponse(
            content_type="text/calendar, text/x-vcalendar, application/hbs-vcs"
        )
        if hasattr(self, "item_pubdate") or hasattr(self, "item_updateddate"):
            # if item_pubdate or item_updateddate is defined for the feed, set
            # header so as ConditionalGetMiddleware is able to send 304 NOT MODIFIED
            response["Last-Modified"] = http_date(
                timegm(feedgen.latest_post_date().utctimetuple())
            )
        feedgen.write(response, "utf-8")

        filename = self._get_dynamic_attr("file_name", obj)
        if filename:
            response["Content-Disposition"] = 'attachment; filename="%s"' % filename

        return response 
开发者ID:jazzband,项目名称:django-ical,代码行数:29,代码来源:views.py

示例3: title

# 需要导入模块: from django.contrib.syndication import views [as 别名]
# 或者: from django.contrib.syndication.views import Feed [as 别名]
def title(self, obj):
        return '%s - %s Jobs Feed' % (obj.site.name, obj.name) 
开发者ID:tramcar,项目名称:tramcar,代码行数:4,代码来源:feeds.py


注:本文中的django.contrib.syndication.views.Feed方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。