Skip to content

Commit

Permalink
feat: Add deprecation handling to skeleton (#984)
Browse files Browse the repository at this point in the history
Handles `seoKeyBone` usage, which is now `SeoKeyBone`.

---------

Co-authored-by: Sven Eberth <mail@sveneberth.de>
  • Loading branch information
phorward and sveneberth authored Mar 8, 2024
1 parent 628785a commit be9417c
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/viur/core/skeleton.py
Original file line number Diff line number Diff line change
Expand Up @@ -1625,3 +1625,22 @@ def processVacuumRelationsChunk(

# Forward our references to SkelInstance to the database (needed for queries)
db.config["SkeletonInstanceRef"] = SkeletonInstance


# DEPRECATED ATTRIBUTES HANDLING

__DEPRECATED_NAMES = {
# stuff prior viur-core < 3.6
"seoKeyBone": ("SeoKeyBone", SeoKeyBone),
}


def __getattr__(attr: str) -> object:
if entry := __DEPRECATED_NAMES.get(attr):
func = entry[1]
msg = f"{attr} was replaced by {entry[0]}"
warnings.warn(msg, DeprecationWarning, stacklevel=2)
logging.warning(msg, stacklevel=2)
return func

return super(__import__(__name__).__class__).__getattribute__(attr)

0 comments on commit be9417c

Please sign in to comment.