Skip to content

Provide item classes directly #23

@kmike

Description

@kmike

An idea: allow callbacks to request item classes directly. So, instead of writing one of those:

    def parse_product(self, response: DummyResponse,
                      page: AutoExtractProductPage):
        product = page.to_item()

    def parse_product(self, response: DummyResponse,
                      produuct_data: AutoExtractProductData):
        product = product_data.to_item()

it would be possible to write

    def parse_product(self, response: DummyResponse,
                      product: Product):

Edge cases:

  1. If I'm not mistaken, to_item() might return None. It seems errback should be called in this case.
  2. There can be non-autoextract ways to get Product, so there should be a way to turn it off (or turn it on, depending on what the default we decide on). It could be a separate provider or an option.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions