Weblog
Plone 3 versus 4.1 Compatibility
Add Plone 4.1 compatibility while avoiding breaking Plone 3 compatibility.
I see a bit too often that some kind soul adds Plone 4.1 compatibility to a package and then does not notice that Plone 3 compatibility is destroyed. In at least one case this is totally not needed and easily avoided.
The problem that people try to solve is that on Plone 4.1 a lot of packages will need to explicitly load the permissions.zcml file of Products.CMFCore. That could be done like this, but this is bad:
The problem with this code is that it breaks Plone 3 compatibility: the Products.CMFCore version used in Plone 3 does not have a permissions.zcml file! You will get an error like this when you try to startup your Plone 3 site:
IOError: [Errno 2] No such file or directory: '.../Products.CMFCore-2.1.2-py2.4.egg/Products/CMFCore/permissions.zcml'
Note that on Plone 4.0 the loading of this file works fine but is not needed, so avoiding it is probably very slightly better in startup time. No big deal though.
The proper way is to load this file conditionally. This is easy enough, with just two extra lines:
Of course if you know that for other reasons your package is not Plone 3 compatible then you could safely omit the condition. But it does not hurt to keep it for clarity.
All this is shown in the Plone Upgrade Guide at http://plone.org/upgrade, specifically here.
Note that the plone-41 definition that is used in the zcml:condition is defined in the meta.zcml file of Products.CMFPlone 4.1.3 as follows:
So if you think you could use something similar in your code, this is where to start looking.
Actually, it can be done simpler; the following currently works in all Plone versions:
Meanwhile, loaded with this knowledge you can participate safely in the Plone TuneUp this Friday 16 December 2011, and update some packages for Plone 4. Thanks!
Python Users Netherlands meeting 20 October 2011
Summary of the Python Users Netherlands (PUN) meeting at 20 October 2011 in Amsterdam.
This month's PUN was hosted by Minddistrict, which has acquired The Health Agency (THA). Jan-Jaap Driessen introduced the companies. They build online tools for health care. Are you looking for a position of 1, 2 or 3 years at the Leuphana University (close to Hamburg, Germany)? They have a spot available there.
- Jan-Jaap Driessen: Connecting the bots
- Boaz Leskes: PyCounters
- Steve Alexander: Celebration, Motivation, Distribution
- Frank Niessink: Ran 160242 tests in 13.716s
- Vincent Pretre: collective.autosaveform
- Sylvain Viollon: context managers and generators to work on lots of objects
- Remco Wendt: showing two python tools
Jan-Jaap Driessen: Connecting the bots
Now for something more technical. We use buildbot to test our software. We use Selenium (using gocept.selenium) to test in a real web browser, including javascript. Instead of checking the end result of clicking with Selenium by going to a page, you can also check the database directly. We have a local browser farm, so with several versions of several browsers on several operating systems. You can try setting up something yourself or use the saucelabs paid service for this. So we have this setup:
zc.buildout + buildbot + selenium = nightly testing on all browsers
When this is running on saucelabs you can actually see the screen of the browser that is being tested at that moment! You can also see a video of it later and share that with your client to show that your software is working or that this particular bug has been fixed. The saucelabs service is pretty cheap actually, cheaper than setting up some hosts in the cloud yourself and keeping them running.
Boaz Leskes: PyCounters
PyCounters is a light weight library to monitor performance and events in production systems. We started this project because we had a performance problem. We had lots of layers in the system, so it was challenging to see where the bottleneck is. PyCounters gives us that. It is a combination of light weight events, counters to collect needed statistics, and reporters to regularly output statistics. Short example to see how many times per second a function is being called:
from pycounters.shortcuts import frequency @frequency("req_per_sec") def serve_a_request(): """do something interesting and serve a request""" pass
Some possibilities:
- We can calculate frequencies, average values per time, simply counting.
- There is JSON file output.
- A helper class for Munin plugins.
- Support for counting what happens in a single thread or for using multiple processes or servers.
Future plans:
- Using context managers (the with statement) is now planned, as decorators are not always fine grained enough.
- Django specific counters.
- More output formats (suggestions welcome).
See documentation at http://pycounters.readthedocs.org/ and source code at https://bitbucket.org/bleskes/pycounters
Note from Maurits: do not confuse this with the pycounters module of François Beausoleil which does something different, though it seems to have overlapping functionality.
Steve Alexander: Celebration, Motivation, Distribution
"Now we're talking." I was a python programmer, then I worked for Launchpad, then Canonical (making Ubuntu), then I did acting classes and stuff. Then I started a company to talk about how we work. We have really complicated brains. I am using a metaphor: the hero's journey. George Lucas used that same story to create the Star Wars movies. When we go to work we also go on a journey and we should enjoy it.
Some of us work alone, some in a community or team. Who is my team? What is my value to the team? We need to achieve a goal, for example fixing a bug or other issue somewhere in a tracker. You fix or create something and that means you add value to the team. That is the outer journey. There is also an inner journey, some kind of transformation that goes on. (Insert some Star Wars and Indiana Jones jokes here.) You have some personal 'Aha!' moments, where you discover amazing things, or that you can do amazing things. What those moments tell you is your team's value to you.
I wrote a blog article about celebrating the hero's journey. See http://blog.nowtalking.nl/archives/55. Lots of different reactions are possible from colleagues or clients when you tell them "Hey, I fixed a bug."
Frank Niessink: Ran 160242 tests in 13.716s
Task Coach: your friendly task manager. This is a project that has been going on since 2005. Done in Python of course, and some Objective C. It is open source. Runs on Windows, Mac OS X, Linux, BSD, iPhone. We try to release often; last year about twice a month. We have quite some downloads, in total at least 2 million downloads. More than 4000 users use it daily. Over 4500 unit tests and with 40 languages over 160,000 language tests. Translatable strings can contain keyboard shortcuts; translating this wrongly (e.g. translating Ctrl into German as Strg instead of leaving it at Ctrl) can actually crash the program. We have generated a unit test for each translation, like checking whether a translator forgot to add ... when necessary or indeed checking for program crashes.
Vincent Pretre: collective.autosaveform
collective.autosaveform is an open source project for Plone. A user has entered a lot of data in a web form, his internet connection quits and he gets mad because he has lost everything. With collective.autosaveform we save the form every five seconds or every click. We use localstorage for this in the browser, supported by IE8 and higher and normal browsers. After ten local saves we also send the data to the server so in case the browser crashes or something like that the data can still be made available later. When something bad has happened and the user is loading the form again, we compare the local and remote database versions and use the most recent. You need to register the form for autosaving in Plone with a few lines, and use one jQuery line in your javascript. It's configurable, friendly on the server and for the user, supported on multiple browsers, supports all HTML inputs except file. It should be pretty doable to make it work in Django.
See the slides.
Sylvain Viollon: context managers and generators to work on lots of objects
This is code that is hard to summarize, but you can do interesting things with context managers and generators, at least with Python 2.6 and higher. You can save some memory but more importantly you can save a lot of lines of code with good use of these utilities.
See his code at http://pastebin.com/hgqiSTVz. The long stretches of white space between the code parts should be seen as separating different versions of the code.
Remco Wendt: showing two python tools
vcprompt: show in the command line prompt which version control system (vcs) you are using, which branch, etc. There is a binary one, but you should use the Python one.
dotfiles: define a repository of dotfiles that you have in a vcs, show what dotfiles you have managed already and allow you to sync or override them, especially handy when on a new system.
Nederlandse Plone gebruikersdag 2011
Samenvatting Nederlandse Plone gebruikersdag 2011
Op dinsdag 20 september 2011 was de jaarlijkse Nederlandse Plone gebruikersdag 2011 in De Balie in Amsterdam. Deze dag werd georganiseerd in een samenwerking van diverse Plone bedrijven. Naast goede gesprekken bij de koffie- en lunchpauzes waren er natuurlijk presentaties. Hier volgt een korte samenvatting van die presentaties, met links naar uitgebreidere samenvattingen.
De toekomst van Plone
Maarten Kling van Four Digits presenteerde over "Plone Next", de toekomst van Plone. In welke versie alle wijzigingen precies gaan komen staat nog niet vast.
Plone 4.1 is de meest recente versie. Van Plone 4.2 is een tweede alpha versie beschikbaar met onder andere een betere weergave van zoekresultaten en nieuwe collecties (verzamelingen) die op een eenvoudigere manier te beheren zijn. Naast plannen voor Plone 4.3 zijn er spannender plannen voor verder in de toekomst, of dat nu Plone 5 gaat heten of iets anders: een handigere interface (Deco) met meer vrijheid voor de webmaster; makkelijker themen van een website; CMS UI: een balk aan de bovenkant waar je knoppen hebt voor bijvoorbeeld het bewerken van de pagina, workflow, toevoegen van content, enzovoorts. De rest van de week gaan we tijdens de Living Statues Sprint hieraan met diverse ontwikkelaars werken.
Lees meer: http://maurits.vanrees.org/weblog/archive/2011/09/toekomst-plone
SalesForce
Wieteke den Uijl van Proteon en Pierre Broekarts van Unit 4 Consist presenteren een case study over de integratie van SalesForce met Plone. Unit 4 Consist gebruikt SalesForce als CRM systeem voor intern gebruik en voor marketing, sales, servicedesk, rapportages. In de oude situatie was er veel handmatig werk, dus dat was foutgevoelig. De klant had ook geen inzicht in de status van afhandelingen.
Ze hadden dus wat wensen: volledige CMS functionaliteit en automatische invoer in SalesForce. Hier is voor Plone gekozen, met extra functionaliteit voor de koppeling met SalesForce. Klanten weten nu waar ze alles moeten zoeken, namelijk op dit ene systeem.
Lees meer: http://maurits.vanrees.org/weblog/archive/2011/09/salesforce
Naslagwerken in Plone: publiceren zonder zorgen
Jan Murre van Pareto presenteert een case study over naslagwerken in Plone. KNMP publiceert het Informatorium Medicamentorum, een boek met duizenden grote pagina's medische informatie. Dat beheren we nu in Plone. Daarin hebben we custom contenttypes gebouwd, gebruiken rollen, permissies, workflow, check-out/check-in (je wijzigt bijvoorbeeld de homepage en laat anderen de wijziging controleren terwijl de oorspronkelijke versie nog zichtbaar is), een WYSIWYG-editor en full-text search. Een mooi overzicht van wat er zoal mogelijk is met Plone op dit gebied.
Lees meer: http://maurits.vanrees.org/weblog/archive/2011/09/naslagwerken
Lightning talks
Traditioneel werd het inhoudelijke gedeelte van de dag afgesloten met lightning talks, praatjes van ongeveer vijf minuten.
- Paul Roeland: van Joomla naar Plone. http://schonekleren.nl is nu nog een oude Joomla site. Wordt Plone. We gaan transmogrifier gebruiken om de content om te zetten.
- Yadi Dragtsma: Free publicity. Je hebt een mooi persbericht, maar zelfs het lokale suffertje pikt het niet op. Wat moet je doen? Een paar redactiewetten en speltips.
- Kees Hink: Diazo. Voor http://www.iederz.nl/ hebben we een nieuwe website gebouwd in Plone, met Diazo als theming methode. Diazo haalt stukjes uit de website (Plone) en hangt dat in het html ontwerp.
- Maurits van Rees (ondergetekende): collective.depositbox. Een klein python pakket om een geheime sleutel op te slaan om acties mogelijk te maken zoals het herstellen van je wachtwoord in Plone.
- Thijs Jonkman: Diazo. Voor het themen van een site met Diazo hebben wij het Compass style framework gebruikt (met Ruby) om wat css stylesheets te maken die aardig goed zijn voor de gemiddelde Plone site, zodat nieuwe sites gemakkelijker worden.
Lees meer: http://maurits.vanrees.org/weblog/archive/2011/09/lightning-talks
Al met al een mooie dag waarin gebruikers en ontwikkelaars van Plone in Nederland elkaar ontmoet hebben.
Dutch Plone User Day 2011
Summary of the Dutch Plone User Day 2011.
On Tuesday 20 September 2011 the yearly Dutch Plone User Day 2011 (Dutch link) was held in De Balie in Amsterdam. This day was organized by various Dutch Plone companies. Next to good conversations during coffee and lunch the day was of course filled with presentations. Here is a short summary of those talks.
Dutch readers are encouraged to read the Dutch summary with links to larger Dutch summaries of the individual talks.
The future of Plone
Maarten Kling from Four Digits talked about "Plone Next", the future of Plone. In which exact version all changes will be available has not been decided yet.
Plone 4.1 is the most recent version. A second alpha release of Plone 4.2 is available with among other changes a better display of search results and new collections that can be managed in an easier way. Next to plans for Plone 4.3 there are more exciting plans for somewhere in the future, whether that is going to be called Plone 5 or something else: a handier interface (Deco) with more freedom for the web master; easier theming of a website; CMS UI: a bar at the top of the page with buttons for editing the page, workflow, adding content, etcetera. The rest of the week we will be working on this with several developers during the Living Statues Sprint.
SalesForce
Wieteke den Uijl from Proteon and Pierre Broekarts from Unit 4 Consist present a case study about the integration of SalesForce in Plone. Unit 4 Consist uses SalesForce as CRM system for internal usage and for marketing, sales, servicedesk, reports. In the old situation there was a lot of manual work, so errors were made. The customer also had no insight in the status of his requests.
So they had wishes: full CMS functionality and automatic input into SalesForce. Plone was chosen for this, with extra functionality for the integration with SalesForce. Customers now know where they can find everything: on this one system.
Books of reference in Plone: publishing without worries
Jan Murre from Pareto presents a case study about books of reference in Plone. KNMP publishes the Informatorium Medicamentorum, a book with thousands of large pages with medical information. We now manage this within Plone. We have built custom contenttypes, are using roles, permissions, workflow, check-out/check-in (for example you are editing the homepage and let others check your changes while the original version is still visible), a WYSIWYG-editor and full-text search. A nice overview of what is possible with Plone in this area.
Lightning talks
Following tradition the official part of the day ended with lightning talks of about five minutes.
- Paul Roeland: from Joomla to Plone. http://schonekleren.nl is currently still an old Joomla site. This will become Plone. We will use transmogrifier to migrate the content.
- Yadi Dragtsma: Free publicity. You have a nice press release but even the small local paper does not publish it. What must you do? A few redactional laws and game tips.
- Kees Hink: Diazo. For http://www.iederz.nl/ we have created a new website in Plone, with Diazo as theming method. Diazo takes pieces from the website (Plone) en places them in the html theme.
- Maurits van Rees (that's me): collective.depositbox. A small python package to store a secret key that makes actions possible, in the same way as resetting your password in Plone.
- Thijs Jonkman: Diazo. For the theming of a site with Diazo we have used the Compass style framework (with Ruby) to create some css stylesheets that work pretty well for most Plone sites, so new sites will be easier to theme.
All in all it was a nice day on which users and developers of Plone in the Netherlands have met.
Lightning talks
Nederlandse Plone gebruikersdag 2011
Lightning talks tijdens de Nederlandse Plone gebruikersdag 2011 in De Balie.
Paul Roeland: van Joomla naar Plone
http://schonekleren.nl is nu nog een oude Joomla site. Wordt Plone. We gaan transmogrifier gebruiken om de content om te zetten. Het is een pijplijn die content uit in dit geval Joomla haalt en daar Plone content van bakt. De andere kant op kan ook; je kan er zelf pijplijnen voor definiëren. In Joomla kan je Jix installeren, een import en export utility. Die export gebruik je als input voor transmogrifier. Zie http://pypi.python.org/pypi/collective.transmogrifier
Yadi Dragtsma: Free publicity
Ik doe marketing en communicatie bij Four Digits. Je hebt een mooi persbericht, maar zelfs het lokale suffertje pikt het niet op. Wat moet je doen? Redactiewetten: redacteuren hebben altijd haast, zijn liever lui dan moe (maak het hen makkelijk), redacteuren zijn generalisten (maak het begrijpelijk), redacteuren zijn objectief (zeg dus niet te snel dat iets nieuw en fantastisch is). De meeste persberichten zijn enorme verhalen zonder structuur; meer vorm dan inhoud; beroepsdeformatie (cijfertjes, jippie; nee, gebruik Jip-en-Janneke-taal). Speltips: vergroot je kansen. Wees kort, bondig en objectief; kies juiste opmaak; koppel je evenement aan iets actueels; let op spelfouten, let op de vijf W's: wie, wat, waar, wanneer, waarom. Zorg liefst dat het bericht bij een specifieke redacteur terecht komt en bel ook even.
Kees Hink: Diazo
http://www.iederz.nl/ Sociale werkplaats in Groningen. Wij werden gevraagd een nieuwe website hiervoor te bouwen, passend bij hun nieuwe huisstijl. Die stijl was heel specifiek. Dat kan een uitdaging zijn met Plone. Je wil het liefst alle handige standaard Plone features, maar dan wel de voorkant tonen in de stijl van de klant. Diazo haalt stukjes uit de website (Plone) en hangt dat in het html ontwerp.
Maurits van Rees: collective.depositbox
Dat ben ik. :-) Zie http://pypi.python.org/pypi/collective.depositbox
Thijs Jonkman: Diazo
Wij hebben het Compass style framework gebruikt (met Ruby) om wat css stylesheets te maken die aardig goed zijn voor de gemiddelde Plone site, zodat nieuwe sites gemakkelijker worden. Zie http://www.compass-style.org/