'Scrapy use other variables of item in item processor

I am requesting adress information for a webservice to crosscheck whether the adres that I already have is in the same format as the webservice I am requesting from.

For this I have the following item with the following input_processor:


class AdresItem(scrapy.Item):

    postal_code = scrapy.Field()
    house_number = scrapy.Field()
    addition = scrapy.Field()
    scraped_addition = scrapy.Field(
                                 input_processor = MapCompose(MyFunction),
                                 output_processor = TakeFirst()
                              )


def MyFunction(scraped_addition):
    if scraped_addition == addition
        return scraped_addition
    else:
        return None

ofcourse I can't access the original addition this way. What would be a good way to go about using another variable of the item in the input processor?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source