Quiet some of the logspam around instances
This commit is contained in:
2
api.py
2
api.py
@@ -134,7 +134,7 @@ def Unpin(google_user, client, instance_id, args):
|
||||
|
||||
try:
|
||||
models.Subject.FindOrCreate(subject).Unpin(
|
||||
client.parent_key(), sender_message_id, instance)
|
||||
client.parent_key(), sender_message_id, instance.key())
|
||||
except models.AccessDenied:
|
||||
logging.exception('Pin access denied')
|
||||
return {
|
||||
|
||||
13
channel.py
13
channel.py
@@ -28,6 +28,9 @@ class OnChannelConnect(webapp2.RequestHandler):
|
||||
def post(self):
|
||||
instance_id = self.request.get('from')
|
||||
instance = models.Instance.FromID(instance_id)
|
||||
if not instance:
|
||||
logging.error('Channel opened with invalid instance_id: %s', instance_id)
|
||||
return
|
||||
instance.active = True
|
||||
instance.put()
|
||||
|
||||
@@ -36,17 +39,19 @@ class OnChannelDisconnect(webapp2.RequestHandler):
|
||||
@utils.local_namespace
|
||||
def post(self):
|
||||
instance_id = self.request.get('from')
|
||||
instance = models.Instance.FromID(instance_id)
|
||||
instance_key = db.Key.from_path('Instance', instance_id)
|
||||
|
||||
subscriptions = models.Subscription.all().filter('instance =', instance)
|
||||
subscriptions = models.Subscription.all().filter('instance =', instance_key)
|
||||
for subscription in subscriptions:
|
||||
subscription.delete()
|
||||
|
||||
pins = models.Pin.all().filter('instance =', instance)
|
||||
pins = models.Pin.all().filter('instance =', instance_key)
|
||||
for pin in pins:
|
||||
pin.Delete()
|
||||
|
||||
instance.delete()
|
||||
instance = models.Instance.FromID(instance_id)
|
||||
if instance:
|
||||
instance.delete()
|
||||
|
||||
|
||||
app = webapp2.WSGIApplication([
|
||||
|
||||
@@ -253,17 +253,17 @@ class Subject(db.Model):
|
||||
subscription.SendMessage(event)
|
||||
|
||||
@db.transactional(xg=True)
|
||||
def RemovePin(self, sender, sender_message_id, instance):
|
||||
def RemovePin(self, sender, sender_message_id, instance_key):
|
||||
# Reload the subject and instance to establish a barrier
|
||||
subject = Subject.get(self.key())
|
||||
instance = Instance.get(instance.key())
|
||||
Instance.get(instance_key)
|
||||
|
||||
pins = (
|
||||
Pin.all()
|
||||
.ancestor(subject)
|
||||
.filter('sender =', sender)
|
||||
.filter('sender_message_id =', sender_message_id)
|
||||
.filter('instance =', instance))
|
||||
.filter('instance =', instance_key))
|
||||
|
||||
events = []
|
||||
for pin in pins:
|
||||
@@ -272,9 +272,9 @@ class Subject(db.Model):
|
||||
|
||||
return (events, list(Subscription.all().ancestor(subject)))
|
||||
|
||||
def Unpin(self, sender, sender_message_id, instance):
|
||||
def Unpin(self, sender, sender_message_id, instance_key):
|
||||
self.VerifyWritable(sender)
|
||||
events, subscriptions = self.RemovePin(sender, sender_message_id, instance)
|
||||
events, subscriptions = self.RemovePin(sender, sender_message_id, instance_key)
|
||||
for event in events:
|
||||
for subscription in subscriptions:
|
||||
subscription.SendMessage(event)
|
||||
@@ -378,4 +378,6 @@ class Pin(db.Model):
|
||||
}
|
||||
|
||||
def Delete(self):
|
||||
self.parent().Unpin(self.sender, self.sender_message_id, self.instance)
|
||||
self.parent().Unpin(
|
||||
self.sender, self.sender_message_id,
|
||||
Pin.instance.get_value_for_datastore(self))
|
||||
|
||||
Reference in New Issue
Block a user