本文整理汇总了Python中model.Entry类的典型用法代码示例。如果您正苦于以下问题:Python Entry类的具体用法?Python Entry怎么用?Python Entry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Entry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get
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")
示例2: saveEntry
def saveEntry(self):
"""
Updates an entry
"""
contents = self.entry.get(1.0, tkinter.END)
Entry.updateEntry(self.currDate, contents)
self.updateStatusBar("Last action: " + str(self.currDate) + " - Entry updated")
示例3: test_put
def test_put(self):
context = Context(http=MockHttp(HTTP_SRC_DIR), entry="http://example.org/entry/67")
entry = Entry(context)
(headers, body) = entry.put(body="<entry></entry>")
self.assertEqual(200, headers.status)
self.assertFalse(entry.has_media())
self.assertEqual(0, len(body))
示例4: get
def get(self, page_id="", operation=""):
t_values = {}
logging.info("PageManager get: page_id = %s, operation = %s" % (page_id, operation))
# find current_post based on page_id
if page_id:
current_post = Entry.get_by_id(long(page_id))
if current_post:
logging.info("find post %s from post id %s" % (page_id, current_post.title))
if operation == "edit":
t_values['current_post'] = current_post
elif operation == "publish":
current_post.is_external_page = True
current_post.put()
t_values['alert_message'] = "Post %s has been changed to public" % (current_post.title)
elif operation == "unpublish":
current_post.is_external_page = False
current_post.put()
t_values['alert_message'] = "Post %s has been changed to private" % (current_post.title)
elif operation == "delete":
current_post.delete()
t_values['alert_message'] = "Post %s has been changed to deleted" % (current_post.title)
# show all posts
posts = Entry.all().filter("entrytype =", 'page')
t_values['posts'] = posts
return self.response.out.write(render_template("pages.html", t_values, "", True))
示例5: get
def get(self, page_slug=""):
if page_slug:
t_values = {}
posts = Entry.all().filter("is_external_page =", True).filter("entrytype =", 'page').filter("slug =", page_slug)
if posts.count() == 1:
logging.warning("find one page with slug=%s" % (page_slug))
posts = posts.fetch(limit=1)
post = posts[0]
t_values['post'] = post
# dump(post)
# find all comments
comments = Comment.all().filter("entry =", post).order("date")
t_values['comments'] = comments
else:
logging.warning("%d entries share the same slug %s" % (posts.count(), page_slug))
links = Link.all().order("date")
t_values['links'] = links
categories = Category.all()
t_values['categories'] = categories
pages = Entry.all().filter("is_external_page =", True).filter("entrytype =", 'page').order("date")
t_values['pages'] = pages
return self.response.out.write(render_template("page.html", t_values, "basic", False))
else:
self.redirect(uri_for("weblog.index"))
示例6: deleteEntry
def deleteEntry(self):
"""
Deletes an entry
"""
Entry.deleteEntry(self.currDate)
self.entry.delete(1.0, tkinter.END)
self.updateStatusBar("Last action: " + str(self.currDate) + " - Entry deleted")
示例7: test_put_media
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.
示例8: test_get_media
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))
示例9: post
def post(self):
target = self.request.get('target')
amount = int(self.request.get('amount'))
location = self.request.get('location')
date = datetime.datetime.strptime(self.request.get('date'), '%Y-%m-%d').date()
succeed = True#self.request.get('succeed')
story = self.request.get('story')
entry = Entry(target=target, amount=amount, location=location, date=date, succeed=succeed, story=story, author=users.get_current_user())
entry.put()
self.redirect('/')
示例10: get
def get(self):
task = self.request.get("task")
if task == "cleanup":
# Remove obsolete entries
Entry.cleanup()
elif task == "subscribe":
# Periodically make subscribe request
#
# Priorily subscribe to newly added channel (i.e. status == None);
# if there aren't any, then confirm the least checked subscription.
ch = Channel.all().filter("status =", None).get()
if not ch:
ch = Channel.all().filter("status =",
"subscribed").order("lastcheck").get()
ch.subscribe()
else: self.error(404)
示例11: post
def post(self, user_id, feed_id, entry_id):
"""Updates a specific entry"""
current_user = utils.get_current_user()
if not current_user:
self.error(403)
return
user = User.get_by_id(int(user_id))
if user == None:
self.error(404)
return
if current_user.key() != user.key():
self.error(401)
return
feed = InputFeed.get_by_id(int(feed_id), parent=user)
if feed == None:
self.error(404)
return
entry = Entry.get_by_id(int(entry_id), parent=feed)
published = self.request.get('published')
if published != None:
entry.published = bool(int(published))
entry.save()
self.response.headers['Content-Type'] = 'application/json; charset=utf-8'
self.response.headers['Access-Control-Allow-Origin'] = '*'
self.response.out.write(json.dumps(entry.to_struct()))
示例12: get
def get(self):
context = {}
query = Entry.all().order("-updated")
next = self.request.get("next")
if next:
dt = datetime.strptime(next, "%Y-%m-%dT%H:%M:%S")
entries = query.filter("updated <=",
dt).fetch(PAGESIZE + 1)
if len(entries) == PAGESIZE + 1:
context["next"] = entries[-1].updated.isoformat("T")
else:
context["next"] = None
context["entries"] = entries[:PAGESIZE]
self.response.out.write(self.render_sec_entries(context))
return
else:
sec = {}
entries = query.fetch(PAGESIZE + 1)
if len(entries) == PAGESIZE + 1:
context["next"] = entries[-1].updated.isoformat("T")
else:
context["next"] = None
context["entries"] = entries[:PAGESIZE]
sec["entries"] = self.render_sec_entries(context)
sec["featured"] = self.render_sec_featured()
path = templatepath("main.html")
self.response.out.write(template.render(path, sec))
示例13: delete
def delete(self, title):
"""Delete the specified tag for the current user"""
user = utils.get_current_user()
title = title.decode('utf-8')
if not user:
self.error(403)
return
m = Tag.all().ancestor(user).filter('title_lower =', title.lower()).get()
if not m:
# Original tag not found
self.error(404)
return
entries = Entry.all().filter('tags =', m.key())
# Remove tag from entries
for entry in entries:
logging.info(entry)
entry.tags.remove(m.key())
entry.save()
m.delete()
self.response.headers['Content-Type'] = 'text/plain; charset=utf-8'
self.response.headers['Access-Control-Allow-Origin'] = '*'
self.response.out.write('ok')
示例14: EntryHandler_postTest
def EntryHandler_postTest(self):
weight = 75.0
variance = 1.4
currDate = "2012-10-10"
currDt =dt.date(2012, 10, 10)
nick= users.get_current_user().nickname()
head = {"Content-Type" : "application/x-www-form-urlencoded", "Accept" : "text/plain"}
payload = urlencode({"date" : currDate, "variance" : float(variance),"weight":float(weight)})
#request = requests.Request("POST","/users/%s/"%nick, data=payload)
request = webapp2.Request.blank('/users/%s/entry/%s'%(nick,currDate))
request.method="POST"
request.headers=head
request.body=payload
currUser=users.get_current_user()
response = webapp2.Response()
handler = EntryHandler()
handler.initialize(request, response)
handler.post(user=None,cd=None)
self.setCurrentUser("[email protected]", "aaaaaaa")
userId=users.get_current_user().user_id()
db.delete(Entry.all())
nick=users.get_current_user().nickname()
handler.post(user=nick,cd='2012-10-10')
Entry(weight=100.0, variance=5.0,date=currDt,user=currUser, parent=log_key(userId)).put()
handler.post(user=nick,cd='2012-10-10')
db.delete(Biometric.all())
Biometric(height=150, target=73.3, parent=bio_key(currUser.user_id())).put()
handler.post(user=nick,cd='2012-10-10')
#Put Test
handler.put(user=nick,cd='2012-10-10')
handler.put(user=nick,cd='2012-10-15')
handler.delete(user=nick,cd='2012-10-10')
示例15: get
def get(self, **kwargs):
"""Return current status
"""
e = Entry.latest()
if e:
return e.as_dict()
return {}