• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python po.Po类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中model.po.Po的典型用法代码示例。如果您正苦于以下问题:Python Po类的具体用法?Python Po怎么用?Python Po使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Po类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: get

    def get(self, cid, n=1):
        cid = int(cid)
        qs = Reply.where('cid = %s', cid)
        total = qs.count()
        page, limit, offset = page_limit_offset(
            '/reply_list/%s-%%s'%cid,
            total,
            n,
            PAGE_LIMIT,
        )
        li = qs.order_by('id desc')[offset: offset + limit]
        txt_bind(li)
        #print cid == CID_USER
        if cid == CID_USER:
            Wall.mc_bind(li, 'wall', 'rid')
            wall_list = [i.wall for i in li]
            Zsite.mc_bind(wall_list, 'from_user', 'from_id')
            Zsite.mc_bind(wall_list, 'to_user', 'to_id')
        else:
            Po.mc_bind(li, 'po', 'rid')

        Zsite.mc_bind(li, 'user', 'user_id')
        self.render(
            reply_list=li,
            page=page,
        )
开发者ID:immissile,项目名称:42qu_github_mirror,代码行数:26,代码来源:reply.py


示例2: __init__

 def __init__(self, pid, event_list):
     self.pid = pid
     self.place = place_name(pid)
     self.province_id = pid_province(pid)
     event_list.sort(key=lambda x: x.begin_time)
     Po.mc_bind(event_list, 'po', 'id')
     self.event_list = event_list
开发者ID:immissile,项目名称:42qu_github_mirror,代码行数:7,代码来源:event_weekly.py


示例3: get

 def get(self, n=1):
     qs = Po.where("state>%s", STATE_RM).where("zsite_id=user_id")
     total = qs.count()
     page, limit, offset = page_limit_offset("/po/zsite-%s", total, n, PAGE_LIMIT)
     li = qs.order_by("id desc")[offset : offset + limit]
     Po.mc_bind(li, "question", "rid")
     self.render(po_list=li, page=page)
开发者ID:immissile,项目名称:42qu_github_mirror,代码行数:7,代码来源:po.py


示例4: 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',
        )
开发者ID:immissile,项目名称:42qu_github_mirror,代码行数:31,代码来源:fav.py


示例5: 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,
        )
开发者ID:immissile,项目名称:42qu_github_mirror,代码行数:57,代码来源:po_view.py


示例6: sync_recommend

def sync_recommend(id, po_id):
    from po import Po
    p = Po.mc_get(po_id)
    s = state_oauth_id_by_zsite_id_cid(id, SYNC_CID_SHARE)
    for oauth_id in s:
        rec_po = Po.mc_get(p.rid)
        if rec_po:
            txt = cnencut(p.name_, 20)
            if txt:
                txt = '%s -> '%txt
            else:
                txt = txt+"分享: "
            sync_by_oauth_id(oauth_id, txt + cnencut(rec_po.name_,50)  , 'http:%s'%rec_po.link)
开发者ID:,项目名称:,代码行数:13,代码来源:


示例7: spammer_reset

def spammer_reset(user_id):
    from model.po import Po, po_rm, reply_rm_if_can
    from zsite_tag import zsite_tag_rm_by_po
    for i in Po.where(user_id=user_id):
        po_rm(user_id, i.id)
        zsite_tag_rm_by_po(i)

    from model.reply import Reply
    for i in Reply.where(user_id=user_id):
        reply_rm_if_can(user_id, i.id)



    from model.wall import Wall
    from model.zsite import Zsite
    z = Zsite.mc_get(user_id)
    total = z.reply_count
    if total:
        reply_list = z.reply_list_reversed(total, 0)
        for reply in reply_list:
            wall = Wall.mc_get(reply.rid)
            if wall:
                wall.reply_rm(reply)


    spammer_new(user_id)
开发者ID:,项目名称:,代码行数:26,代码来源:


