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


Python model.Entry類代碼示例

本文整理匯總了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")
開發者ID:myblup,項目名稱:atompubbase,代碼行數:7,代碼來源:test_entry.py

示例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")
開發者ID:hanleychan,項目名稱:diary,代碼行數:7,代碼來源:diary.py

示例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))
開發者ID:myblup,項目名稱:atompubbase,代碼行數:7,代碼來源:test_entry.py

示例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))
開發者ID:loongw,項目名稱:another-gae-blog,代碼行數:27,代碼來源:admin.py

示例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"))
開發者ID:loongw,項目名稱:another-gae-blog,代碼行數:30,代碼來源:weblog.py

示例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")
開發者ID:hanleychan,項目名稱:diary,代碼行數:7,代碼來源:diary.py

示例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.
開發者ID:myblup,項目名稱:atompubbase,代碼行數:8,代碼來源:test_entry.py

示例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))
開發者ID:myblup,項目名稱:atompubbase,代碼行數:10,代碼來源:test_entry.py

示例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('/')
開發者ID:yaozhifeng,項目名稱:i-bribe,代碼行數:12,代碼來源:main.py

示例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)
開發者ID:juvenn,項目名稱:microupdater,代碼行數:16,代碼來源:croned.py

示例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()))
開發者ID:studyindenmark,項目名稱:newscontrol,代碼行數:35,代碼來源:entries.py

示例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))
開發者ID:juvenn,項目名稱:microupdater,代碼行數:28,代碼來源:main.py

示例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')
開發者ID:studyindenmark,項目名稱:newscontrol,代碼行數:29,代碼來源:tags.py

示例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')
開發者ID:acantatore,項目名稱:Chompanion,代碼行數:32,代碼來源:SUT_Chompanion.py

示例15: get

 def get(self, **kwargs):
     """Return current status
     """
     e = Entry.latest()
     if e:
         return e.as_dict()
     return {}
開發者ID:quodt,項目名稱:etaui,代碼行數:7,代碼來源:service.py


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