Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass info from FEEDS to ItemExporter #4606

Closed
StasDeep opened this issue Jun 1, 2020 · 2 comments · Fixed by #4768
Closed

Pass info from FEEDS to ItemExporter #4606

StasDeep opened this issue Jun 1, 2020 · 2 comments · Fixed by #4768

Comments

@StasDeep
Copy link
Contributor

StasDeep commented Jun 1, 2020

Summary

The new FeedExporter class doesn't allow to pass custom info to ItemExporter through the FEEDS setting.

Motivation

My use-case is a bit too long to describe, but it can be minimized to the following: for example, I have a custom ItemExporter which I want to have different options for different feeds. Say I want to pass custom param option to it.

class CustomItemExporter(BaseItemExporter):
    
    def _configure(self, options, dont_fail=False):
        super()._configure(options, dont_fail)
        self.param = options.pop('param', None)
        
    def export_item(self, item):
        # Using self.param here
        ...

Ideally, I would like to do set it like this:

FEEDS = {
    uri_detail: {'format': 'custom', 'item_export_kwargs': {'param' : 'Detail'}},
    uri_overview: {'format': 'custom', 'item_export_kwargs': {'param' : 'Overview'} }
}

Describe alternatives you've considered

The only workaround I've found was to create a new FeedExporter class and override open_spider method to pass feed['item_export_kwargs'] to _get_exporter method.

Additional context

Will provide a PR this week.

@Gallaecio
Copy link
Member

Gallaecio commented Jun 2, 2020

I implemented this in #4512, as I needed it there.

@StasDeep
Copy link
Contributor Author

StasDeep commented Jun 2, 2020

@Gallaecio if I understand the changes correctly, it is now possible to pass it to FeedStorage. What I want, though, is passing custom args to ItemExporters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants