當前位置: 首頁>>代碼示例>>Python>>正文


Python MCatalog.delete方法代碼示例

本文整理匯總了Python中torcms.model.mcatalog.MCatalog.delete方法的典型用法代碼示例。如果您正苦於以下問題:Python MCatalog.delete方法的具體用法?Python MCatalog.delete怎麽用?Python MCatalog.delete使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在torcms.model.mcatalog.MCatalog的用法示例。


在下文中一共展示了MCatalog.delete方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: MaintainCategoryHandler

# 需要導入模塊: from torcms.model.mcatalog import MCatalog [as 別名]
# 或者: from torcms.model.mcatalog.MCatalog import delete [as 別名]
class MaintainCategoryHandler(BaseHandler):
    def initialize(self):
        self.init()
        self.mclass = MCatalog()
        self.tmpl_router = 'maintain_category'


    def get(self, url_str=''):
        url_arr = self.parse_url(url_str)

        if url_str == 'add':
            self.to_add()
        elif url_str == 'list':
            self.list_catalog()
        elif url_arr[0] == 'modify':
            self.to_modify(url_arr[1])

        elif url_arr[0] == 'delete':

            self.delete_by_uid(url_arr[1])

        else:
            kwd = {
                'info': '頁麵未找到',
            }
            self.render('html/404.html', kwd=kwd, userinfo = self.userinfo,)

    def post(self, url_str=''):

        url_arr = self.parse_url(url_str)

        if url_arr[0] == 'modify':
            self.update(url_arr[1])
        elif url_str == 'add':
            self.add_catalog()
        elif url_arr[0] == 'add':

            self.p_add_catalog()
        else:
            self.redirect('html/404.html')

    def list_catalog(self):
        kwd = {
            'pager': '',
            'unescape': tornado.escape.xhtml_unescape,
            'title': '最近文檔',
        }
        self.render('{0}/{1}/category_list.html'.format(self.tmpl_name, self.tmpl_router),
                    kwd=kwd,
                    view=self.mclass.query_all(by_order=True),
                    format_date=tools.format_date,
                    userinfo=self.userinfo,
                    cfg=config.cfg
                    )

    @tornado.web.authenticated
    def to_add(self):
        kwd = {
            'pager': '',
            'uid': '',
        }
        self.render('{0}/{1}/category_add.html'.format(self.tmpl_name, self.tmpl_router),
                    topmenu='',
                    kwd=kwd,
                    userinfo=self.userinfo,
                    cfg=config.cfg
                    )

    @tornado.web.authenticated
    def update(self, uid):
        raw_data = self.mclass.get_by_id(uid)
        if self.userinfo.privilege[2] == '1' or raw_data.user_name == self.get_current_user():
            pass
        else:
            return False
        post_data = {}
        for key in self.request.arguments:
            post_data[key] = self.get_arguments(key)
        post_data['user_name'] = self.get_current_user()

        if self.tmpl_router == "maintain_category":
            self.mclass.update(uid, post_data)
            self.redirect('/maintain/category/list'.format(uid))
        else:
            if self.mclass.update(uid, post_data):

                output = {
                    'addinfo ': 1,
                }
            else:
                output = {
                    'addinfo ': 0,
                }
            return json.dump(output, self)

    @tornado.web.authenticated
    def to_modify(self, id_rec):
        a = self.mclass.get_by_id(id_rec)
        if self.userinfo.privilege[4] == '1':
            pass
#.........這裏部分代碼省略.........
開發者ID:Sijiu,項目名稱:TorCMS,代碼行數:103,代碼來源:maintain_handler.py


注:本文中的torcms.model.mcatalog.MCatalog.delete方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。