Skip to content

Commit

Permalink
Merge branch 'main' into fix/email_renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
sveneberth authored Jan 29, 2025
2 parents 4d39a00 + 3c8680f commit 08734b1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 15 deletions.
5 changes: 3 additions & 2 deletions src/viur/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,9 @@
]

# Show DeprecationWarning from the viur-core
warnings.filterwarnings("always", category=DeprecationWarning, module=r"viur\.core.*")

warnings.filterwarnings("once", category=DeprecationWarning)
warnings.filterwarnings("ignore", category=DeprecationWarning, module=r"viur\.datastore.*",
message="'clonedBoneMap' was renamed into 'bone_map'")

def setDefaultLanguage(lang: str):
"""
Expand Down
19 changes: 9 additions & 10 deletions src/viur/core/modules/script.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,26 @@
import re
import typing as t
from viur.core.bones import *
from viur.core.prototypes.tree import Tree, TreeSkel, SkelType
from viur.core.modules.file import File
from viur.core import db, conf, current, skeleton, tasks, errors
from viur.core.decorators import exposed
from viur.core.i18n import translate

# pre-compile patterns for vfuncs
DIRECTORY_PATTERN = re.compile(r'^[a-zA-Z0-9äöüÄÖÜ_-]*$')
FILE_PATTERN = re.compile(r'^[a-zA-Z0-9äöüÄÖÜ_-]+?.py$')


class BaseScriptAbstractSkel(TreeSkel):

path = StringBone(
descr="Path",
readOnly=True,
unique=UniqueValue(UniqueLockMethod.SameValue, True, "This path name is already taken!")
unique=UniqueValue(UniqueLockMethod.SameValue, True, "This path is already taken!")
)

@classmethod
def fromClient(cls, skel, data, *args, **kwargs):
# Set script name when provided, so that the path can be regenerated
if name := data.get("name"):
skel["name"] = name
conf.main_app.vi.script.update_path(skel)
conf.main_app.script.update_path(skel)

ret = super().fromClient(skel, data, *args, **kwargs)

Expand Down Expand Up @@ -54,7 +50,7 @@ class ScriptNodeSkel(BaseScriptAbstractSkel):
name = StringBone(
descr="Folder",
required=True,
vfunc=lambda value: not DIRECTORY_PATTERN.match(value)
vfunc=lambda value: None if File.is_valid_filename(value) else "Foldername is invalid"
)


Expand All @@ -63,12 +59,15 @@ class ScriptLeafSkel(BaseScriptAbstractSkel):

name = StringBone(
descr="Filename",
vfunc=lambda value: not FILE_PATTERN.match(value),
required=True,
vfunc=lambda value:
None if File.is_valid_filename(value) and value.endswith(".py") and value.removesuffix(".py")
else "Filename is invalid or doesn't have a '.py'-suffix",
)

script = RawBone(
descr="Code",
indexed=False
indexed=False,
)

access = SelectBone(
Expand Down
3 changes: 0 additions & 3 deletions src/viur/core/skeleton.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,6 @@ class BaseSkeleton(object, metaclass=MetaBaseSkel):
@deprecated(
version="3.7.0",
reason="Function renamed. Use subskel function as alternative implementation.",
action="always"
)
def subSkel(cls, *subskel_names, fullClone: bool = False, **kwargs) -> SkeletonInstance:
return cls.subskel(*subskel_names, clone=fullClone) # FIXME: REMOVE WITH VIUR4
Expand Down Expand Up @@ -1099,7 +1098,6 @@ def fromClient(
@deprecated(
version="3.7.0",
reason="Use skel.read() instead of skel.fromDB()",
action="once"
)
def fromDB(cls, skel: SkeletonInstance, key: KeyType) -> bool:
"""
Expand Down Expand Up @@ -1166,7 +1164,6 @@ def read(
@deprecated(
version="3.7.0",
reason="Use skel.write() instead of skel.toDB()",
action="once"
)
def toDB(cls, skel: SkeletonInstance, update_relations: bool = True, **kwargs) -> db.Key:
"""
Expand Down

0 comments on commit 08734b1

Please sign in to comment.