示例#1
0
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"]))
示例#2
0
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
示例#3
0
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
示例#4
0
 def test_isEmpty_emptyNone(self):
     from viur.core.bones import numericBone
     self._run_tests(numericBone(getEmtpyValueFunc=lambda: None))
示例#5
0
 def test_isEmpty_default_bone(self):
     from viur.core.bones import numericBone
     self._run_tests(numericBone())
示例#6
0
 def test_isEmpty_precision(self):
     from viur.core.bones import numericBone
     self._run_tests(numericBone(precision=2))