code: def write_user(user):
      
  
      udata = {}
  
      for f in USER_FIELDS:
          udata[f] = getattr(user, f)
  
      for p in PERMISSIONS:
          udata[p] = '1' if getattr(user, p) else '0'
      db.hmset('user:{0}'.format(user.uid), udata)
docs: Write an user ot the database.
  
      :param User user: User to write