示例8: post

    def post(self, po_id=0):
        cid = CID_AUDIO
        name = self.get_argument("name", None)
        txt = self.get_argument("txt", None)

        link = "/feed"

        if po_id:
            po_id = int(po_id)
            po = Po.mc_get(po_id)
            if po and po.user_id == self.current_user_id:
                po.name_ = name
                po.txt_set(txt)
                po.save()
                link = "/po/tag/%s" % po_id
        else:
            audio = self._audio()
            if audio:
                user_id = self.current_user_id
                zsite_id = zsite_id_by_zsite_user_id(self.zsite, user_id)

                if zsite_id:
                    state = STATE_PO_ZSITE_SHOW_THEN_REVIEW
                else:
                    state = STATE_ACTIVE

                po = po_audio_new(user_id, name, txt, audio, state, zsite_id=zsite_id)

                if po:
                    po_id = po.id
                    link = "/po/tag/%s" % po_id

        return self.redirect(link)
开发者ID:immissile,项目名称:42qu_github_mirror,代码行数:33,代码来源:po_audio.py


示例9: get

 def get(self, id):
     po = Po.mc_get(id)
     if po:
         link = po.link
     else:
         link = '/'
     return self.redirect(link, True)
开发者ID:immissile,项目名称:42qu_github_mirror,代码行数:7,代码来源:index.py


示例10: get

    def get(self, id):
#        data = {
#            "zsite":{
#                "name":"w",
#                "unit":"xx",
#                "title":"zz"
#            },
#            "name":"2011年第2次BPUG活动",
#            "id":1234,
#            "fav":True,
#            "reply_count":1,
#            "tag_id":232,
#            "tag_name":"sss"
#        }
        po = Po.mc_get(id)
        user = po.user
        result = [id]
        result.extend(feed_tuple_by_db(id))
        result.pop()
        result.pop()
        result.append(po.htm)

        zsite = [user.name, user.link]
        zsite.extend(career_current(po.user_id))

        result.append(zsite)
        self.finish(dumps(result))
开发者ID:immissile,项目名称:42qu_github_mirror,代码行数:27,代码来源:po.py


示例11: post

    def post(self, po_id=0):
        cid = CID_PHOTO
        name = self.get_argument('name', None)
        txt = self.get_argument('txt', None)
        user_id = self.current_user_id


        link = '/feed'

        if po_id:
            po_id = int(po_id)
            po = Po.mc_get(po_id)
            if po and po.user_id == user_id:
                po.name_ = name
                po.txt_set(txt)
                po.save()
                link = '/po/tag/%s' % po_id
        else:
            img = self._img()
            if img:
                zsite_id = zsite_id_by_zsite_user_id(self.zsite, user_id)
                if zsite_id:
                    state = STATE_PO_ZSITE_SHOW_THEN_REVIEW
                else:
                    state = STATE_ACTIVE
                po = po_photo_new(user_id, name, txt, img, state, zsite_id)
                if po:
                    po_id = po.id

                    link = '/po/tag/%s' % po_id


        return self.redirect(link)
开发者ID:immissile,项目名称:42qu_github_mirror,代码行数:33,代码来源:po_photo.py


示例12: post

    def post(self, po_id=0):
        cid = CID_VIDEO
        url = self.get_argument('video', None)
        name = self.get_argument('name', None)
        txt = self.get_argument('txt', None)


        link = '/feed'

        if po_id:
            po_id = int(po_id)
            po = Po.mc_get(po_id)
            if po and po.user_id == self.current_user_id:
                po.name_ = name
                po.txt_set(txt)
                po.save()
                link = '/po/tag/%s' % po_id
        else:
            if url:
                video, video_site = video_filter(url)
                if video:
                    user_id = self.current_user_id
                    zsite_id = zsite_id_by_zsite_user_id(self.zsite, user_id)

                    if zsite_id:
                        state = STATE_PO_ZSITE_SHOW_THEN_REVIEW
                    else:
                        state = STATE_ACTIVE
                    po = po_video_new(user_id, name, txt, video, video_site, state, zsite_id)
                    if po:
                        po_id = po.id
                        link = '/po/tag/%s' % po_id


        return self.redirect(link)
开发者ID:immissile,项目名称:42qu_github_mirror,代码行数:35,代码来源:po_video.py


示例13: post

 def post(self, id):
     current_user_id = self.current_user_id
     rec_po = Po.mc_get(id)
     if rec_po and rec_po.cid == CID_REC and rec_po.user_id == current_user_id:
         name = self.get_argument('txt', '')
         rec_po.name_ = name
         rec_po.save()
     self.finish('{}')
开发者ID:immissile,项目名称:42qu_github_mirror,代码行数:8,代码来源:po.py


