_google_appengine_ext_ndb.py 文件源码

python
阅读 15 收藏 0 点赞 0 评论 0

项目:Tinychat-Bot--Discontinued 作者: Tinychat 项目源码 文件源码
def getCustomProperties(self):
        props = {}
        # list of property names that are considered read only
        read_only_props = []
        repeated_props = {}
        non_repeated_props = {}
        # list of property names that are computed
        computed_props = {}

        for name, prop in self.klass._properties.iteritems():
            props[name] = prop

            if prop._repeated:
                repeated_props[name] = prop
            else:
                non_repeated_props[name] = prop

            if isinstance(prop, ndb.ComputedProperty):
                computed_props[name] = prop

        if issubclass(self.klass, polymodel.PolyModel):
            del props['class']

        # check if the property is a defined as a computed property. These
        # types of properties are read-only
        for name, value in self.klass.__dict__.iteritems():
            if isinstance(value, ndb.ComputedProperty):
                read_only_props.append(name)

        self.encodable_properties.update(props.keys())
        self.decodable_properties.update(props.keys())
        self.readonly_attrs.update(read_only_props)

        if computed_props:
            self.decodable_properties.difference_update(computed_props.keys())

        self.model_properties = props or None
        self.repeated_properties = repeated_props or None
        self.non_repeated_properties = non_repeated_props or None
        self.computed_properties = computed_props or None
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号