Kaydet (Commit) 75cf9b5a authored tarafından Tim Graham's avatar Tim Graham

Refs #13110 -- Removed SyndicationFeed.add_item()'s enclosure argument.

Per deprecation timeline.
üst d67a46e1
...@@ -24,10 +24,8 @@ http://web.archive.org/web/20110718035220/http://diveintomark.org/archives/2004/ ...@@ -24,10 +24,8 @@ http://web.archive.org/web/20110718035220/http://diveintomark.org/archives/2004/
from __future__ import unicode_literals from __future__ import unicode_literals
import datetime import datetime
import warnings
from django.utils import datetime_safe, six from django.utils import datetime_safe, six
from django.utils.deprecation import RemovedInDjango20Warning
from django.utils.encoding import force_text, iri_to_uri from django.utils.encoding import force_text, iri_to_uri
from django.utils.six import StringIO from django.utils.six import StringIO
from django.utils.six.moves.urllib.parse import urlparse from django.utils.six.moves.urllib.parse import urlparse
...@@ -119,9 +117,8 @@ class SyndicationFeed(object): ...@@ -119,9 +117,8 @@ class SyndicationFeed(object):
def add_item(self, title, link, description, author_email=None, def add_item(self, title, link, description, author_email=None,
author_name=None, author_link=None, pubdate=None, comments=None, author_name=None, author_link=None, pubdate=None, comments=None,
unique_id=None, unique_id_is_permalink=None, enclosure=None, unique_id=None, unique_id_is_permalink=None, categories=(),
categories=(), item_copyright=None, ttl=None, updateddate=None, item_copyright=None, ttl=None, updateddate=None, enclosures=None, **kwargs):
enclosures=None, **kwargs):
""" """
Adds an item to the feed. All args are expected to be Python Unicode Adds an item to the feed. All args are expected to be Python Unicode
objects except pubdate and updateddate, which are datetime.datetime objects except pubdate and updateddate, which are datetime.datetime
...@@ -135,16 +132,6 @@ class SyndicationFeed(object): ...@@ -135,16 +132,6 @@ class SyndicationFeed(object):
if ttl is not None: if ttl is not None:
# Force ints to unicode # Force ints to unicode
ttl = force_text(ttl) ttl = force_text(ttl)
if enclosure is None:
enclosures = [] if enclosures is None else enclosures
else:
warnings.warn(
"The enclosure keyword argument is deprecated, "
"use enclosures instead.",
RemovedInDjango20Warning,
stacklevel=2,
)
enclosures = [enclosure]
item = { item = {
'title': to_unicode(title), 'title': to_unicode(title),
'link': iri_to_uri(link), 'link': iri_to_uri(link),
......
...@@ -963,7 +963,6 @@ They share this interface: ...@@ -963,7 +963,6 @@ They share this interface:
* ``pubdate`` * ``pubdate``
* ``comments`` * ``comments``
* ``unique_id`` * ``unique_id``
* ``enclosure``
* ``enclosures`` * ``enclosures``
* ``categories`` * ``categories``
* ``item_copyright`` * ``item_copyright``
...@@ -976,17 +975,10 @@ They share this interface: ...@@ -976,17 +975,10 @@ They share this interface:
* ``pubdate`` should be a Python :class:`~datetime.datetime` object. * ``pubdate`` should be a Python :class:`~datetime.datetime` object.
* ``updateddate`` should be a Python :class:`~datetime.datetime` object. * ``updateddate`` should be a Python :class:`~datetime.datetime` object.
* ``enclosure`` should be an instance of
:class:`django.utils.feedgenerator.Enclosure`.
* ``enclosures`` should be a list of * ``enclosures`` should be a list of
:class:`django.utils.feedgenerator.Enclosure` instances. :class:`django.utils.feedgenerator.Enclosure` instances.
* ``categories`` should be a sequence of Unicode objects. * ``categories`` should be a sequence of Unicode objects.
.. deprecated:: 1.9
The ``enclosure`` keyword argument is deprecated in favor of the
``enclosures`` keyword argument.
:meth:`.SyndicationFeed.write` :meth:`.SyndicationFeed.write`
Outputs the feed in the given encoding to outfile, which is a file-like object. Outputs the feed in the given encoding to outfile, which is a file-like object.
......
...@@ -353,18 +353,11 @@ https://web.archive.org/web/20110718035220/http://diveintomark.org/archives/2004 ...@@ -353,18 +353,11 @@ https://web.archive.org/web/20110718035220/http://diveintomark.org/archives/2004
All parameters should be Unicode objects, except ``categories``, which All parameters should be Unicode objects, except ``categories``, which
should be a sequence of Unicode objects. should be a sequence of Unicode objects.
.. method:: add_item(title, link, description, author_email=None, author_name=None, author_link=None, pubdate=None, comments=None, unique_id=None, enclosure=None, categories=(), item_copyright=None, ttl=None, updateddate=None, enclosures=None, **kwargs) .. method:: add_item(title, link, description, author_email=None, author_name=None, author_link=None, pubdate=None, comments=None, unique_id=None, categories=(), item_copyright=None, ttl=None, updateddate=None, enclosures=None, **kwargs)
Adds an item to the feed. All args are expected to be Python ``unicode`` Adds an item to the feed. All args are expected to be Python ``unicode``
objects except ``pubdate`` and ``updateddate``, which are ``datetime.datetime`` objects except ``pubdate`` and ``updateddate``, which are ``datetime.datetime``
objects, ``enclosure``, which is an ``Enclosure`` instance, and objects, and ``enclosures``, which is a list of ``Enclosure`` instances.
``enclosures``, which is a list of ``Enclosure`` instances.
.. deprecated:: 1.9
The ``enclosure`` keyword argument is deprecated in favor of the
new ``enclosures`` keyword argument which accepts a list of
``Enclosure`` objects.
.. method:: num_items() .. method:: num_items()
......
...@@ -312,3 +312,6 @@ these features. ...@@ -312,3 +312,6 @@ these features.
* Support for the ``allow_tags`` attribute on ``ModelAdmin`` methods is * Support for the ``allow_tags`` attribute on ``ModelAdmin`` methods is
removed. removed.
* The ``enclosure`` keyword argument to ``SyndicationFeed.add_item()`` is
removed.
...@@ -9,10 +9,7 @@ from django.core.exceptions import ImproperlyConfigured ...@@ -9,10 +9,7 @@ from django.core.exceptions import ImproperlyConfigured
from django.test import TestCase, override_settings from django.test import TestCase, override_settings
from django.test.utils import requires_tz_support from django.test.utils import requires_tz_support
from django.utils import timezone from django.utils import timezone
from django.utils.deprecation import RemovedInDjango20Warning from django.utils.feedgenerator import rfc2822_date, rfc3339_date
from django.utils.feedgenerator import (
Enclosure, SyndicationFeed, rfc2822_date, rfc3339_date,
)
from .models import Article, Entry from .models import Article, Entry
...@@ -520,16 +517,3 @@ class SyndicationFeedTest(FeedTestCase): ...@@ -520,16 +517,3 @@ class SyndicationFeedTest(FeedTestCase):
views.add_domain('example.com', '//example.com/foo/?arg=value'), views.add_domain('example.com', '//example.com/foo/?arg=value'),
'http://example.com/foo/?arg=value' 'http://example.com/foo/?arg=value'
) )
class FeedgeneratorTestCase(TestCase):
def test_add_item_warns_when_enclosure_kwarg_is_used(self):
feed = SyndicationFeed(title='Example', link='http://example.com', description='Foo')
msg = 'The enclosure keyword argument is deprecated, use enclosures instead.'
with self.assertRaisesMessage(RemovedInDjango20Warning, msg):
feed.add_item(
title='Example Item',
link='https://example.com/item',
description='bar',
enclosure=Enclosure('http://example.com/favicon.ico', 0, 'image/png'),
)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment