class TreeSkel(Skeleton): parententry = keyBone(descr="Parent", visible=False, indexed=True, readOnly=True) parentrepo = keyBone(descr="BaseRepo", visible=False, indexed=True, readOnly=True) sortindex = numericBone(descr="SortIndex", visible=False, indexed=True, readOnly=True, precision=8, max=pow(2, 30)) @classmethod def preProcessSerializedData(cls, skelValues, entity): if not ("sortindex" in entity and entity["sortindex"]): entity["sortindex"] = time() return entity @classmethod def refresh(cls, skelValues): # ViUR2 Compatibility super().refresh(skelValues) if not skelValues["parententry"] and skelValues.dbEntity.get( "parentdir"): # parentdir for viur2 compatibility skelValues["parententry"] = utils.normalizeKey( db.Key.from_legacy_urlsafe(skelValues.dbEntity["parentdir"]))
class TreeSkel(Skeleton): parententry = keyBone(descr="Parent", visible=False, indexed=True, readOnly=True) parentrepo = keyBone(descr="BaseRepo", visible=False, indexed=True, readOnly=True) sortindex = numericBone(descr="SortIndex", mode="float", visible=False, indexed=True, readOnly=True, max=pow(2, 30)) def preProcessSerializedData(self, dbfields): if not ("sortindex" in dbfields and dbfields["sortindex"]): dbfields["sortindex"] = time() return dbfields
class TreeSkel(Skeleton): parententry = keyBone(descr="Parent", visible=False, indexed=True, readOnly=True) parentrepo = keyBone(descr="BaseRepo", visible=False, indexed=True, readOnly=True) sortindex = numericBone(descr="SortIndex", mode="float", visible=False, indexed=True, readOnly=True, max=pow(2, 30)) @classmethod def preProcessSerializedData(cls, skelValues, entity): if not ("sortindex" in entity and entity["sortindex"]): entity["sortindex"] = time() return entity
def test_isEmpty_emptyNone(self): from viur.core.bones import numericBone self._run_tests(numericBone(getEmtpyValueFunc=lambda: None))
def test_isEmpty_default_bone(self): from viur.core.bones import numericBone self._run_tests(numericBone())
def test_isEmpty_precision(self): from viur.core.bones import numericBone self._run_tests(numericBone(precision=2))