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


Python Entry.get方法代码示例

本文整理汇总了Python中model.Entry.get方法的典型用法代码示例。如果您正苦于以下问题:Python Entry.get方法的具体用法?Python Entry.get怎么用?Python Entry.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在model.Entry的用法示例。


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

示例1: test_get

# 需要导入模块: from model import Entry [as 别名]
# 或者: from model.Entry import get [as 别名]
 def test_get(self):
     context = Context(http=MockHttp(HTTP_SRC_DIR), entry="http://example.org/entry/67")
     entry = Entry(context)
     (headers, body) = entry.get()
     self.assertEqual(200, headers.status)
     self.assertFalse(entry.has_media())
     self.assertEqual(entry.uri(), "http://example.org/entry/67")
开发者ID:myblup,项目名称:atompubbase,代码行数:9,代码来源:test_entry.py

示例2: delete

# 需要导入模块: from model import Entry [as 别名]
# 或者: from model.Entry import get [as 别名]
    def delete(self, id):
        e = Entry.get(Entry.id == id)
        if not e:
            self.write({'status':'error'})
            return

        e.delete_instance()
        self.write({'status':'success'})
开发者ID:zqqf16,项目名称:clipboard,代码行数:10,代码来源:handler.py

示例3: test_put_media

# 需要导入模块: from model import Entry [as 别名]
# 或者: from model.Entry import get [as 别名]
 def test_put_media(self):
     context = Context(http=MockHttp(HTTP_SRC_DIR), entry="http://example.org/images/77")
     entry = Entry(context)
     (headers, body) = entry.get()
     self.assertEqual(200, headers.status)
     self.assertTrue(entry.has_media())
     (headers, body) = entry.put_media(headers={}, body="")
     self.assertEqual(202, headers.status)  # We don't really expect 202 from a PUT, just testing.
开发者ID:myblup,项目名称:atompubbase,代码行数:10,代码来源:test_entry.py

示例4: test_get_media

# 需要导入模块: from model import Entry [as 别名]
# 或者: from model.Entry import get [as 别名]
 def test_get_media(self):
     context = Context(http=MockHttp(HTTP_SRC_DIR), entry="http://example.org/images/77")
     entry = Entry(context)
     (headers, body) = entry.get()
     self.assertEqual(200, headers.status)
     self.assertTrue(entry.has_media())
     (headers, body) = entry.get_media()
     self.assertEqual(200, headers.status)
     self.assertTrue(headers["content-type"], "image/jpg")
     self.assertEqual(7483, len(body))
开发者ID:myblup,项目名称:atompubbase,代码行数:12,代码来源:test_entry.py

示例5: get

# 需要导入模块: from model import Entry [as 别名]
# 或者: from model.Entry import get [as 别名]
 def get(self, id):
     e = Entry.get(Entry.id == id)
     self.write(e.to_dict())
开发者ID:zqqf16,项目名称:clipboard,代码行数:5,代码来源:handler.py

示例6: get

# 需要导入模块: from model import Entry [as 别名]
# 或者: from model.Entry import get [as 别名]
	def get(self,page):
		code=OptionSet.getValue("Akismet_code",default="")
		up=OptionSet.getValue("Akismet_Comments_v0.3",default=[])
		if type(up)!=type([]):
			up=[]
		delkey = page.param('delkey')
		rekey = page.param('rekey')
		if rekey or delkey:
			newup = []
			for i in up:
				cmtkey = i['key'][0];
				enykey = i['key'][1];
				if delkey and cmtkey==delkey:
					cm = Comment.get(cmtkey)
					db.Model.delete(cm)
				elif rekey and cmtkey==rekey:
					cm = Comment.get(cmtkey)
					eny = Entry.get(enykey)
					eny.commentcount+=1
					eny.put()
					cm.entry = eny
					db.Model.put(cm)
					self.SubmitAkismet({
						'user_agent':i['other']['user_agent'],
						'referrer':i['other']['referrer'],
						'user_ip' : cm.ip,
						'comment_type' : 'comment', 
						'comment_author' : cm.author.encode('utf-8'),
						'comment_author_email' : cm.email,
						'comment_author_url' : cm.weburl,
						'comment_content' : cm.content.encode('utf-8')
					},i['other'].get('url',''),"Ham")
				else:
					newup.append(i)
			if not len(up)==len(newup):
				OptionSet.setValue("Akismet_Comments_v0.3",newup)
			up = newup
		cmts = [(Comment.get(i['key'][0]),Entry.get(i['key'][1])) for i in up]
		comments = [u'<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td><a target="_blank" href="/%s">%s</a></td><td><a href="?delkey=%s" title="删除">删除</a> <a href="?rekey=%s" title="这不是一个垃圾评论">还原</a></td></tr>'%(i[0].date,
			i[0].author,i[0].content,i[0].email,i[0].ip,i[1].link,i[1].title,str(i[0].key()),str(i[0].key())) for i in cmts]
		comments = ''.join(comments)
		apikey = OptionSet.getValue("Akismet_code",default=self.AKISMET_default_Key)
		if len(apikey)<5:
			apikey = self.AKISMET_default_Key
		api =  AkismetManager(apikey,Blog.all()[0].baseurl)
		if not code:
			status = ''
		elif api.IsValidKey():
			status = 'True'
		else:
			status = 'False'
		return u'''<h3>Akismet</h3>
					<form action="" method="post">
					<p>Akismet Api Key:</p>
					<input name="code" style="width:400px;" value="%s"> %s
					<br />
					<p>删除一条评论并提交Spam(输入评论的ID):</p>
					<input name="spam" style="width:400px;" value="">
					<br />
					<input type="submit" value="submit">
					</form>
				  <div>
				  	<br />
				  	<h3>被过滤的评论</h3> <table class="widefat"><thead><tr><th>日期</th><th>作者</th><th>内容</th><th>电子邮件</th><th>IP地址</th><th>文章/页面</th><th style="width:15%%;">选择操作</th></tr></thead><tbody>%s </tbody></table>
				  </div>'''%(code,status,comments)
