Пример #1
0
 def _storeFriends(self,friends,start=0,end=300,user_key=None):
     ''' Store friends as User objects
     '''
     users = []
     for friend in friends[start:end]:
         bFriends = [str(uid) for uid in friend.get('friends',user_key)] #user_key and [user_key,] or []
         fId = str(friend.get('id',friend.get('uid')))
         fName = friend.get('name')
         fFirstName = friend.get('first_name')
         fLastName = friend.get('last_name')
         fBirthday = friend.get('birthday_date')
         fSex = friend.get('sex')
         profile = {'id':fId,
                    'name':fName,
                    'first_name':fFirstName,
                    'last_name':fLastName,
                    'birthday':fBirthday,
                    'gender':fSex}
         user = FBUser.get_or_insert(key_name=str(fId),**profile)
         for k,v in profile.items():
             value = getattr(user,k)
             if v and not(v==value):
                 setattr(user,k,v)
         users.append(user)
     db.put(users)
     return users
Пример #2
0
 def updateUser(self,user,profile={}):
     ''' Let's update this user
     '''
     base_properties = ['first_name','last_name','name','link','about','birthday',
                        'email','website','bio','quotes','gender',
                        'relationship_status', 'religion','political','timezone']
     list_properties = ['interested_in','meeting_for']
     geo_properties = ['hometown','location']
     for prop in base_properties:
         value = profile.get(prop)
         if hasattr(user,prop) and value:
             setattr(user,prop,value)
         
     # Update Hometown and Location               
     for prop in geo_properties:
         value = profile.get(prop)
         if hasattr(user,prop) and value:
             location = self._location(value.get('id'),value.get('name'))
             setattr(user,prop,location)
     
     if 'significant_other' in profile:
         fName = profile.get('significant_other')['name']
         fId = profile.get('significant_other')['id']
         profile = {'id':fId,'name':fName}
         user = FBUser.get_or_insert(key_name=str(fId),**profile)
         user.significant_other = tmpUser