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


Python Entry.all方法代码示例

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


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

示例1: get

# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import all [as 别名]
  def get(self):
    self.response.headers['Content-Type'] = 'text/html'
    older_than = int(self.request.get("older_than",
                     datetime.datetime.now().date().toordinal() + 1))
    older_than = datetime.date.fromordinal(older_than)

    body = ""

    oldest = datetime.datetime.now().date().toordinal() + 1

    for e in Entry.all().filter("date <", older_than).order('-date').run(
          limit=20):
      body += e.render()
      oldest = e.date.toordinal()

    nav = """
<div class='row'>
  <div class='span4 offset4'>
    <a href='/?older_than=%d'>Newer</a> -- <a href='/?older_than=%d'>Older</a>
  </div>
</div>""" % (oldest + 41, oldest)

    body = nav + body + nav
    self.response.out.write(indexTemplate.render({
      'title': 'Home',
      'body': body
    }))
开发者ID:Mononofu,项目名称:infinite-diary,代码行数:29,代码来源:diary.py

示例2: detail

# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import all [as 别名]
def detail(slug):
    query = Entry.all()
    entry = get_object_or_404(query, Entry.slug == slug)
    tags = ""
    for tag in entry.tags:
        tags = tags + " " + tag.tag
    return render_template("detail.html", entry=entry, tags=tags)
开发者ID:keybits,项目名称:permanote,代码行数:9,代码来源:views.py

示例3: get

# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import all [as 别名]
 def get(self):
   enforce_key(self)
   entries = [e.to_dict() for e in Entry.all().order('-date')]
   self.response.headers['Content-Type'] = "application/json"
   self.response.headers['Content-Disposition'] = (
       "attachment; filename=entries.json")
   self.response.out.write(json.dumps(entries))
开发者ID:Mononofu,项目名称:infinite-diary,代码行数:9,代码来源:backup.py

示例4: post

# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import all [as 别名]
  def post(self):
    enforce_key(self)

    rawEntries = self.request.get("entries")
    entries = json.loads(rawEntries)

    for e in Entry.all():
      e.delete()

    for e in entries:
      newEntry = Entry()
      newEntry.from_json(e)
      newEntry.put()

    rawTodos = self.request.get("todos")
    todos = json.loads(rawTodos)

    for t in ToDo.all():
      t.delete()

    for t in todos:
      newToDo = ToDo()
      newToDo.from_json(t)
      newToDo.put()

    self.response.out.write("Backup successfuly restored.")
开发者ID:Mononofu,项目名称:infinite-diary,代码行数:28,代码来源:backup.py

示例5: index

# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import all [as 别名]
def index(handler):
    context = {}
    if handler.session.get("account", False):
        context["drafts"] = Entry.all().filter("author =", db.Key(handler.session["account"]))
    else:
        pass
    return context
开发者ID:michael-gillette,项目名称:GaeMVC,代码行数:9,代码来源:writer.py

示例6: get

# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import all [as 别名]
  def get(self):
    today = datetime.date.today()

    q = Entry.all().filter("date >", today - datetime.timedelta(days=1))
    msg = ""

    if q.count() <= 0:
      q = Entry.all().filter("date =", today - datetime.timedelta(days=30))
      old_entry = ""
      if q.count() > 0:
        old_entry = "\tEntry from 30 days ago\n%s\n\n" % q[0].content

      q = Entry.all().filter("date =", today - datetime.timedelta(days=180))
      if q.count() > 0:
        old_entry += "\tEntry from 180 days ago\n%s\n\n" % q[0].content

      mail.send_mail(sender="%s <%s>" % (DIARY_NAME, DIARY_EMAIL),
                     to="%s <%s>" % (RECIPIENT_NAME, RECIPIENT_EMAIL),
                     subject="Entry reminder for %s" % today.strftime("%b %d"),
                     body="""Don't forget to update your diary!

Remember to include short snippets of important things you did today,
as well as a list of things you are grateful for.

Just respond to this message with todays entry.

%s
-----
diaryentry%dtag
""" % (old_entry, int(time.time())))
      msg = "Reminder sent"
    else:
      msg = "I already have an entry for today"

    self.response.out.write(indexTemplate.render({
        'title': 'Ideas',
        'body': msg,
        'active_page': 'reminder'
    }))
开发者ID:Mononofu,项目名称:infinite-diary,代码行数:41,代码来源:mail.py

示例7: entry_index

# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import all [as 别名]
def entry_index(request):
    _posts = Entry.all().filter('published =', True)
    _posts.order('-pub_date')
    _posts = list(_posts)

    try:
        latest = _posts[0]
    except IndexError:
        latest = None

    posts = len(_posts) > 1 and _posts[1:11] or []

    return locals()
开发者ID:BrianPainter,项目名称:geraldo,代码行数:15,代码来源:views.py

示例8: get

# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import all [as 别名]
  def get(self, ordinal):
    out = ""
    month = date.fromordinal(int(ordinal))
    for e in Entry.all().filter("date >=", month).filter("date <", next_month(month)):
      out += """%s
<form action='/highlights/month/%s' method='POST'>
  <input type='hidden' name='key' value='%s'>
  <input type='submit' value='Pick'>
</form><br><br>""" % (e.render(), ordinal, e.key())

    self.response.out.write(indexTemplate.render({
      'title': 'Highlights - Monthly',
      'body': out,
      'active_page': 'highlights'
    }))
开发者ID:Mononofu,项目名称:infinite-diary,代码行数:17,代码来源:highlight.py

示例9: get

# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import all [as 别名]
    def get(self, pageindex):
        logging.info(pageindex)
        pi = 1 if int(pageindex) < 1 else int(pageindex)
        offset = (pi - 1) * PAGESIZE
        logging.info(offset)

        q = Entry.all();
        q.order('-insertTime')

        total = q.count()
        its = q.fetch(PAGESIZE, offset)

        self.render_template('index.html', { 
            'title': 'Entry List', 'items': its, 'total': total, 
            'pageindex': pi, 'pagesize': PAGESIZE })
开发者ID:tonychi,项目名称:readLater,代码行数:17,代码来源:main.py

示例10: tag_index

# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import all [as 别名]
def tag_index(request, tag):
    posts = Entry.all().filter('published =', True).filter('tags =',tag)
    posts.order('-pub_date')
    posts = [i for i in posts]

    if not posts:
        raise Http404

    latest = posts[0]

    try:
        posts = posts[1:]
    except ValueError:
        posts = []

    return locals()
开发者ID:BrianPainter,项目名称:geraldo,代码行数:18,代码来源:views.py

示例11: year_index

# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import all [as 别名]
def year_index(request, year):
    start_date = datetime.datetime(int(year),1,1)
    end_date = datetime.datetime(int(year),12,31)

    posts = Entry.all().filter('published =', True)#.filter('pub_date >=',start_date).filter('pub_date <=',end_date)
    posts.order('-pub_date')
    posts = [i for i in posts]

    if not posts:
        raise Http404

    latest = posts[0]

    try:
        posts = posts[1:]
    except ValueError:
        posts = []

    return locals()
开发者ID:BrianPainter,项目名称:geraldo,代码行数:21,代码来源:views.py

示例12: index

# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import all [as 别名]
def index(request):
    q_feed = Feed.all()
    feed_list = q_feed.fetch(q_feed.count())
    q_entry = Entry.all()
    entry_list = q_entry.fetch(q_entry.count())

    # Create as dict tree
    dict_tree = {}
    for e in entry_list:
        dict_tree.setdefault(e.pub_date(), {}).setdefault(e.feed, []).append(e)
    days = dict_tree.keys()
    days.sort()
    days.reverse()

    # Recreate as list tree
    recent_list = []
    for day in days:
        blog_list = [dict_tree[day][k] for k in dict_tree[day]]
        blog_list.sort(pub_dttm_desc)
        recent_list.append(blog_list)

    return render_to_response("planet/index.html", {"feed_list": feed_list, "recent_list": recent_list})
开发者ID:nakagami,项目名称:planetgae,代码行数:24,代码来源:views.py

示例13: feeds_tag

# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import all [as 别名]
def feeds_tag(request, tag):
    lang = "pt-br"

    feed = feedgenerator.Rss201rev2Feed(
            title = u'Django Utilidades :: Marinho Brandao',
            link = settings.PROJECT_ROOT_URL,
            description = u'',
            language = lang,
            )

    entries = Entry.all().filter('published =',True).filter('show_in_rss =',True).filter('tags =',tag)
    entries.order('-pub_date')
    entries = entries[:20]

    for e in entries:
        feed.add_item(
                title=e.title,
                link=settings.PROJECT_ROOT_URL[:-1]+e.get_absolute_url(),
                description=e.get_text(),
                )

    response = HttpResponse(mimetype="application/xhtml+xml")
    feed.write(response, 'utf-8')
    return response
开发者ID:BrianPainter,项目名称:geraldo,代码行数:26,代码来源:views.py

示例14: admin_index

# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import all [as 别名]
def admin_index(request):
    list = Entry.all()
    list.order('-pub_date')

    return locals()
开发者ID:BrianPainter,项目名称:geraldo,代码行数:7,代码来源:views.py

示例15: admin_entry_export_all

# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import all [as 别名]
def admin_entry_export_all(request):
    items = Entry.all().order('title')
    #ret = render_to_string('gae_blog/export_all.txt', locals())
    ret = serialize(items)
    return HttpResponse(ret, mimetype='text/xml')
开发者ID:BrianPainter,项目名称:geraldo,代码行数:7,代码来源:views.py


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