Weblog
plone.portlets
Plone conference 2007, Naples. Speaker: Geir Baekholt
Plone conference 2007, Naples. Speaker: Geir Baekholt
The left_slots and right-slots properties are probably the oldest piece of Plone that is sill in 2.5. It is at least seven years old. It is not working really nice for users or developers.
Then we had PlonePortlets. With this product, portlets became content objects (which is not terribly nice). They worked but has many side effects.
In April 2006 we had the Archipelagosprint in which we spent time thinking about portlets and coding a bit. Then everyone went home and did nothing about it. Except Martin Aspeli (optilude on irc). He almost singlehandedly (well, with help by Philipp von Weitershausen) coded plone.portlets and plone.app.portlets which is in Plone 3.0.
In Plone 3.0 portlets are objects, not templates (although there are templates in the background of course, to actually show the portlets in the browser).
Default portlets are the login portlet, navigation, calendar, recent items, news, events, search, RSS feed (though it does not work), review list and the classic portlet (which we will see later).
Adding portlets is now more involved than just setting the left_slots and right_slots properties. They can be assigned to context, users/groups and content types.
With the Manage Portal permission you have a link at the bottom of the left and right slots to a page for managing the portlets of that context. You can also block portlets in subfolders. Due to a bug this does not work in Plone 3.0, but it does work in 3.0.1.
Often you want to have a portlet that is only visible to for example the finance department. You can now do this in the Group Management in the Plone Control Panel. Go to the Group Portlets tab and add left and right portlets there for this group.
You can have user portlets. A user can add portlets in his personal dashboard. Click on the user name (next to logout usually). Edit your dashboard there and add your favorite portlets.
There is a static portlet in the collective. It is a good example that you can copy. Also look at the Collection portlet, which can come in place of the News and Recent Items portlets.
These new portlets are a bit more complex than the old ones. For backwards compatibility there is the Classic portlet so you can still use them (with all its downsides of course).
Portlets are not viewlets. Portlets are persistent. Viewlets are defined in zcml.
Porlets have at least: interface, assignment, renderer. Possibly also an add form, edit form. Interface describes what it looks like (it has a header attribute in our case), inheriting from IPortletDataProvider. The Assignment class implements that Interface. The Renderer class renders the portlet (mostly using a template). It also has a method available so you can use that to conditionnally show the portlet. You wrap all this up with some lines in a zcml file.
In the future we want to have more GenericSetup support for this so you can define portlet assignments in xml so you do not need to write code for this. (Are there any volunteers?) We need widgets for more advanced configuration. We need more reusable portlets. Try it! We also may come up with a paster template that you can use as a starting point for your own portlet.
Multimedia in Plone
Plone conference 2007, Naples. Speaker: Nate Aune
Plone conference 2007, Naples. Speaker: Nate Aune
Plone has rss 1.0. This does not support enclosures, so not podcasting. Plone4Artists improves this. It uses Zope 3 technologies: it does not introduce new content types. You can just use it to adapt existing content types.
Plone4ArtistsSite wraps together a few of the Plone4Artists products.
We went from CMFAudio (CMF) via ATAudio (Archetypes) to Plone4Artists (Zope 3). Instead of ATAudio, ATVideo, ATPhoto we just have default content types like ATFile, ATImage, ATLink and adapt it to our needs with Plone4ArtistsAudio/Video, etc.
Example sites: http://talk.bmc.com, http://engagemedia.org, http://thedailyreel.com, http://bilive.it, http://phonogen.com and since last Thursday... http://plone.tv!
Id3 metadata is automatically extracted by Plone4Artists and when you edit them they are written back to the audio file. That is cool.
With WebDav you can upload audio content to Plone.
You can turn a SmartFolder into a podcast.
Uploading large files is tedious in Zope. To improve this you now have ZipFileTransport, PloneFlashUpload and Tramline.
More info: http://plone4artists.org/products
irc: #plone4artists on irc.freenode.net
Introduction to the ZODB
Plone conference 2007, Naples. Speaker: Laurence Rowe
Plone conference 2007, Naples. Speaker: Laurence Rowe
The ZODB stores objects, not rows of data. When dealing with rows like in a relational database and you change the data layout, you do alter table statements for migration. In the ZODB that does not happen so you need to do that differently.
Transactions
Zope 2.8 introduced transactions, which means:
- concurrency control
- atomicity
- less conflict errors
When you do a lot of writes in the ZODB you will encounter conflict errors. Most of them should be resolved automatically. But if this happens a lot, you need to improve your code. In some cases BTrees help, so using BTreeFolders as base for your folders. Also a product like QueueCatalog can help. This defers new calls to the catalog, which can speed things up at the cost of not always seeing up-to-date data.
Sending emails might happen twice if the transaction gets aborted somewhere in between.
Scalability
Python has a Global Interpreter Lock, which means a python process can use just one CPU. Zope can use ZEO to handle this better. One ZEO server serves the data to several ZEO clients. A ZEO client is basically a normal Zope instance but with the database being managed by another process: the ZEO server.
You can also store for example the catalog in a different ZODB. You can tweak the caching of the different ZODBs to fit whatever you put in that particular database. A lot of big sites to this.
Storage types
Almost everyone uses FileStorage. This stores the database in a single file Data.fs. DirectoryStorage can be used in some cases. Newer on the block is PGStorage which stores the data in a PostgreSQL database.
Other features
- Savepoints: you can go back to one state that you know is safe, instead of reverting the complete transaction.
- You can store versions, but that is deprecated.
- Undo, but this is not always possible. If you put for example your catalog in a different storage, you will find that an undo of the main database does not undo the change in that catalog.
- BLOB: large file support (in newer ZODBs).
- Packing: remove old versions of obejcts. Similar to doing a vacuum in PostgreSQL to reclaim used space. It gets rid of undo information.
Best practices
- Do not write on read. If your object for example uses setDefault, you may find that the first time you read that object it actually gets written.
- Keep your code on the file system, not in the ZODB, like the custom folder. That quickly becomes unmanageable.
- Use more BTrees. This scales better than normal trees. BTrees handles thousands of objects more efficiently CPU-wise and memory-wise.
- Make simple content types. Use adapters if you need more complexity on top of the base content types.
Documentation: http://wiki.zope.org/ZODB/Documentation It is a bit old though, more about earlier versions of the ZODB. But still a good source of information.
Why you should learn more about workflow in Plone
Plone conference 2007, Napels. Speaker: Vincenzo Di Somma Company: RefLab
Plone conference 2007, Naples. Speaker: Vincenzo Di Somma Company: RefLab
Workflow from the beginning. This is mostly a hands-on talk, showing the portal_workflow in the ZMI.
Workflow is basically: during the life cycle of content there are changes in who is allowed to do what.
In Plone we use the workflow to manage the publication process. But we can use it for other things.
Plone 3.0 by default has six workflows now that you can choose from.
About four people in the audience have created workflows in the ZMI. About three have used ArchGenXML for this.
In the ZMI you can manage workflow variables. Usually: action, actor, comments, review_history, time. But you can add more yourself.
You can add worklists. By default there is the reviewer_queue. This is used by the Recent Items portlet to get a list of items that are in the pending workflow state.
On the Permissions tab you can list permissions that should be handled by this workflow: who is allowed to do what in which state.
Files and Images have no workflow anymore in Plone 3.0 by default. Question from the audience: why do they not have a on-state workflow? Answer: there are differences, but I would have to look up the code. Probably there are differences in what Anonymous visitors are allowed to see.
There is also the CMFPlacefulWorkflow, which you can install with the quick installer. [About three in the audience have worked with that.] It is very powerful. It lets you specify workflow policies. In there you can set a different default workflow and assign different workflows to content types. Within a folder object you can specify which policy to use. So you can use a different policy in different parts of your site.
You can change workflows through the ZMI or with a python file or with the newer, better way: with a xml file in a GenericSetup profile. In portal_setup you can export your current workflow to an xml file, because you do not want to create such an xml file from scratch.
Use case: Smanettona. Site for learning children about computers. Content that is added should be checked by an adult first. We use default Plone publishing workflow for the corporate part of the site. We use a restricted workflow for the home folder of the users. And an even more restricted workflow for the magazine.
You can manage more than just the publication process. You can send emails when a transition occurs. You can have worklists, like the reviewer queue.
Common requested improvements by customers on top of workflows:
- email alerts on workflow change (look at content rules in Plone 3.0)
- explicit selection of actors (like reviewers) by group, sections, etc.
- multireview: transition needs to be done by more than one person.
- link transitions: publishing A also automatically publishes B.
- multi site life cycle: once content is published on site A it is automatically published on site B.
The story of GetPaid and a "social source" process to create new opportunities with Plone
Plone conference 2007, Naples. Speaker: Christopher Johnson
Plone conference 2007, Naples. Speaker: Christopher Johnson
This talk is about how Plone GetPaid is being developed. We made a name for how we did that: Social Source.
Developers are often not too happy about input from others. "We know quite well what we need to do, thank you."
How you get it done determines what you get done.
We saw that Plone was flexible and useful out of the box. But payment through Plone was not possible, so you had to use other products. We wanted to do something about that.
I am an entrepreneur, not a developer, and I did not know much about e-commerce when I started.
Step 1. So we started looking: what is already out there? Why do we need something else. We wrote about that on the website of GetPaid: http://plonegetpaid.com.
Step 2. Then we made a plan. What do you do and how? Who is going to benefit? And make the site pretty.
Step 3. We recruited leaders and participants.
Step 4. We refined the requirements. We got input from users, developers, UI experts.
Step 5. We asked for money. If you do not ask, you will not get it. How to ask? Connect needs with value: how does it help them? Be transparent about what you do with the money. Be patient and persistent.
Step 6. We celebrate successes. Reward and recognize people. Communicate about recent developments in the project: what has been done?
Step 7. Sustain it: have fun together, motivate people.
We had three sprints so far. The code is at Google Code. We have a blog, mailing list, irc channel #getpaid.
Perhaps Plone could benefit from a process like this? Where is Plone going? What is our vision? Developers and users should answer that question. [Someone from the audience says: Alexander Limi is going to announce something about that this week.]