Skip to content

Commit 7180629

Browse files
committed
chore: Adding file deprecations
This is a follow-up on viur-framework#1241
1 parent 5a929ed commit 7180629

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/viur/core/modules/file.py

+17
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import requests
1414
import string
1515
import typing as t
16+
import warnings
1617
from collections import namedtuple
1718
from google.appengine.api import images, blobstore
1819
from urllib.parse import quote as urlquote, urlencode
@@ -1315,3 +1316,19 @@ def start_delete_pending_files():
13151316
.filter("pending =", True)
13161317
.filter("creationdate <", utils.utcNow() - datetime.timedelta(days=7))
13171318
)
1319+
1320+
1321+
# DEPRECATED ATTRIBUTES HANDLING
1322+
1323+
def __getattr__(attr: str) -> object:
1324+
if entry := {
1325+
# stuff prior viur-core < 3.7
1326+
"GOOGLE_STORAGE_BUCKET": ("File.get_bucket()", _private_bucket),
1327+
}.get(attr):
1328+
func = entry[1]
1329+
msg = f"{attr} was replaced by {entry[0]}"
1330+
warnings.warn(msg, DeprecationWarning, stacklevel=2)
1331+
logging.warning(msg, stacklevel=2)
1332+
return func
1333+
1334+
return super(__import__(__name__).__class__).__getattribute__(attr)

0 commit comments

Comments
 (0)