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


Python Entry.objects方法代码示例

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


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

示例1: entry_list

# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import objects [as 别名]
def entry_list(request, **kwargs):
    entries = Entry.objects(status = Entry.STATUS_PUBLIC)
    # TODO: Paginate the Entry-list

    return direct_to_template(request, 'mongoblog/entry_list.html', {
        'entry_list': entries,
    })
开发者ID:xintron,项目名称:django-mongoblog,代码行数:9,代码来源:views.py

示例2: entry_detail

# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import objects [as 别名]
def entry_detail(request, slug):
    entry = Entry.objects(slug=slug).first()
    if not entry:
        raise Http404

    return direct_to_template(request, 'mongoblog/entry_detail.html', {
        'entry': entry,
    })
开发者ID:xintron,项目名称:django-mongoblog,代码行数:10,代码来源:views.py

示例3: update_entry

# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import objects [as 别名]
def update_entry(entry_id=None):
	'''Update an existing entry at /update/entry_id/ or make a new one at /update/.
	Returns the entry_id of the new or updated entry.'''
	entry = Entry()
	if entry_id != None:
		entry = Entry.objects(id=entry_id)[0]
	revision = Revision(content=request.form['content'], rows=request.form['rows'])
	entry.add_revision(revision)
	entry.save()
	return str(entry.id)
开发者ID:BenjaminMalley,项目名称:Notably,代码行数:12,代码来源:app.py

示例4: create

# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import objects [as 别名]
def create():
    if request.method == 'POST':
        if request.form.get('title') and request.form.get('content'):
            user=session['user']
            entry = Entry(
                title=request.form['title'],
                content=request.form['content'],
                published=True,
                #published=request.form.get('published') or False, #for later implementation of drafts
                authors=[user['username']])
            entry.save()
            Entry.objects(id=entry.id).update_one(slug=unicode(entry.id))
            entry.reload() #made to avoid duplicate slugs and to generate an url
            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:clement91190,项目名称:cdj_website,代码行数:23,代码来源:urls.py

示例5: system_stats

# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import objects [as 别名]
def system_stats():
    ''' calculates and prints info about the system
    usage:
        $ . /path/to/venv/bin/activate
        (venv)$ python
        >> import application
        >> application.controllers.system_stats()
        there are 1234 entries in the system
    '''
    # initialize the mongoengine connection
    mongo_config = app.config['MONGO_CONFIG']
    mongodb_uri = 'mongodb://'
    if mongo_config['dbuser'] and mongo_config['dbpassword']:
        mongodb_uri += '%s:%[email protected]' % (mongo_config['dbuser']
                , mongo_config['dbpassword'])
    mongodb_uri += '%s/%s' % (mongo_config['hosts'], mongo_config['db_name'])
    connect(mongo_config['db_name'], host=mongodb_uri)

    projects = Project.objects()
    total_entries = 0
    total_points = 0
    for project in projects:
        schema = project.ordered_schema
        entries = Entry.objects(project=project)

        # count the points
        for entry in entries:
            # drop non-uniques or hidden
            if not entry.unique or not entry.visible:
                continue
            
            total_entries += 1

            # count datapoints
            for header in schema:
                if header.name in entry.values:
                    if entry['values'][header.name] != None:
                        total_points += 1

    print 'there are %s entries in the system' % total_entries
    print 'there are %s datapoints in the system' % total_points
开发者ID:aquaya,项目名称:pipeline,代码行数:43,代码来源:system_stats.py


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