我使用plone.api
创建一个脚本,将一批PDF上传到一个文件夹中,关于我将把每个PDF放在哪个文件夹的信息来自csv。我的问题是。。你知道吗
如果for
中的下一个值是同一年,那么在for
的最后一个变量yearBrain
中创建的变量的输出又是空的。当脚本完成后,在plone中我会有很多文件夹,标题是2015
,ID是2015
,2015-1
。。。你知道吗
for i in csv:
yearBrain = api.content.find(context=container, SearchableText=str(i[1]))
if solidData(yearBrain):
#solidData returns if exist infor and year have 4 digits
print 'if true, insert a PDF into a folder'
else:
#If solidData false, yearBrain results empty, so create a folder
container = api.content.create(type='Folder', title=unicode(str(i[1]), 'utf-8'), container=container)
transaction.commit()
我想api.content.find
找不到最近创建的文件夹。你知道吗
我是怎么解决这个问题的?你知道吗
[更新-工作]
if pdf_tipodoc:
if pdf_tipodoc == 'PROCESSO':
valor = splitProcesso(pdf_nprocesso)
# valor returns a list with two elements like ['234', '2016']
container = portal[plone_site_pasta][processos]
# Container is: <ATFolder at /intranet/ged/processos>
print container.objectIds() #look what have inside!
if valor[1] in container.objectIds():
print 'Folder already created! Commit PDF inside'
else:
container = api.content.create(type='Folder', title=valor[1], container=container)
transaction.commit()
不要使用api.content.find文件为此:您不需要在文件夹中搜索具有know id的项。你知道吗
如果
i[1]
在某种程度上是你当前的一年(我猜),就试试这样的方法:相关问题 更多 >
编程相关推荐