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


Python Entry.create方法代码示例

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


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

示例1: new_view

# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import create [as 别名]
def new_view(parent_id=None):
    user = Session.get_user()

    if parent_id and Entry.select().where(Entry.id == parent_id, Entry.is_active == True).exists():
        parent = Entry.get(Entry.id == parent_id, Entry.is_active == True)
    else:
        parent = None

    title = views.form_get('title', 'no title')
    body = views.form_get('body', '')

    Entry.create(
        user=user,
        parent=parent,
        title=title,
        body=body,
    )

    return redirect(URLS['index'])
开发者ID:kmasaya,项目名称:bottle.peewee.template,代码行数:21,代码来源:index.py

示例2: create

# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import create [as 别名]
def create():
    if request.method == "POST":
        if request.form.get("title") and request.form.get("content"):
            try:
                entry = Entry.create(
                    title=request.form["title"],
                    content=request.form["content"],
                    archived=request.form.get("archived") or False,
                )
                tags = request.form["tags"].split()
                # present is a check to see if the tag exists
                present = 0
                # add or create tags
                for tag in tags:
                    for entrytag in entry.tags:
                        if tag == entrytag.tag:
                            present = 1
                    if present == 0:
                        try:
                            thistag = Tag.get(Tag.tag == tag)
                            entry.tags.add(thistag)
                        except:
                            tag_obj, was_created = Tag.create_or_get(tag=tag)
                            EntryTags.create(tag=tag_obj, entry=entry)
                    present = 0
                flash("Entry created successfully.", "success")
                return redirect(url_for("detail", slug=entry.slug))
            except:
                flash("Note title already exists", "danger")
                return render_template("create.html")
        # TODO Refactor the below and above to make it more DRY or not
        # to need to display seconds (e.g. add some kind of suffix if entry
        # already exists)
        elif request.form.get("content"):
            entry = Entry.create(
                title="{:%a %d %b %Y at %H:%M:%S}".format(datetime.datetime.now()), content=request.form["content"]
            )
            flash("Note created successfully.", "success")
            return redirect(url_for("detail", slug=entry.slug))
        else:
            flash("Content is required.", "danger")
    return render_template("create.html")
开发者ID:keybits,项目名称:permanote,代码行数:44,代码来源:views.py

示例3: post

# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import create [as 别名]
 def post(self):
   page = self.get_int_param("page")
   location = self.get_int_param("location")
   book_key_name = self.request.get("book")
   if page or location:
     try:
       entry = Entry.create(book     = Book.get_by_key_name(book_key_name),
                            reader   = users.get_current_user(),
                            page     = page,
                            location = location)
       Progress.create(entry)
     except ValueError, error:
       self.set_cookie("flash_message", error)
开发者ID:mrchucho,项目名称:infinite-summer,代码行数:15,代码来源:main.py

示例4: post

# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import create [as 别名]
 def post(self, request, *args, **kwargs):
     form = TextForm(request.POST)
     if form.is_valid():
         cd = form.cleaned_data
         title = cd.get('title')
         text = cd.get('text')
         cover = cd.get('cover', '')
         entry = Entry.create(title, text, cover)
         return HttpResponseRedirect(
             reverse('detail', kwargs={'_id': str(entry.id)}))
     return render_to_response('create.html', {
         'form': form,
     }, RequestContext(request))
开发者ID:davechenww,项目名称:ermiao-wysiwyg,代码行数:15,代码来源:views.py

示例5: create

# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import create [as 别名]
def create():
  if request.method == 'POST':
    if request.form.get('title') and request.form.get('content'):
      entry = Entry.create(
        title=request.form['title'],
        content=request.form['content'],
        published=request.form.get('published') or False)
      flash('Entry created successfully.', 'success')
      if entry.published:
        return redirect(url_for('detail', slug=entry.slug))
      else:
        return redirect(url_for('edit', slug=entry.slug))
    else:
      flash('Title and Content are required.', 'danger')
  return render_template('create.html')
开发者ID:ephiepark,项目名称:mysite,代码行数:17,代码来源:app.py

示例6: create_entry

# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import create [as 别名]
def create_entry(blog, title, content, pub_date=None):
    return Entry.create(blog=blog, title=title, content=content,
                        pub_date=pub_date or datetime.datetime.now())
开发者ID:DYFeng,项目名称:peewee,代码行数:5,代码来源:bench.py


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