def get(self, topic_key): topic = Topic.get(topic_key) if topic: topic.stars = topic.stars - 1 topic.sync() store.commit() #jon add memcache.set('Topic_' + str(topic.num), topic, 86400)
def get(self, topic_key): topic = Topic.get(topic_key) if topic: topic.stars = topic.stars - 1 topic.sync() store.commit() #jon add memcache.set('Topic_' + str(topic.num), topic, 86400)
def get(self, topic_key): topic = Topic.get(topic_key) combined = topic.title + " " + topic.content ms = re.findall('(@[a-zA-Z0-9\_]+\.?)\s?', combined) unique = [] for m in ms: if m.lower() not in unique: unique.append(m.lower()) keys = [] if (len(unique) > 0): for m in unique: m_id = re.findall('@([a-zA-Z0-9\_]+\.?)', m) if (len(m_id) > 0): if (m_id[0].endswith('.') != True): member_username = m_id[0] member = GetMemberByUsername(member_username) if member: if member.id != topic.member.id and member.id not in keys: #q = db.GqlQuery('SELECT * FROM Counter WHERE name = :1', 'notification.max') q = Counter.selectBy(name='notification.max') if (q.count() == 1): counter = q[0] counter.value = counter.value + 1 else: counter = Counter() counter.name = 'notification.max' counter.value = 1 #q2 = db.GqlQuery('SELECT * FROM Counter WHERE name = :1', 'notification.total') q2 = Counter.selectBy( name='notification.total') if (q2.count() == 1): counter2 = q2[0] counter2.value = counter2.value + 1 else: counter2 = Counter() counter2.name = 'notification.total' counter2.value = 1 notification = Notification(member=member) notification.num = counter.value notification.type = 'mention_topic' notification.payload = topic.content notification.label1 = topic.title notification.link1 = '/t/' + str( topic.num) + '#reply' + str(topic.replies) notification.member = topic.member notification.for_member_num = member.num keys.append(str(member.id)) counter.sync() counter2.sync() notification.sync() store.commit() #jon add for k in keys: taskqueue.add(url='/notifications/check/' + k)
def get(self, topic_key): topic = Topic.get(topic_key) combined = topic.title + " " + topic.content ms = re.findall('(@[a-zA-Z0-9\_]+\.?)\s?', combined) unique = [] for m in ms: if m.lower() not in unique: unique.append(m.lower()) keys = [] if (len(unique) > 0): for m in unique: m_id = re.findall('@([a-zA-Z0-9\_]+\.?)', m) if (len(m_id) > 0): if (m_id[0].endswith('.') != True): member_username = m_id[0] member = GetMemberByUsername(member_username) if member: if member.id != topic.member.id and member.id not in keys: #q = db.GqlQuery('SELECT * FROM Counter WHERE name = :1', 'notification.max') q = Counter.selectBy(name='notification.max') if (q.count() == 1): counter = q[0] counter.value = counter.value + 1 else: counter = Counter() counter.name = 'notification.max' counter.value = 1 #q2 = db.GqlQuery('SELECT * FROM Counter WHERE name = :1', 'notification.total') q2 = Counter.selectBy(name='notification.total') if (q2.count() == 1): counter2 = q2[0] counter2.value = counter2.value + 1 else: counter2 = Counter() counter2.name = 'notification.total' counter2.value = 1 notification = Notification(member=member) notification.num = counter.value notification.type = 'mention_topic' notification.payload = topic.content notification.label1 = topic.title notification.link1 = '/t/' + str(topic.num) + '#reply' + str(topic.replies) notification.member = topic.member notification.for_member_num = member.num keys.append(str(member.id)) counter.sync() counter2.sync() notification.sync() store.commit() #jon add for k in keys: taskqueue.add(url='/notifications/check/' + k)