本文整理汇总了Python中model.zsite.Zsite类的典型用法代码示例。如果您正苦于以下问题:Python Zsite类的具体用法?Python Zsite怎么用?Python Zsite使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Zsite类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
def get(self, n=1):
zsite_id = self.zsite_id
cid = self.cid
page_template = self.page_template
total = fav_po_count_by_user_id_cid(zsite_id, cid)
n = int(n)
page, limit, offset = page_limit_offset(
page_template,
total,
n,
PAGE_LIMIT
)
if n != 1 and offset >= total:
return self.redirect(page_template[:-3])
li = fav_po_list_by_user_id_cid(zsite_id, cid, limit, offset)
if cid == CID_WORD:
rid_po_list = [i for i in li if i.rid]
Po.mc_bind(rid_po_list, 'question', 'rid')
Zsite.mc_bind([i.target for i in rid_po_list], 'user', 'user_id')
self.render(
cid=cid,
total=total,
li=li,
page=page,
back_a='/fav',
)
示例2: get
def get(self, cid, state, n=1):
path_base = self.request.path.split("-", 1)[0]
total = pic_reviewed_count_by_cid_state(cid, state)
page, limit, offset = page_limit_offset("%s-%%s" % path_base, total, n, PAGE_LIMIT)
if type(n) == str and offset >= total:
return self.redirect(path_base)
pic_list = pic_list_reviewed_by_cid_state(cid, state, limit, offset)
Zsite.mc_bind(pic_list, "user", "user_id")
self.render(cid=int(cid), state=int(state), pic_list=pic_list, total=total, page=page)
示例3: get
def get(self, n=1):
zsite_id = self.zsite_id
user_id = self.current_user_id
zsite = self.zsite
zsite_cid = zsite.cid
if zsite_cid == CID_SITE:
self.template = '/ctrl/zsite/po_view/site_po_page.htm'
else:
self.template = '/ctrl/zsite/po_view/po_page.htm'
cid = self.cid
page_template = self.page_template
n = int(n)
if zsite_cid == CID_SITE:
total = po_cid_count_by_zsite_id(zsite_id, cid)
else:
is_self = zsite_id == user_id
total = po_list_count(zsite_id, cid, is_self)
page, limit, offset = page_limit_offset(
page_template,
total,
n,
PAGE_LIMIT
)
if n != 1 and offset >= total:
return self.redirect(page_template[:-3])
if zsite_cid == CID_SITE:
po_list = feed_po_list_by_zsite_id(user_id, zsite_id, cid, limit, offset)
back_a = None
total = 0
else:
po_list = po_view_list(zsite_id, cid, is_self, limit, offset)
if cid == CID_WORD:
rid_po_list = [i for i in po_list if i.rid]
Po.mc_bind(rid_po_list, 'question', 'rid')
Zsite.mc_bind([i.target for i in rid_po_list], 'user', 'user_id')
if is_self:
back_a = '/feed'
else:
back_a = '/'
self.render(
cid=cid,
total=total,
li=po_list,
page=page,
back_a=back_a,
)
示例4: get
def get(self, id):
t = Trade.get(id)
from_user = Zsite.mc_get(t.from_id)
to_user = Zsite.mc_get(t.to_id)
self.render(
from_user=from_user,
to_user=to_user,
trade=t,
)
示例5: get
def get(self, n=1):
count = product_count()
page, limit, offset = page_limit_offset(
'/product-%s',
count,
n,
PAGE_LIMIT,
)
li = product_list(limit, offset)
Zsite.mc_bind(li, 'zsite', 'zsite_id')
self.render(
li=li,
page=str(page)
)
示例6: get
def get(self, n=1):
total = Zsite.where().count()
page, limit, offset = page_limit_offset(
href='/user_list-%s',
total=total,
n=n,
limit=PAGE_LIMIT
)
user_list = Zsite.where(cid=CID_USER).order_by('id desc')[offset:offset+limit]
self.render(
user_list=user_list,
page=page,
)
示例7: get
def get(self, cid=0, n=1):
if cid:
cid = int(cid)
if cid not in CID_ZSITE_TUPLE:
return self.redirect('/following')
zsite_id = self.zsite_id
if cid:
id_list = follow_id_list_by_from_id_cid(zsite_id, cid)
else:
id_list = follow_id_list_by_from_id(zsite_id)
total = len(id_list)
page, limit, offset = page_limit_offset(
'/following%s-%%s' % (cid or ''),
total,
n,
PAGE_LIMIT
)
if type(n) == str and offset >= total:
return self.redirect('/following%s' % (cid or ''))
id_list = id_list[offset: offset + limit]
following = Zsite.mc_get_list(id_list)
self.render(
zsite_list=following,
page=page,
title='关注',
path='/following%s'%(cid or '')
)
示例8: get
def get(self, mail):
if mail.isdigit():
user_id = mail
user = Zsite.mc_get(user_id)
if user:
mail = mail_by_user_id(user_id)
link = mail2link(mail)
if user:
return self.render(mail=mail, link=link)
elif EMAIL_VALID.match(mail):
user_id = user_id_by_mail(mail)
if user_id:
user = Zsite.mc_get(user_id)
verify_mail_new(user_id, user.name, mail, self.cid)
return self.redirect('/auth/password/reset/%s'%user_id)
self.redirect('/login')
示例9: main
def main():
id2alias = {}
for zhihu_topic in ZHIHU_TOPIC:
id = zhihu_topic[0]
alias_list = zhihu_topic[5]
id2alias[int(id)] = alias_list
name2id = {}
for i in Zsite.where(cid=CID_TAG):
tag_list = map(str.strip, i.name.split("/"))
zhihu_id = MY2ID[i.id]
alias_list = id2alias.get(zhihu_id,())
tag_list.extend(alias_list)
for name in tag_list:
name2id[name.lower()] = i.id
print """
#coding:utf-8
NAME2ID = """,
pprint(name2id)
示例10: post
def post(self):
arguments = parse_qs(self.request.body, True)
link = ''
name = ''
auto = 1
user_list_exist = []
for txt, id in zip(arguments.get('txt'), arguments.get('id')):
user_id = int(id)
for url in txt.splitlines():
url = url.strip()
if url:
rss = rss_new(user_id, url, name, link, 0, auto)
user_list_exist.append(user_id)
if user_list_exist:
self.render(
'/god/rss/rss_add.htm',
user_list_exist=Zsite.mc_get_list(user_list_exist),
user_list_not_exist=[],
success = True
)
else:
self.rediect("/rss/add")
示例11: _tag_feed_next
def _tag_feed_next(tag_id, offset):
feed_id = id_by_tag_admin(tag_id, offset)
#feed_id = 1
if feed_id:
feed = FeedImport.get(feed_id)
author_rm = is_rt_by_title(feed.title)
tag_id_list = filter(bool, feed.tag_id_list.split(' '))
tag_id_list = list(
zip(
[ i.name for i in Zsite.mc_get_list(tag_id_list) if i is not None],
tag_id_list
)
)
r = {
'id':feed.id,
'title':feed.title,
'txt':feed.txt,
'tag_id_list':tag_id_list,
'author_rm':author_rm,
'url':feed.url
}
else:
r = '0'
return r
示例12: init_channel
def init_channel():
for id, name in CHANNEL:
o = Zsite.get_or_create(id=id)
o.cid = CID_CHANNEL
o.name = name
o.state = ZSITE_STATE_ACTIVE
o.save()
示例13: get
def get(self, id):
current_user_id = self.current_user_id
zsite = Zsite.mc_get(id)
if zsite:
follow_new(current_user_id, id)
mq_buzz_follow_new(current_user_id, id)
示例14: _login
def _login(self, user_id, mail, redirect=None):
session = user_session(user_id)
self.set_cookie('S', session)
self.set_cookie('E', mail)
if not redirect:
current_user = Zsite.mc_get(user_id)
redirect = LOGIN_REDIRECT%current_user.link
self.redirect(redirect)
示例15: buzz_follow_mail
def buzz_follow_mail():
prev_pos = kv_int.get(KV_BUZZ_FOLLOW_POS)
c = Buzz.raw_sql(
'select max(id) from buzz where create_time<%s', int(time()) - ONE_DAY
)
pos = c.fetchone()[0]
if pos > prev_pos:
d = defaultdict(OrderedDict)
for i in Buzz.where(cid=CID_BUZZ_FOLLOW).where('to_id=rid').where(
'id>%s and id<=%s', prev_pos, pos
):
id = i.id
d[i.to_id][i.from_id] = i.id
dd = defaultdict(OrderedSet)
for to_id, _d in d.iteritems():
if mail_notice_state(to_id, CID_BUZZ_FOLLOW):
min_id = buzz_pos.get(to_id)
for from_id, id in _d.iteritems():
if id > min_id:
dd[to_id].add(from_id)
for to_id, li in dd.iteritems():
mail = mail_by_user_id(to_id)
name = Zsite.mc_get(to_id).name
for from_id in li:
from_user = Zsite.mc_get(from_id)
career = from_user.career
if from_user.state >= ZSITE_STATE_VERIFY and any(career):
rendermail(
'/mail/buzz/follow_new.htm', mail, name,
from_user=from_user,
format='html',
subject='%s ( %s ) 关注 你' % (
from_user.name,
' , '.join(career),
)
)
#sleep(0.1)
kv_int.set(KV_BUZZ_FOLLOW_POS, pos)