news.backends.abstract — Backend interfaces

Provides abstract backend interfaces that should be implemented.

class news.backends.abstract.AbstractBackend(schedule_model=None, news_model=None, *args, **kwargs)

Abstract news backend that should be implemented in orm specific ways

Parameters:
  • schedule_model (Implementation of AbstractSchedule.) – Schedule class to use with backend.
  • news_model (Implementation of AbstractNews.) – News class to use with backend.
delete_news(*news)

Delete news in the backend.

Parameters:news (news_model) – News to delete.
get_news(id)

Should retrive a news with given id.

Parameters:id – Id of the news.
Returns:News of the given id.
Return type:
attr:news_model
get_news_by(owner, url)

Should return a news for owner from backend.

Parameters:
  • owner (owner_model of schedule_model) – Owner of the news.
  • url (str) – Url of the news.
get_news_list(owner, root_url)

Should retrieve a list of news for owner from backend.

Parameters:
  • owner (owner_model of schedule_model) – Owner of the news.
  • root_url (str) – Url of the root news.
Returns:

A list of news under the given root url.

Return type:

list

get_schedule(owner, url)

Should retrieve a schedule for owner from the backend.

Parameters:owner (owner of schedule_model) – Owner of the schedule
Returns:Owner’s schedule with given url.
Return type:schedule_model
get_schedules(owner)

Should retrieve a list of schedule for owner from backend.

Parameters:owner (owner of schedule_model) – Owner of the schedules.
Returns:A list of owner’s schedule.
Return type:list
news_exists(id)

Should check existance of the news in the backend.

Parameters:id (int) – Id of the news.
Returns:Whether the news exists in the backend or not.
Return type:bool
save_news(*news)

Should save news to the backend.

Parameters:news (news_model) – News to save.
schedule_exists(id)

Should check existance of the schedule in the backend.

Parameters:
  • owner (owner of schedule_model) – Owner of the schedule
  • url (str) – Url of the schedule .
Returns:

Whether the schedule exists in the backend or not.

Return type:

bool