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)
评论列表
文章目录