支持上传和引用内容的原型小部件。

archetypes.uploadreferencewidget的Python项目详细描述


上传参考小部件

The Upload Reference Widget aims to be the primary mechanism for uploading a file when creating a content item that uses the file. Instead of embedding the file into the content item, this widget uploads the file as a separate item and automatically populates a reference in the content item. Now Plone can reuse image and file assets in a more user-friendly way.

问题

One of the biggest issues we have seen re-using file assets in the Plone CMS is that once a file is uploaded as an attribute of content; you can not easily reuse it. Take this scenerio for instance:

  • You create a ‘News Item’ in ‘/news/foo.html’ and upload an image, ‘logo.jpg’, that shows a picture of a corporate logo. To address this image you must goto a URL like, ‘http://host/news/foo.html/logo.jpg’.
  • Two weeks later you create another ‘News Item’ in ‘/news/bar.html’ and you dont want to re-upload the corporate logo. You simply want to reuse the existing corporate logo. Where do you find it?
  • We could browse content and goto ‘/news/foo.html’ and inside the ‘News Item’ see the ‘logo.jpg’. While this is possible. It is not probable that someone has created a container where images are being uploaded. Specifically the default Plone ‘News Item’ implementation does not work this way.

建议的解决方案

Create a new ‘UploadReferenceWidget’. What this will do is be an alternative widget that can work in-place of a ReferenceWidget; and should retain all the functionality of a Reference Field/Widget. But enable someone to upload a ‘File’. The policy on the Field/Widget could dictate that the file gets put into a certain folder. Take this scenerio for instance:

  • We know that all content in ‘http://host/corporate/news’ is commercial news.
  • When user is creating a ‘News Item’ and uploads ‘logo2.jpg’ into the Upload Reference Widget called ‘image’ that we will ask the policy Where does this image, ‘logo2.jpg’ go? The policy could put it in /images/logos.
  • The policy would have to do everything. The Widget wouldn’t help anything. The file would be put into the ‘/images/logos’ folder and then in the ‘News Item’ image attribute would be the reference id to the ‘/images/logos/logo2.jpg’.

实施细节

The new widget has two main features:

  • Upload a new file: create a new object and make a reference to it
  • Select an existing object: make a reference to it

When uploading a new file, the widget checks for the mimetype and create an instance of the appropriate content-type: File or Image. This content is created in the ‘startup_directory’ property defined in the widget.

示例用法

Take a look in the ‘demo.py’ file for a simple example usage of this widget.

The browse and select functionality is provided by ‘archetypes.referencebrowserwidget’, which means you can use any of its current features.

Check the “complete reference of available options”:http://tinyurl.com/referencebrowserwidget-options online.

It contains the list of default property values and explains its meanings.

更改日志

0.2.1(2010-09-22)

  • 在文件中添加了manifest.in。 [沃特文]
  • 修复了pot文件中的i18n域。 [沃特文]
  • 添加荷兰语翻译。 [沃特文]
  • 添加了区域设置。 [吹捧]
  • 增加了法语翻译。 [吹捧]
  • 修复了registerType。它需要一个包名,因为原型是1.3.2。 [吹捧]

0.2(2009-03-22)

  • 将我们的皮肤层添加到所有皮肤路径。 [DEO]
  • 修复了metadata.xml和configure.zcml上的依赖项注册。 [DEO]

0.1-α(未释放)

  • 记录正在应用猴子修补程序的事实。 [润雅嘉]
  • 生成原型uploadreferencewidget并更改为使用 原型.referenceBrowserWidget而不是products.atreferenceBrowserWidget [沼泽猴]

uploadreferencewidget的更改日志

1.1(2007年11月26日)

  • 修复了测试用例中导致测试在 不同的方式取决于它们的运行方式或plone版本。[DEO]
  • 修正了demo.py代码中“startup_directory”的用法。[DEO]
  • 确保小部件将“使用当前对象”作为“启动目录” 当其值为“”时。[DEO]
  • 修复了当小部件的字段标记为 必修的。[DEO]

1.0.1(2007年11月16日)

  • 重新编写monkeypatch代码,使其更加健壮,并修补 右class。[DEO]
  • 修改了一个测试来处理所有plone版本。[DEO]

1.0(14-112007)

  • 修正了readme.txt的文本格式以使用StructuredText标记。[DEO]
  • 修正了当表单验证失败时不上载文件的问题。[DEO]
  • 为原型baseobject添加了monkeypatch。processform方法,因此我们不 要求整个世界将原型升级到未发布的版本。[DEO]

0.5(2007年30-10月)

  • 修复为使用referencebrowserwidget中的reference\u edit宏 (在1.7.2和2.0.1版本中提供),如果可用。这就去掉了 标题/说明字段文本。[DEO]
  • 增加了一个多重上传功能。现在一次可以上载多个文件 当小部件支持多个值时。[DEO]
  • 修正了没有从文件名中删除目录路径的错误, 从Internet Explorer上载到运行在不同操作系统中的Zope服务器时 从窗户。[DEO]
  • 改进了“Stastupx目录”处理:如果路径不存在,则文件 在实例本身内部上载(对于folderish对象),或 它的父母。[DEO]

0.2(2007年9月10日)

  • 改进了readme.txt文件的内容。添加了有关测试和示例的信息 用法。[DEO]
  • 重命名、简化并在演示中添加了第二个非多值字段 架构。[DEO]
  • 修正了当字段不是多值时上载也可以工作的问题。[DEO]

0.1(2007年8月24日)

  • 初始版本。[DEO]

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java Android同步不同页面上的按钮   java评测每个类收集的垃圾对象实例数   java(Spring MVC+Hibernate 4+Test 4)自动连线DAO返回NULL   java Android编辑文本和虚拟键盘   java Selenium与BrowserMobProxy   JAVAlang.NoClassDefFoundError:com/sun/jersey/spi/inject/Errors$关闭原因?   java为什么在我成功登录后仍然会出现“不正确的帐户或密码或用户类型”   安卓应用程序在重新启动java时崩溃。网UnknownHostException:无法解析主机   多线程在Java中同步共享静态对象的正确方法是什么?   未调用自定义注释的java类验证(约束类)   java如何将指定目录的存档文件放入所需位置?   java如何识别Selenium中的每个编辑文本字段,如果它们的Xpath都相同   使用gwtmockito/mockito的java简单单选按钮单元测试?