This repository has been archived by the owner on Dec 25, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 482
/
queue.py
60 lines (49 loc) · 1.52 KB
/
queue.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env python
# coding=utf-8
import os
import re
import time
import datetime
import hashlib
import string
import random
from google.appengine.ext import webapp
from google.appengine.api import memcache
from google.appengine.ext import db
from google.appengine.ext.webapp import util
from google.appengine.ext.webapp import template
from v2ex.babel import Member
from v2ex.babel import Counter
from v2ex.babel import Section
from v2ex.babel import Node
from v2ex.babel import Topic
from v2ex.babel import Reply
from v2ex.babel import Note
from v2ex.babel import SYSTEM_VERSION
from v2ex.babel.security import *
from v2ex.babel.ua import *
from v2ex.babel.da import *
from v2ex.babel.l10n import *
class AddStarTopicHandler(webapp.RequestHandler):
def post(self, topic_key):
topic = db.get(db.Key(topic_key))
if topic:
topic.stars = topic.stars + 1
topic.put()
memcache.set('Topic_' + str(topic.num), topic, 86400)
class MinusStarTopicHandler(webapp.RequestHandler):
def post(self, topic_key):
topic = db.get(db.Key(topic_key))
if topic:
topic.stars = topic.stars - 1
topic.put()
memcache.set('Topic_' + str(topic.num), topic, 86400)
def main():
application = webapp.WSGIApplication([
('/add/star/topic/(.*)', AddStarTopicHandler),
('/minus/star/topic/(.*)', MinusStarTopicHandler)
],
debug=True)
util.run_wsgi_app(application)
if __name__ == '__main__':
main()