本文整理汇总了Python中wiki.models.Document.path方法的典型用法代码示例。如果您正苦于以下问题:Python Document.path方法的具体用法?Python Document.path怎么用?Python Document.path使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wiki.models.Document
的用法示例。
在下文中一共展示了Document.path方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _postdoc
# 需要导入模块: from wiki.models import Document [as 别名]
# 或者: from wiki.models.Document import path [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)