本文整理汇总了Python中model.Node.get_newest方法的典型用法代码示例。如果您正苦于以下问题:Python Node.get_newest方法的具体用法?Python Node.get_newest怎么用?Python Node.get_newest使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.Node
的用法示例。
在下文中一共展示了Node.get_newest方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from model import Node [as 别名]
# 或者: from model.Node import get_newest [as 别名]
def get(self):
if USER_MODEL==2:
self.redirect('/sigin')
return
open_id = str(self.get_cookie('open_id',''))
access_token = str(self.get_cookie('access_token',''))
if open_id and access_token:
access_token_in_kvdb = kv.get('qq_' +str(open_id))
if access_token_in_kvdb == access_token:
pass
else:
self.redirect('/sigin')
return
else:
self.redirect('/sigin')
return
self.echo('setname.html', {
'title': "设置名字",
'errors':[],
'name':'',
'newest_node': Node.get_newest(),
}, layout='_layout.html')
示例2: get
# 需要导入模块: from model import Node [as 别名]
# 或者: from model.Node import get_newest [as 别名]
def get(self, nodeid):
n_obj = Node.get_by_id(int(nodeid))
if not n_obj:
self.error(404)
self.echo('error.html', {
'page': '404',
'title': "Can't find out this URL",
'h2': 'Oh, my god!',
'msg': 'Something seems to be lost...'
})
return
from_id = int(self.request.get('id', '0'))
if from_id<=0 and n_obj.count:
from_id = n_obj.count
to_id = from_id - EACH_PAGE_POST_NUM
if to_id<0:
to_id = 0
newest_node = Node.get_newest()
self.echo('nodedetail.html', {
'title': n_obj.name,
'n_obj': n_obj,
'from_id': from_id,
'to_id': to_id,
'topic_objs': Node.get_page_topic(nodeid, from_id, to_id),
'newest_node': newest_node,
'recent_node': Node.get_recent_node(),
'hot_node': Node.get_hot_node(),
'recent_topic_objs': KeyStrValue.get_topic_key_title('recent-topic-home'),
'reply_topic_objs': KeyStrValue.get_topic_key_title('recent-reply-topic'),
}, layout='_layout.html')
if len(newest_node)==10:
KeyStrValue.add_node_key(nodeid)
示例3: post
# 需要导入模块: from model import Node [as 别名]
# 或者: from model.Node import get_newest [as 别名]
def post(self):
name = str(self.get_argument('name','').lower().encode('utf-8'))
pw = self.get_argument('pw','')
errors = []
if name and pw:
if len(name)<20 or len(pw)<20:
if re.search('^[a-zA-Z0-9]+$', name):
pwmd5 = md5(pw.encode('utf-8')).hexdigest()
u_obj = kv.get('m-' + name)
if u_obj:
member_dict = decode_dict(u_obj)
if pwmd5 == member_dict['code'] and int(member_dict['flag']) >= 1:
#set sr_code
code_list = [member_dict['code']]
u_topic_time = kv.get('u_topic_time:'+name)
if u_topic_time:
code_list.append(u_topic_time)
u_comment_time = kv.get('u_comment_time:'+name)
if u_comment_time:
code_list.append(u_comment_time)
#login
self.set_cookie('username', name, path="/", expires_days = 365 )
self.set_cookie('usercode', md5(''.join(code_list)).hexdigest(), path="/", expires_days = 365 )
self.set_cookie('userflag', member_dict['flag'], path="/", expires_days = 365 )
if member_dict['flag'] == '1':
self.redirect('/setavatar')
else:
self.redirect('/')
return
else:
errors.append('用户名或密码不对或已被禁用')
else:
errors.append('用户名或密码不对')
else:
errors.append('用户名只能包含字母和数字')
else:
errors.append('用户名或密码太长了')
else:
errors.append('用户名和密码必填')
self.echo('login.html', {
'title': "登录",
'errors':errors,
'name':name,
'newest_node': Node.get_newest(),
}, layout='_layout.html')
示例4: post
# 需要导入模块: from model import Node [as 别名]
# 或者: from model.Node import get_newest [as 别名]
def post(self):
req_user = self.request.user
gu_obj = GoogleUser.get_or_insert(req_user.user_id())
if gu_obj.name:
self.redirect('/')
return
errors = []
name = self.POST['name'].strip().lower()
if name:
if len(name)<20:
if re.search('^[a-zA-Z0-9]+$', name):
check_obj = Member.get_by_key_name(str(name))
if check_obj:
errors.append('该用户名已被注册,请换一个吧')
else:
#get member id
mid_obj = Counter.get_or_insert('member_auto_increment',name = 'member_auto_increment', value = 1)
nuser_obj = Member(key_name=name, id = mid_obj.value, flag = 1, add = int(time()))
nuser_obj.put()
if nuser_obj.is_saved():
#set google user
gu_obj.name = name
db.run_in_transaction(obj_runput,gu_obj)
#all member num +1
mid_obj.value += 1
db.run_in_transaction(obj_runput,mid_obj)
self.redirect('/setavatar')
return
else:
errors.append('服务器出现意外错误,请稍后再试')
else:
errors.append('用户名只能包含字母和数字')
else:
errors.append('用户名太长了')
else:
errors.append('用户名必填')
self.echo('setname.html', {
'title': "设置名字",
'errors':errors,
'name':name,
'newest_node': Node.get_newest(),
}, layout='_layout.html')