CodeSOD: The Base Model

This post was originally published on this site

The Daily WTF

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.