Beispiel #1
0
 def _load_favorites(self):
     """ Loads favorites of this user from the database into a set in memory """
     if hasattr(self, "_favorites") and self._favorites:
         # Already have the favorites in memory
         return
     self._favorites = set()
     i = iter(FavoriteModel.list_favorites(self.id()))
     self._favorites.update(i)
Beispiel #2
0
 def _load_favorites(self):
     """ Loads favorites of this user from the database into a set in memory """
     if hasattr(self, "_favorites") and self._favorites:
         # Already have the favorites in memory
         return
     self._favorites = set()
     i = iter(FavoriteModel.list_favorites(self.id()))
     self._favorites.update(i)
Beispiel #3
0
 def del_favorite(self, destuser_id):
     """ Delete an A-favors-B relation between this user and the destuser """
     self._load_favorites()
     self._favorites.discard(destuser_id)
     FavoriteModel.del_relation(self.id(), destuser_id)
Beispiel #4
0
 def add_favorite(self, destuser_id):
     """ Add an A-favors-B relation between this user and the destuser """
     self._load_favorites()
     self._favorites.add(destuser_id)
     FavoriteModel.add_relation(self.id(), destuser_id)
Beispiel #5
0
 def del_favorite(self, destuser_id):
     """ Delete an A-favors-B relation between this user and the destuser """
     self._load_favorites()
     self._favorites.discard(destuser_id)
     FavoriteModel.del_relation(self.id(), destuser_id)
Beispiel #6
0
 def add_favorite(self, destuser_id):
     """ Add an A-favors-B relation between this user and the destuser """
     self._load_favorites()
     self._favorites.add(destuser_id)
     FavoriteModel.add_relation(self.id(), destuser_id)