Ejemplo n.º 1
0
 def post(self):
     message = "User {0} logged in".format(self.uid)
     user = User.find_by_name(self.request.db, self.uid)
     if not user:
         self.log.info("Created user {}".format(self.uid))
         User.create(self.request.db, name=self.uid, mood=0)
     self.log.info(message)
     return {}
Ejemplo n.º 2
0
 def __init__(self, request):
     super(PersonBase, self).__init__(request)
     self.user = User.find_by_name(self.request.db, self.uid)
Ejemplo n.º 3
0
 def post(self):
     user = User.create(name=self.request.params['name'],
                        mood=self.request.params.get('mood', 0))
     return user.to_dict()
Ejemplo n.º 4
0
 def get(self):
     users = [u.to_dict() for u in User.all(self.request.db)]
     return {"users": users}
Ejemplo n.º 5
0
 def delete(self):
     self.log.info("User {} checked out from {}", self.uid, self.venue)
     user = User.find_by_name(self.request.db, self.uid)
     user.checkout(self.venue)
     return user.to_dict()
Ejemplo n.º 6
0
 def post(self):
     self.log.info("User {} checked in into {}", self.uid, self.venue)
     user = User.find_by_name(self.request.db, self.uid)
     user.checkin(self.venue)
     return user.to_dict()
Ejemplo n.º 7
0
 def get(self):
     return User.find(self.request.db, self.uid).to_dict()
Ejemplo n.º 8
0
                        type=int, default=100)
    args = parser.parse_args()
    return args

def parse_ini(ini):
    config = ConfigParser.ConfigParser()
    config.read(ini)

    return {k.replace("redis.", ""): v for k,v in config.items("app:main",
                                                               raw=True) if
            k.startswith("redis.")}


if __name__ == '__main__':
    args = parse_args()
    conf = parse_ini(args.ini)
    db = StrictRedis(**conf)
    venue = Venue.find(db, args.venue)

    print "Creating users: ",
    for i in xrange(args.number):
        username = "******".format(i)
        mood = random.randrange(0, 9, 1)
    #    user = User.create(db, name=username, mood=mood)
    #    user.checkin(venue)
        print ".",

    print " Done."
    user = User.create(db, name="fede", mood=1)
    user.checkin(venue)