-
Notifications
You must be signed in to change notification settings - Fork 16
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
Extend ItemLoader processors #31
Comments
I am having a hard time trying to picture what you want done, even after reading the documentation from your pull request. Could you provide some sample code that shows the (convoluted) way to achieve your goal before your changes, and the (simpler) way to do the same after your suggested changes? |
We have a custom itemloader which specifies some default input processors. Some fields needs an additional input processor which is specific for this field. Now we need to copy the default input processor and add the new one. We we want to add a new default input processor in the future we have to do this at all those fields again. I would like to be able to keep the default input processor and only extend it with one new input processor. Example:
I hope this makes the use case a bit more clear |
So, if I got it right, you are saying that you have:
How would you like that to look like instead? |
No we don't use the
But I would like to do it in this style
This way I don't have to duplicate the |
@Gallaecio Do you understand the problem now? Or do I need to explain more? |
I think I understand, although I personally don’t like coupling Item’s Field class and the ItemLoader class that way. |
Currently there are three methods to add ItemLoader processor:
default_input/output_processor
on theItemLoader
classfield_name_in/out
on theItemLoader
classinput/output_processor
on thescrapy.Field
Personally I use the
input/output_processor
on thescrapy.Field
combined with thedefault_input/output_processor
a lot. But I use those in combination. Often I just want to add one more processor after the default processors. Sinceinput/output_processor
onscrapy.Field
does a override of the defaults this is quite hard to do.So I would propose to add another method to add a input/output processors. I would like to have something like
add_input/output
on thescrapy.Field
, which would add the specified processor to the default processor.I did implement this on my own ItemLoader class but think that it would be usefull for the scrapy core. My implementation is as follows (original source: https://github.com/scrapy/scrapy/blob/master/scrapy/loader/__init__.py#L69). Ofcourse this can be added to
get_output_processor
in the same way.I am not sure if
add_input
is a good name, probablyextend_input_processor
is more clear but this quite a long name. I would like to hear if more people are wanting this feature and what you all think about what the naming should be.The text was updated successfully, but these errors were encountered: