-Поиск по дневнику

Поиск сообщений в rss_thedaily_wtf

 -Подписка по e-mail

 

 -Постоянные читатели

 -Статистика

Статистика LiveInternet.ru: показано количество хитов и посетителей
Создан: 06.04.2008
Записей:
Комментариев:
Написано: 0


CodeSOD: The Base Model

Среда, 21 Сентября 2022 г. 09:30 + в цитатник

Penny uses a Python ORM. Like most ORMs, it involves a lot of "inherit from a BaseModel class, and get all your database access stuff for "free". Or at least, it used to. They've released an update.

def __init__(self, *args, **kwargs): if hasattr(self, "ACCESS_POLICY_VIEWSET_NAME"): deprecation_logger.warn( f"The model {self.__class__} defines the 'ACCESS_POLICY_VIEWSET_NAME' class " f"attribute which is no longer required and is discouraged to be set." ) return super().__init__(*args, **kwargs)

Now, this is an interesting class of breaking change. Everyone like Penny has been class MyEntity(BaseModel) for the entire time they've been using the framework. Whether or not that's a good way to do ORMs, it's going to disrupt a lot of people's code.

In Penny's case, their application uses the ORM for syncing data between large databases, and they're large and complicated- thousands of entities have to get synced, and each entity inherits from that BaseModel class. This means that not only does nearly every entity need to be changed, but also that every time they run their code, they generate many many thousands of lines of logged warnings.

[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!

https://thedailywtf.com/articles/the-base-model

Метки:  

 

Добавить комментарий:
Текст комментария: смайлики

Проверка орфографии: (найти ошибки)

Прикрепить картинку:

 Переводить URL в ссылку
 Подписаться на комментарии
 Подписать картинку