models.py 文件源码

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

项目:redis-astra 作者: pilat 项目源码 文件源码
def __init__(self, pk=None, **kwargs):
        self._fields = dict()
        self._helpers = set()
        self._hash = {}  # Hash-object cache
        self._hash_loaded = False
        self._fields_loaded = False
        assert isinstance(self.database, redis.StrictRedis)

        if pk is None:
            raise ValueError('You\'re must pass pk for object')
        self.pk = str(pk)  # Always convert to str for key-safe ops.

        # When object initialize with parameters, for example
        # user1 = UserObject(1, name='Username'), then load fields from/to db
        # immediate. When object initialized as user2 = UserObject(1), then
        # information from database not obtain before first data handling
        if kwargs:
            self._load_fields(**kwargs)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号