使用 PloneFormGen 在 Plone 中以编程方式添加文件对象
我正在编写一个 PloneFormGen 自定义操作适配器,以便将文件对象从表单中的文件字段添加到文件夹中。脚本如下:
target = context.filefolder
form = request.form
uid = str(DateTime().millis())
target.invokeFactory("File", id=uid, file=form['arquivo-do-cv_file'])
obj = target[uid]
“filefolder”是 PFG FormFolder 的父文件夹内的文件夹名称。该脚本配置为以管理员代理角色运行。
问题是,当我查看以这种方式创建的文件对象时,它们不会显示“单击此处下载文件”链接。不过,如果我抑制 URL 末尾的“/view”部分,则可以下载这些文件。调用 invokeFactory 创建 File 对象时我缺少什么?
更新:我的意思是我没有得到“文件名 - 文件类型,以KB为单位的大小(大小以字节为单位)”文档链接,位于署名下方。当我使用普通的 Plone UI 创建 File 对象时,它确实会显示。
I'm writing a PloneFormGen custom action adapter in order to add a File object to a folder from the File Field in the form. Here is the script:
target = context.filefolder
form = request.form
uid = str(DateTime().millis())
target.invokeFactory("File", id=uid, file=form['arquivo-do-cv_file'])
obj = target[uid]
"filefolder" is the name of a folder inside the parent folder for the PFG FormFolder. This script is configured to run with a Manager proxy role.
Problem is that the File objects created this way won't show the "Click here to download the file" link when I view them. The files can be downloaded though, if I suppress the "/view" part from the end of the URL. What am I missing when calling invokeFactory to create the File object?
UPDATE: What I meant is that I don't get the "filename - filetype, size in KBs (size in bytes)" link for the document, below the byline. When I create a File object using the normal Plone UI, it does show up.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我什么也不怀疑;我认为这是 Plone 4 中的默认行为。
我刚刚添加了一个文件,但没有看到任何“单击此处下载文件”。
快速搜索不会显示字符串“单击此处下载”:
I suspect nothing; I think that is the default behavior in Plone 4.
I just added a File and I don't see any "Click here to download the file".
And a quick search does not reveal the string "click here to download":
我没有 Plone 实例来测试它,但尝试在
invokeFactory
之后调用processForm()
。它将:这些操作的详细信息请参见对象构造生命周期< /a>.也许需要其中一些操作来创建您想要的知识库信息(我希望它是索引)。
I don't have a Plone instance to test it, but try to call
processForm()
afterinvokeFactory
. It will:These actions are detailed on Object Construction Lifecycle. Maybe some of these actions are needed to create the KB information you're after (I'm hoping it's the index).