mirror of https://github.com/scrapy/scrapy.git
allow to override item class adaptor in constructor
--HG-- extra : convert_revision : svn%3Ab85faa78-f9eb-468e-a121-7cced6da292c%40277
This commit is contained in:
parent
79485ceb5c
commit
c73cbdd9b1
|
|
@ -3,8 +3,15 @@ from scrapy.item.adaptors import AdaptorPipe
|
|||
class ScrapedItem(object):
|
||||
"""
|
||||
This is the base class for all scraped items.
|
||||
'guid' attribute is required, and is an attribute
|
||||
that identifies uniquely the given scraped item.
|
||||
"""
|
||||
adaptors_pipe = AdaptorPipe([])
|
||||
adaptors_pipe = AdaptorPipe()
|
||||
|
||||
def __init__(self, adaptors_pipe=None):
|
||||
"""If an adaptors_pipe is given, overrides class adaptors_pipe"""
|
||||
if adaptors_pipe:
|
||||
self.adaptors_pipe = adaptors_pipe
|
||||
|
||||
def attribute(self, attrname, value):
|
||||
value = self.adaptors_pipe.execute(attrname, value)
|
||||
|
|
|
|||
Loading…
Reference in New Issue