mirror of https://github.com/scrapy/scrapy.git
Document that follow_all requests share meta and cb_kwargs values (#7962)
This commit is contained in:
parent
95fe7acc86
commit
a0d1ad2001
|
|
@ -305,6 +305,11 @@ class Response(object_ref):
|
|||
:class:`~.TextResponse` provides a :meth:`~.TextResponse.follow_all`
|
||||
method which supports selectors in addition to absolute/relative URLs
|
||||
and Link objects.
|
||||
|
||||
.. caution:: Every returned request gets its own *meta* and
|
||||
*cb_kwargs* dictionaries, but the values within them are shared.
|
||||
Mutating one of those values, e.g. appending to a list, affects
|
||||
all the returned requests.
|
||||
"""
|
||||
if not hasattr(urls, "__iter__"):
|
||||
raise TypeError("'urls' argument must be an iterable")
|
||||
|
|
|
|||
|
|
@ -276,6 +276,9 @@ class TextResponse(Response):
|
|||
using the ``css`` or ``xpath`` parameters, this method will not produce requests for
|
||||
selectors from which links cannot be obtained (for instance, anchor tags without an
|
||||
``href`` attribute)
|
||||
|
||||
.. seealso:: :meth:`.Response.follow_all`, for a caution about mutable
|
||||
*meta* and *cb_kwargs* values.
|
||||
"""
|
||||
arguments = [x for x in (urls, css, xpath) if x is not None]
|
||||
if len(arguments) != 1:
|
||||
|
|
|
|||
|
|
@ -15,8 +15,7 @@ logger = logging.getLogger(__name__)
|
|||
|
||||
class MetaCopyDetectionMiddleware(BaseSpiderMiddleware):
|
||||
"""Warn when a spider yields a request with internal meta keys that should
|
||||
not be copied from response.meta, or when two requests share the same meta
|
||||
dict object.
|
||||
not be copied from response.meta.
|
||||
|
||||
Each warning is emitted at most once per crawl.
|
||||
"""
|
||||
|
|
|
|||
Loading…
Reference in New Issue