Exemplo n.º 1
0
 def get(self):
     try:
         p_name = self.request.get('name')
         p_pin = self.request.get('pin')
         p_clcode = self.request.get('clcode')
         
         if is_empty(p_name) or is_empty(p_pin) or is_empty(p_clcode):
             projection.fail_result(self, 501, 'missing paramer')
             return
         
         m = Member.all().filter('name =', p_name)
         if m.count() == 0:
             member = Member(name=p_name, pin=p_pin, clcode=p_clcode, created = datetime.datetime.now().date())
             member.initilizeValue()
             key = member.put()
             projection.success_result(self, projection.member_to_dict(member, key), {'first_login':True})
         else:
             member = m.fetch(1)[0]
             if member.pin == p_pin:
                 # if changed clcode 
                 if member.clcode != p_clcode:
                     member.clcode = p_clcode
                     member.put()                        
                 projection.success_result(self, projection.member_to_dict(member, key = None), {'first_login':False})
             else:
                 projection.fail_result(self, 510, 'invalid pincode')
     except:
         projection.fail_result(self, 500, 'unknown error')                    
Exemplo n.º 2
0
 def get(self):
     q = Member.all()
     projection.success_result(self, projection.members_to_list(q), extra_value = None)