A widget for Archetypes with support for both uploading and referencing content.
Upload Reference Widget
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.
The suggested solution
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.
- Added MANIFEST.in file. [WouterVH]
- Fixed i18n-domain in pot-file. [WouterVH]
- Add Dutch translation. [WouterVH]
- Added locales. [toutpt]
- Added French translation. [toutpt]
- Fixed registerType. It needs a package name since Archetypes 1.3.2. [toutpt]
- Added our skin layer to all skins paths. [deo]
- Fixed dependency registration on both metadata.xml and configure.zcml. [deo]
- Log that fact that a monkey patch is being applied. [runyaga]
- Eggified to archetypes.uploadreferencewidget and changed to use archetypes.referencebrowserwidget instead of Products.ATReferenceBrowserWidget [swampmonkey]
Changelog for UploadReferenceWidget
- Fixed a persistence bug in the TestCase who was causing tests to behave in different ways depending on how they were run or on the Plone version. [deo]
- Fixed the usage of ‘startup_directory’ in the demo.py code. [deo]
- Made sure the widget honors the “use the current object” as the ‘startup_directory’ when its value is “”. [deo]
- Fixed the “can’t save the object” problem when the widget’s field is marked as required. [deo]
- Reformulated the MonkeyPatch code to make it more robust and also to patch the right class. [deo]
- Amended a test to work on all Plone versions. [deo]
- Fixed the text formatting of README.txt to use the StructuredText markup. [deo]
- Fixed to not upload files when the form validation fails. [deo]
- Added a MonkeyPatch for Archetypes BaseObject._processForm method, so we don’t require the entire world to upgrade Archetypes to unreleased versions. [deo]
0.5 (30-10 2007)
- Fixed to use the reference_edit macro from ATReferenceBrowserWidget (present in 1.7.2 and 2.0.1 versions), when available. This removes the double title/description field text. [deo]
- Added a multi-upload feature. You can now upload more than one file at a time when the widget support multiple values. [deo]
- Fixed a bug where the directory path wasn’t being removed from the filename, when uploading from Internet Explorer to a Zope server running in OS different from Windows. [deo]
- Improved the ‘startup_directory’ handling: if the path doesn’t exists, the files are uploaded inside the instance itself (in case of a folderish object), or its parent. [deo]
- Improved the content of the README.txt file. Added info about tests and example usage. [deo]
- Renamed, simplified and added a second field, non multiValued, to our demo schema. [deo]
- Fixed the upload to also works when the field is not multiValued. [deo]
- Initial version. [deo]
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|File Name & Checksum SHA256 Checksum Help||Version||File Type||Upload Date|
|archetypes.uploadreferencewidget-0.2.1.tar.gz (485.8 kB) Copy SHA256 Checksum SHA256||–||Source||Sep 22, 2010|