def add(self, user, summary, details, contact_info, pubdate=None): """ Adds a new entry """ if pubdate is None: pubdate = datetime.now().isoformat() # TODO(Ori): Should we batch these into a single transaction? uid = redis.incr("marcel:%s:next_uid" % self.type) redis.zadd("marcel:%s" % self.type, uid, 0) redis.hmset("marcel:%s:%s" % (self.type, uid), { 'user': user.uuid, 'summary': summary, 'details': details, 'contact_info': contact_info, 'pubdate': pubdate }) return uid
def set(self, **kwargs): """ Store User attributes in Redis """ redis.hmset(self.key, {key: val for key, val in kwargs.items() if val})