This repository has been archived by the owner on Dec 26, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
blog.py
70 lines (58 loc) · 2.33 KB
/
blog.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
64
65
66
67
68
69
#!/usr/bin/env python
# coding=utf-8
import os
import base64
import re
import time
import datetime
import hashlib
import httplib
import string
import pickle
from v2ex.babel.memcached import mc as memcache
from jinja2 import Template, Environment, FileSystemLoader
from v2ex.babel import Member, MemberBookmark
from v2ex.babel import Avatar
from v2ex.babel import Counter
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
from v2ex.babel.ext.sessions import Session
from v2ex.babel import SYSTEM_VERSION
from v2ex.babel.handlers import BaseHandler
import config
class BlogHandler(BaseHandler):
def get(self, member_username):
one = GetMemberByUsername(member_username)
if one:
self.values['one'] = one
#topics = db.GqlQuery("SELECT * FROM Topic WHERE node_name = 'blog' AND member_num = :1 ORDER BY created DESC", one.num)
topics = Topic.selectBy(node_name='blog', member_num = one.num).orderBy('created')
self.values['topics'] = topics
#friends = db.GqlQuery("SELECT * FROM MemberBookmark WHERE member_num = :1", one.num)
friends = MemberBookmark.selectBy(member_num=one.num)
self.values['friends'] = friends
self.set_title(u'Blog')
self.finalize(template_name='blog')
else:
self.set_title(u'Member Not Found')
self.finalize(template_name='member_not_found')
class BlogEntryHandler(BaseHandler):
def get(self, topic_num):
topic = GetKindByNum('Topic', int(topic_num))
if topic:
if topic.node_name == 'blog':
self.values['one'] = topic.member
self.values['topic'] = topic
if topic.replies > 0:
#self.values['replies'] = db.GqlQuery("SELECT * FROM Reply WHERE topic_num = :1", topic.num)
self.values['replies'] = Reply.selectBy(topic_num=topic.num)
self.values['page_title'] = topic.title
self.finalize(template_name='blog_entry')
else:
self.redirect('/t/' + str(topic.num) + '#reply' + str(topic.replies))
else:
self.set_title(u'Topic Not Found')
self.finalize(template_name='topic_not_found')