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


Python Plugin.notes方法代碼示例

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


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

示例1: post

# 需要導入模塊: from model import Plugin [as 別名]
# 或者: from model.Plugin import notes [as 別名]
    def post(self):
        secret = self.request.get('secret', '')
        is_update = False
        if len(secret):
            plugins = Plugin.query(Plugin.secret == secret).fetch()
            if len(plugins) == 0:
                send_upload_form(self,
                                 "No plugin could be found that matches that "
                                 "secret.")
                return
            else:
                plugin = plugins[0]
            is_update = True
        else:
            plugin = Plugin()
        plugin.zip_url = 'http://' + os.environ['HTTP_HOST'] + '/serve/' + str(
            self.get_uploads('zip')[0].key())
        zip_data = urllib2.urlopen(plugin.zip_url).read()
        if not read_plugin_info(plugin, zip_data):
            send_upload_form(self,
                             "We couldn't find a valid info.json file in your "
                             "zip.")
            return

        console_key = self.request.get('console_key', None)

        plugin.secret = base64.b64encode(os.urandom(128))
        plugin.notes = self.request.get('notes', '')

        plugin.zip_md5 = hashlib.md5(zip_data).hexdigest()

        admin = users.is_current_user_admin() or \
            (console_key and console_key_is_valid(console_key))
        if admin:
            existing = Plugin.by_name(plugin.name)
            if existing:
                plugin.downloads += existing.downloads
                plugin.put()
                existing.disable()
                existing.downloads = 0
                existing.put()
        plugin.put()
        if admin:
            plugin.enable()

        if console_key is not None:
            self.response.write({"success": True})
        else:
            approval_msg = " It'll be public after it's been approved." if not is_update else ""
            message = "Your plugin was uploaded!" + approval_msg
            self.response.write(template("uploaded.html", {"message": message,
                                                           "plugin": plugin}))
開發者ID:xiangchenpublicgithub,項目名稱:Flashlight,代碼行數:54,代碼來源:main.py


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