[MRG+1] Implement FormRequest.from_response CSS support #1382

Merged
merged 1 commit into from Jan 21, 2016

Projects

None yet

5 participants

@barraponto
Contributor

Since we have a formxpath argument, it makes sense to have formcss argument.

Solves #1374

@kmike
Member
kmike commented Jul 29, 2015

LGTM.

@kmike kmike changed the title from Implement FormRequest.from_response CSS support to [MRG+1] Implement FormRequest.from_response CSS support Jul 29, 2015
@barraponto
Contributor

There is also the case where both formxpath and formcss are defined: as I've implemented it, formcss overrides formxpath. Should we document it or should we raise some error?

@kmike
Member
kmike commented Jul 30, 2015

There is also the case where both formxpath and formcss are defined: as I've implemented it, formcss overrides formxpath. Should we document it or should we raise some error?

Yes, documenting it could be nice. But for other arguments the priority is also neither documented nor validated. Your PR is not making things any worse and adds a feature which fits into current design, that's why I'm +1 to merge it :)

In the long term we need to cleanup FormRequest. Maybe it should accept a Selector in addition to Response as a first argument? Or an lxml <form> element directly. This way we won't have issues with xpath/css priorities.

These form... arguments are a mess. See e.g. #1137 - currently you can pass formname and get a form with a different name submitted.

@barraponto
Contributor

okay, then I'm fine with it :shipit:

@eliasdorneles
Member

hey @barraponto, this looks good!
Could you solve the conflicts, so we can merge this?
Thanks, man!

@barraponto
Contributor

did a small refactor, leveraging parsel and moving the css-to-xpath conversion to a higher level (making for less internal changes).

@eliasdorneles
Member

Very nice, thanks, @barraponto !
Can you change the test to use bytes (e.g. self.assertEqual(fs[b'one'], [b'1'])), so that it passes for PY33 too? Will be ready to merge after that. :)

@barraponto barraponto implements FormRequest.from_response CSS support
659715e
@codecov-io

Current coverage is 82.95%

Merging #1382 into master will increase coverage by +0.03% as of 13fe6ea

Powered by Codecov. Updated on successful CI builds.

@barraponto
Contributor

Yay, got the green light from Travis!

@eliasdorneles eliasdorneles merged commit a6e5c84 into scrapy:master Jan 21, 2016

2 checks passed

codecov/patch 100.00% of diff hit (target 100.00%)
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@eliasdorneles
Member

Thanks a bunch @barraponto ! :)

@kmike kmike commented on the diff Jan 21, 2016
docs/topics/request-response.rst
@@ -339,6 +342,9 @@ fields with form data from :class:`Response` objects.
.. versionadded:: 0.17
The ``formxpath`` parameter.
+ .. versionadded:: 1.1.5
@kmike
kmike Jan 21, 2016 Member

We don't have this version yet :) I think this change will be included in 1.1.0.

@eliasdorneles
eliasdorneles Jan 21, 2016 Member

oops, sorry, I missed that (I shouldn't merge PRs after midnight!).
lemme fix that

@redapple redapple added this to the Scrapy 1.1 milestone Jan 25, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment