forked from livid/v2ex-gae
-
Notifications
You must be signed in to change notification settings - Fork 0
/
template.py
63 lines (53 loc) · 1.75 KB
/
template.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
61
62
63
#!/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 *
from v2ex.babel.ext.cookies import Cookies
template.register_template_library('v2ex.templatetags.filters')
class MyNodesHandler(webapp.RequestHandler):
def get(self):
member = CheckAuth(self)
if member:
site = GetSite()
l10n = GetMessages(self, member, site)
template_values = {}
template_values['site'] = site
template_values['member'] = member
template_values['l10n'] = l10n
template_values['page_title'] = site.title + u' › 我收藏的节点'
template_values['rnd'] = random.randrange(1, 100)
path = os.path.join(os.path.dirname(__file__), 'tpl', 'desktop', 'my_nodes.html')
output = template.render(path, template_values)
self.response.out.write(output)
else:
self.redirect('/')
def main():
application = webapp.WSGIApplication([
('/my/nodes', MyNodesHandler)
],
debug=True)
util.run_wsgi_app(application)
if __name__ == '__main__':
main()