当前位置: 首页>>代码示例>>Python>>正文


Python po.Po类代码示例

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


在下文中一共展示了Po类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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,代码来源:


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