예제 #1
0
 def put(self, lat, lng):
   logging.debug(self.request.body)
   kwargs = json.loads(self.request.body)
   if not kwargs.get('address'):
     kwargs['address'] = util.lookup_address(lat, lng)
   portal, created = models.Portal.get_or_insert(added_by=self.user, **kwargs)
   if created:
     # Add it to the cached JSON list of all portals.
     portals_json = memcache_chunker.get('portals')
     if portals_json is not None:
       portals = json.loads(portals_json)
       portals.append(portal)
       memcache_chunker.set('portals', json.dumps(
           portals, cls=PortalJSONEncoder))
   if kwargs.get('watched'):
     xmpp.send_invite(self.user.email)
     if self.user.key() not in portal.subscribers:
       portal.subscribers.append(self.user.key())
   else:
     try:
       portal.subscribers.remove(self.user.key())
     except ValueError:
       pass
   portal.put()
   memcache.delete('watched-portals|%s' % self.user.key())
예제 #2
0
 def put(self, lat, lng):
     logging.debug(self.request.body)
     kwargs = json.loads(self.request.body)
     if not kwargs.get('address'):
         kwargs['address'] = util.lookup_address(lat, lng)
     portal, created = models.Portal.get_or_insert(added_by=self.user,
                                                   **kwargs)
     if created:
         # Add it to the cached JSON list of all portals.
         portals_json = memcache_chunker.get('portals')
         if portals_json is not None:
             portals = json.loads(portals_json)
             portals.append(portal)
             memcache_chunker.set(
                 'portals', json.dumps(portals, cls=PortalJSONEncoder))
     if kwargs.get('watched'):
         xmpp.send_invite(self.user.email)
         if self.user.key() not in portal.subscribers:
             portal.subscribers.append(self.user.key())
     else:
         try:
             portal.subscribers.remove(self.user.key())
         except ValueError:
             pass
     portal.put()
     memcache.delete('watched-portals|%s' % self.user.key())
예제 #3
0
 def put(self, lat, lng):
   logging.debug(self.request.body)
   kwargs = json.loads(self.request.body)
   if not kwargs.get('address'):
     kwargs['address'] = util.lookup_address(lat, lng)
   portal, created = models.Portal.get_or_insert(added_by=self.user, **kwargs)
   if created:
     memcache.delete('portals')
   if kwargs.get('watched'):
     xmpp.send_invite(self.user.email)
     if self.user.key() not in portal.subscribers:
       portal.subscribers.append(self.user.key())
   else:
     try:
       portal.subscribers.remove(self.user.key())
     except ValueError:
       pass
   portal.put()
   memcache.delete('watched-portals|%s' % self.user.key())