Skip to content

Commit

Permalink
chore: Adding file deprecations
Browse files Browse the repository at this point in the history
This is a follow-up on viur-framework#1241
  • Loading branch information
phorward committed Sep 24, 2024
1 parent 5a929ed commit 7180629
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/viur/core/modules/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import requests
import string
import typing as t
import warnings
from collections import namedtuple
from google.appengine.api import images, blobstore
from urllib.parse import quote as urlquote, urlencode
Expand Down Expand Up @@ -1315,3 +1316,19 @@ def start_delete_pending_files():
.filter("pending =", True)
.filter("creationdate <", utils.utcNow() - datetime.timedelta(days=7))
)


# DEPRECATED ATTRIBUTES HANDLING

def __getattr__(attr: str) -> object:
if entry := {
# stuff prior viur-core < 3.7
"GOOGLE_STORAGE_BUCKET": ("File.get_bucket()", _private_bucket),
}.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 7180629

Please sign in to comment.