示例14: get

 def get(self, state, n=1):
     state = int(state)
     qs = Event.where(state=state)
     total = qs.count()
     page, limit, offset = page_limit_offset(
         '/event/%s-%%s' % state,
         total,
         n,
         PAGE_LIMIT,
     )
     li = qs.order_by('id desc')[offset: offset + limit]
     Po.mc_bind(li, 'po', 'id')
     self.render(
         stat=state,
         li=li,
         page=page,
     )
开发者ID:immissile,项目名称:42qu_github_mirror,代码行数:17,代码来源:event.py


示例15: _site_po_goto_direct

 def _site_po_goto_direct(sql):
     c = Po.raw_sql(
         sql,
         site_id,
         site_id,
         STATE_PO_ZSITE_SHOW_THEN_REVIEW,
     ).fetchone()
     return c[0] if c is not None else 0
开发者ID:,项目名称:,代码行数:8,代码来源:


示例16: po

 def po(self, id):
     po = Po.mc_get(id)
     if po:
         if po.cid in PO_SHARE_FAV_CID and po.can_view(self.current_user_id):
             if po.user_id == self.zsite_id or not po.user_id:
                 return po
         return self.redirect(po.link)
     return self.redirect('/')
开发者ID:immissile,项目名称:42qu_github_mirror,代码行数:8,代码来源:po_view.py


示例17: site_po_iter

def site_po_iter(id_list, limit=MAXINT, begin_id=MAXINT):
    id_list = list(merge_iter(id_list, limit, begin_id))
    po_list = Po.mc_get_list(id_list)

    zsite_set = set()

    for i in po_list:
        zsite_set.add(i.zsite_id)
        zsite_set.add(i.user_id)

    zsite_dict = Zsite.mc_get_dict(zsite_set)

    result = []
    pre_zsite_id = None
    m = []

    zsite_set = set()

    if po_list:
        last_id = po_list[-1].id
        for i in po_list:
            if pre_zsite_id != i.zsite_id:
                if pre_zsite_id:
                    result.append([pre_zsite_id, m])
                    zsite_set.add(zsite_dict[pre_zsite_id])
                    m = []
                pre_zsite_id = i.zsite_id

            cid = i.cid
            t = []
            t.append(i.id)
            t.append(cid)

            if cid == CID_WORD:
                t.append(i.htm)
            else:
                t.append(i.name)

            if i.zsite_id != i.user_id:
                user = zsite_dict[i.user_id]
                t.append(user.link)
                t.append(user.name)
            m.append(t)

        result.append([i.zsite_id, m])
        zsite_set.add(zsite_dict[i.zsite_id])
    else:
        last_id = 0

    ico_url_bind_with_default(zsite_set)

    for i in result:
        id = i[0]
        zsite = zsite_dict[id]
        i[0] = [id, zsite.name, zsite.link, zsite.ico]

    return result, last_id
开发者ID:,项目名称:,代码行数:57,代码来源:


示例18: post

 def post(self, id):
     po = Po.mc_get(id)
     name = self.get_argument('name', None)
     txt = self.get_argument('txt', None)
     if name:
         po.name_ = name
         po.save()
     if txt:
         po.txt_set(txt)
     self.redirect('/event')
开发者ID:immissile,项目名称:42qu_github_mirror,代码行数:10,代码来源:event.py


示例19: _sync_site_po

def _sync_site_po(begin_id):
    ss = SiteSync.where('id>%s', begin_id).order_by('id')[0]
    if ss:
        begin_id = ss.id
        zsite = Zsite.mc_get(ZSITE_BIND_FOR_SYNC)
        if zsite:
            po = Po.mc_get(ss.po_id)
            if po:
                sync_site_po(po, zsite)
        return begin_id
开发者ID:immissile,项目名称:42qu_github_mirror,代码行数:10,代码来源:oauth_site_sync.py


示例20: rank_update

def rank_update(po_id):
    up = vote_up_count(po_id)
    down = vote_down_count(po_id)
    po = Po.mc_get(po_id)
    _hot = hot(up, down, po.create_time)
    _confidence = confidence(up, down)
    for r in Rank.where(po_id=po_id):
        r.hot = _hot
        r.confidence = _confidence
        r.save()
        mc_flush_cid(r.to_id, r.cid)
开发者ID:,项目名称:,代码行数:11,代码来源:



注:本文中的model.po.Po类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python queues.Queue类代码示例发布时间:2022-05-27
下一篇:
Python models.Model类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap