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


Python Document.save方法代码示例

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


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

示例1: _postdoc

# 需要导入模块: from wiki.models import Document [as 别名]
# 或者: from wiki.models.Document import save [as 别名]
def _postdoc(request, is_image):
    docpath = u'{0}/{1}'.format(
            settings.MEDIA_ROOT,
            is_image and u'images' or u'documents'
    )

    if not os.path.exists(docpath):
        os.mkdir(docpath)

    f = request.FILES[u'file']

    fd = open(u'{0}/{1}'.format(docpath, f.name), u'wb+')
    for chunk in f.chunks():
        fd.write(chunk)
    fd.close()

    url = u'{0}/{1}/{2}'.format(
            settings.MEDIA_URL,
            is_image and u'images' or u'documents',
            f.name)

    try:
        doc = Document.objects.get(path=url)

    except Document.DoesNotExist:
        doc = Document()

        doc.is_image = is_image
        doc.path = url

        doc.wikipath = request.POST[u'page']
        doc.save()

    return HttpResponse(doc.path)
开发者ID:flegoff,项目名称:pompadour-wiki,代码行数:36,代码来源:views.py

示例2: document

# 需要导入模块: from wiki.models import Document [as 别名]
# 或者: from wiki.models.Document import save [as 别名]
def document(save=False, **kwargs):
    """Return an empty document with enough stuff filled out that it can be
    saved."""
    defaults = {'category': CATEGORIES[0][0], 'title': str(datetime.now())}
    defaults.update(kwargs)
    if 'slug' not in kwargs:
        defaults['slug'] = slugify(defaults['title'])
    d = Document(**defaults)
    if save:
        d.save()
    return d
开发者ID:azhar2005,项目名称:kuma,代码行数:13,代码来源:__init__.py

示例3: _create_document

# 需要导入模块: from wiki.models import Document [as 别名]
# 或者: from wiki.models.Document import save [as 别名]
def _create_document(title='Test Document'):
    d = Document(title=title, html='<div>Lorem Ipsum</div>',
                 category=1, locale='en-US')
    d.save()
    r = Revision(document=d, keywords='key1, key2', summary='lipsum',
                 content='<div>Lorem Ipsum</div>', creator_id=118577,
                 significance=SIGNIFICANCES[0][0])
    r.save()
    d.current_revision = r
    d.save()
    return d
开发者ID:chowse,项目名称:kitsune,代码行数:13,代码来源:test_templates.py

示例4: _create_document

# 需要导入模块: from wiki.models import Document [as 别名]
# 或者: from wiki.models.Document import save [as 别名]
def _create_document(title='Test Document'):
    d = Document(title=title, html='<div>Lorem Ipsum</div>',
                 category=1, locale='en-US')
    d.save()
    return d
开发者ID:sgarrity,项目名称:kitsune,代码行数:7,代码来源:test_templates.py


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