Teaser Jobausschreibung

Control production buildouts with supervisor

Yesterday i tried to integrate varnish into a plone3 buildout using plone.recipe.varnish.
This works like a charm. I added /bin/instance to rc.d and tried to do the same with varnish to make it start automatically.
When asking for a solution to stop varnish on #plone, wiggy and aclark suggested to use supervisor.

Aclark recently worte a blogpost about supervisor and asked for a way to make buildout generate the supervisord.conf and a paster template that includes supervisor.

Wiggy just checked in ZopeSkel2.0 with supervisor added to the plone_hosting template.

Since it’s added using zc.recipe.egg the supervisord.conf has to be created and modified manually and is not generated with bin/buildout.

This is what collective.recipe.supervisor does for you.

The following setup worked fine for me:

[varnish-build]
;find newer versions on http://varnish.projects.linpro.no/
recipe = plone.recipe.varnish:build
url = http://switch.dl.sourceforge.net/sourceforge/varnish/varnish-1.1.2.tar.gz

[varnish]
recipe = plone.recipe.varnish:instance
bind = *:6181
backends = 127.0.0.1:8180
cache-size = 512M
# foreground is needed for supervisor to control varnish correctly
mode = foreground

[supervisor]
#recipe = zc.recipe.egg
#eggs = supervisor
recipe = collective.recipe.supervisor

port = localhost:9001
user = admin
password = admin

programs =
    10 zope ${instance:location}/bin/runzope ${instance:location} true
    20 varnish  ${buildout:directory}/bin/varnish  true

Make sure you’re starting supervisor with root privileges.
Otherwhise varnish will be started but supervisor won’t recognice it’s running.

Now you just add supervisor to your default runlevels, instead of adding every service of your instance.:

cd /etc/init.d/
ln -s INSTANCE_HOME/bin/supervisord project-supervisord
ln -s INSTANCE_HOME/bin/supervisorctl project-supervisorctl
update-rc.d project-supervisord defaults

control the services using /etc/init.d/project-supervisorctl

shutdown supervisor and all started services: /etc/init.d/project-supervisorctl shutdown

Advanced sorting features for plone folders

Since plone2.5 we’ve got drag&drop support for sorting items in folder_contents view (as long as your content’s meta_type does not contain spaces ;-).

However, drag an drop has the limitation that in a batched view (20 items per page), you can’t move the item on position 20 to 21. You can swith off batching in folder_contents view in recent versions, and there are also patches that enable drag&drop again (see plone3 user manual and issue 7202).

When handling a lot of items in a container, i can think of other useful options such as “move to top”, “move to bottom”, “move n items up/down” or even “sort alphabetically asc/desc”.

In 2006 i wrote a python script for making this (except of sorting) possible for a customer.
It has been ‘released’ in our public svn repository today and I hope this will make other people’s live easier, too:

https://svn.webmeisterei.com/repos/public/plone-tools/moveObjToPos/trunk/

I’m thinking of a more polished version as a small plone package (maybe even with i18n) and adding support for sorting items alphabetically.

Does anybody know if there are already products available that do the same thing?

Are there plans that plone will support a feature like “show items alphabetically sorted” or “ordered reversed” in a folder’s views?

meta_types containing spaces break folder_contents sorting

If you experience problems with sorting/reordering items in folder_contents as i did recently
this might save you from spending > 2 hrs with debugging.

If your folder does contain custom or third party content types that have a space ” ” in their meta_type (see portal_type/ ‘Product meta type’) you most probably ran into the same problem:

If you defined the meta_type of your content type in profiles/default/types/My_Type.xml like that:

<object name="My Type">
  ...
  <property name="content_meta_type">My Type</property>
  ...

objects of your type will have ‘MyType’ as meta_type:

>>> _ = folder.invokeFactory('My Type', 'mytype')
>>> folder.mytype.meta_type
'MyType'

Products.Archetypes.OrderedBaseFolder.moveObjectsByDelta only takes CMF-Types into account.

This is done by using only those ids returned by getCMFObjectsSubsetIds which lists all meta_types registered in portal_types and compares them to the meta_type of the objects contained in the folder.

Since these differ for meta types containing spaces you’ll experience very strange behaviour when reordering items in a folder containing some objects of type ‘My Type’.

Solution:

In case you’re responsible for the product, simply change the GS profile for the portal type from <property name="content_meta_type">My Type</property> to <property name="content_meta_type">MyType</property> and reinstall the product.

In case you’re using a third party product you’re out of luck.
This is why I filed a bug (https://dev.plone.org/plone/ticket/8161)