Skip to content

Discussion for subdomain overrides #52

@BurnzZ

Description

@BurnzZ

Background

Currently, the @override_for decorator only works for top-level domains. However, there are some cases wherein a site has multiple subdomains, usually per country (where each has a slightly different layout). This is due to the current setup of get_domain() (ref).

The problem lies in the following workaround due to limitations of the current @override_for decorator interface:

@override_for("example.com", AutoExtractArticleListData)
@attr.s(auto_attribs=True)
class ExampleArticleListPage(AutoExtractItemWebPage):
    article_list_data: AutoExtractArticleListData

    def to_item(self) -> ArticleList:
    	article_list = self.article_list_data.to_item()

    	if "uk.example.com" in self.url:
    		return self._handle_uk(article_list)

    	elif "au.example.com" in self.url:
    		return self._handle_uk(article_list)

    	elif "fr.example.com" in self.url:
    		return self._handle_fr(article_list)

    	return article_list

Objectives

I'm wondering if it's worth it to update the current interface with something like this?

@override_for("example.com", AutoExtractArticleListData, subdomain="uk")
@override_for("example.com", AutoExtractArticleListData, subdomain="au")
@override_for("example.com", AutoExtractArticleListData, subdomain="fr")

Depending on the situation, this provides another option on how to structure the collection of PageObjects in the project.

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