开发者ID:chaoskey,项目名称:micolog-modify,代码行数:67,代码来源:akismet.py

示例7: update_entry

# 需要导入模块: from model import Entry [as 别名]
# 或者: from model.Entry import get [as 别名]
def update_entry(id, changed):
    e = Entry.get(id=id)
    for attr, value in changed.items():
        if attr in ['is_read', 'is_liked', 'is_disliked']:  # writable attr
            setattr(e, attr, value)
    e.save()
开发者ID:lanius,项目名称:uguis,代码行数:8,代码来源:operation.py

示例8: get

# 需要导入模块: from model import Entry [as 别名]
# 或者: from model.Entry import get [as 别名]
    def get(self, page):
        code = OptionSet.getValue("Akismet_code", default="")
        up = OptionSet.getValue("Akismet_Comments_v0.3", default=[])
        rm = OptionSet.getValue("Akismet_AutoRemove", False)
        if type(up) != type([]):
            up = []
        delkey = page.param("delkey")
        rekey = page.param("rekey")
        if rekey or delkey:
            newup = []
            for i in up:
                cmtkey = i["key"][0]
                enykey = i["key"][1]
                if delkey and cmtkey == delkey:
                    cm = Comment.get(cmtkey)
                    db.Model.delete(cm)
                elif rekey and cmtkey == rekey:
                    cm = Comment.get(cmtkey)
                    eny = Entry.get(enykey)
                    eny.commentcount += 1
                    eny.put()
                    cm.entry = eny
                    db.Model.put(cm)
                    self.SubmitAkismet(
                        {
                            "user_agent": i["other"]["user_agent"],
                            "referrer": i["other"]["referrer"],
                            "user_ip": cm.ip,
                            "comment_type": "comment",
                            "comment_author": cm.author.encode("utf-8"),
                            "comment_author_email": cm.email,
                            "comment_author_url": cm.weburl,
                            "comment_content": cm.content.encode("utf-8"),
                        },
                        i["other"].get("url", ""),
                        "Ham",
                    )
                else:
                    newup.append(i)
            if not len(up) == len(newup):
                OptionSet.setValue("Akismet_Comments_v0.3", newup)
            up = newup
        cmts = [(Comment.get(i["key"][0]), Entry.get(i["key"][1])) for i in up]
        comments = [
            u'<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td><a target="_blank" href="/%s">%s</a></td><td><a href="?delkey=%s" title="删除">删除</a> <a href="?rekey=%s" title="这不是一个垃圾评论">还原</a></td></tr>'
            % (
                i[0].date,
                i[0].author,
                i[0].content,
                i[0].email,
                i[0].ip,
                i[1].link,
                i[1].title,
                str(i[0].key()),
                str(i[0].key()),
            )
            for i in cmts
            if i is not None and i[0] is not None
        ]
        comments = "".join(comments)
        apikey = OptionSet.getValue("Akismet_code", default=self.AKISMET_default_Key)
        if len(apikey) < 5:
            apikey = self.AKISMET_default_Key
        api = AkismetManager(apikey, Blog.all()[0].baseurl)
        if not code:
            status = ""
        elif api.IsValidKey():
            status = "True"
        else:
            status = "False"
        if rm == True:
            rmchecked = 'checked="checked"'
        else:
            rmchecked = ""
        return u"""<h3>Akismet</h3>
					<form action="" method="post">
					<p>Akismet Api Key:</p>
					<input name="code" style="width:400px;" value="%s"> %s
					<br />
					<p>自动删除检测到的垃圾评论:
					<input type="checkbox" name="autorm" value="1" %s></p>
					<p>删除一条正常的评论并提交Spam(输入评论的ID):</p>
					<input name="spam" style="width:400px;" value="">
					<br />
					<input type="submit" value="submit">
					</form>
				  <div>
				  	<br />
				  	<h3>被过滤的评论</h3> <table class="widefat"><thead><tr><th>日期</th><th>作者</th><th>内容</th><th>电子邮件</th><th>IP地址</th><th>文章/页面</th><th style="width:15%%;">选择操作</th></tr></thead><tbody>%s </tbody></table>
				  </div>""" % (
            code,
            status,
            rmchecked,
            comments,
        )
开发者ID:wb253,项目名称:goapp,代码行数:97,代码来源:akismet.py


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