Blog

A reminder about catalog-indexes

erstellt von Philip Bauer zuletzt geändert: 2014-05-21T05:56:13+01:00
We often create new indexes to make content searchable in Plone. Many developers still do it wrong.

Most new sites we create contain facetted search based on eea.facetednavigation. Thus we often create new indexes to make content searchable. One example is www.idea-frankfurt.eu where attributes and relations of projects are used to make them searchable in a useful way.

Almost everything that is to be said about indexes can be found in http://docs.plone.org/develop/plone/searching_and_indexing/indexing.html

But there was a known pitfall when registering indexes in catalog.xml that was only fixed in Plone 4.3.2. Even though Maurits van Rees warned about this in a blogpost which is also reference in the documentation I often see developers making that mistake.

Unless working with Plone 4.3.2+, you should never register a index in catalog.xml because the index will be purged when reinstalling your package. Instead register new indexes in your setuphandlers.py. This was fixed in GenericSetup 1.7.4.

I firmly believe that addons have to be reinstallable without ruining a site.

I extended the method written by Maurits to separate the name of the index and the indexed method (useful when dealing with old code):

# -*- coding: UTF-8 -*-
import logging
from Products.CMFCore.utils import getToolByName
PROFILE_ID = 'profile-my.package:default'


def setupVarious(context):

    # Ordinarily, GenericSetup handlers check for the existence of XML files.
    # Here, we are not parsing an XML file, but we use this text file as a
    # flag to check that we actually meant for this import step to be run.
    # The file is found in profiles/default.

    if context.readDataFile('bgp.webcode_various.txt') is None:
        return

    # Add additional setup code here
    logger = context.getLogger('my.package')
    site = context.getSite()
    add_catalog_indexes(site, logger)


def add_catalog_indexes(context, logger=None):
    """Method to add our wanted indexes to the portal_catalog.

    @parameters:

    When called from the import_various method below, 'context' is
    the plone site and 'logger' is the portal_setup logger.  But
    this method can also be used as upgrade step, in which case
    'context' will be portal_setup and 'logger' will be None.
    """
    if logger is None:
        # Called as upgrade step: define our own logger.
        logger = logging.getLogger('my.package')

    # Run the catalog.xml step as that may have defined new metadata
    # columns.  We could instead add <depends name="catalog"/> to
    # the registration of our import step in zcml, but doing it in
    # code makes this method usable as upgrade step as well.  Note that
    # this silently does nothing when there is no catalog.xml, so it
    # is quite safe.
    setup = getToolByName(context, 'portal_setup')
    setup.runImportStepFromProfile(PROFILE_ID, 'catalog')

    catalog = getToolByName(context, 'portal_catalog')
    indexes = catalog.indexes()
    # Specify the indexes you want, with
    # ('index_name', 'index_type', 'indexed_attribute')
    wanted = (('myindex', 'FieldIndex', 'getMyAttribute'),
              )
    indexables = []
    for name, meta_type, attribute in wanted:
        if name not in indexes:
            if attribute:
                extra = {'indexed_attrs': attribute}
                catalog.addIndex(name, meta_type, extra=extra)
            else:
                catalog.addIndex(name, meta_type)
            indexables.append(name)
            if not attribute:
                attribute = name
            logger.info("Added %s '%s' for attribute '%s'.", meta_type, name, extra)
    if len(indexables) > 0:
        logger.info("Indexing new indexes %s.", ', '.join(indexables))
        catalog.manage_reindexIndex(ids=indexables)

By the way: Besides many other amazing features the package ftw.upgrade also has methods catalog_rebuild_index, catalog_add_index and catalog_remove_index you an use in your upgrade-steps.


Mastering Plone

erstellt von Philip Bauer zuletzt geändert: 2014-05-20T16:47:00+01:00
A three-day introduction into customizing and developing websites with Plone

tl;dr: We're giving our three-day "Mastering Plone" training in Munich (in english)

During the course of this three-day training we will teach how to

  • ... wield the awesome features of Plone for maximum effect.
  • ... customize and extend Plone to make it do exactly what you want.
  • ... use the current best-practices to become a Plone rockstar.

In the first part we'll teach the fundamentals needed to setup and manage your own website using the many build-in features of Plone.

The second part will focus on customizations that may be done through-the-web.

The third and longest part will be devoted to Plone-development. Here we focus on current best-practices like Dexterity and Diazo that make developing with Plone fun and accessible.

The training is for people who are new to Plone or used to work with older versions of Plone and want to learn the current best-practices. Basic Python and HTML/CSS skills are a requirement.

The course is an updated and expanded version of the trainings we held at the international Plone-Conferences in Arnhem and Brasilia. The documentation for these can be found at http://starzel.github.io/training

As always, we give the training as a team of two Trainers. This way you'll receive a 1on1 training as soon as something works differently than expected. Something that is not possible with a single trainer and something that adds a lot of insight when something did not work as expected.

If you're interested call us at +49 (0)89 - 189 29 533 or send a mail to

Date:
26. - 28. May 2014

Time:
9:00 - 18:00

Location:
EineWeltHaus
Schwanthalerstr. 80
80336 München

Trainers:
Philip Bauer
Patrick Gerken

Language:
English

Cost:
EUR 1000.- per person plus 19% MwSt (VAT)
Please talk to us if you might be eligible to a discount (Student, Member of the international Plone-community and so on...)

Photo: https://www.flickr.com/photos/mindonfire/4447448937

Update (20.05.2014):
Due to illnesses we currently have three open slots for the training. Talk to us if you are interested.

We are working hard on updating the training. Here are some highlights:

  • We now use plone.app.contenttypes from the beginning
  • More dexterity-types (without grok)
  • Custom search using eea.facetednavigation
  • Infos about debugging
  • We now teach the use of plone.api
  • ...

Extended Mastering Plone Training in Munich in Spring 2015

erstellt von pgerken — zuletzt geändert: 2014-11-11T19:16:14+01:00
We love to teach more than what is possible in two or three days. Because of this, we will offer an extended Plone training in wonderful Munich in spring 2015

When we prepare a training, we always create more material than what we can walk through in the short amount of time we have available.

We decided that we want to offer you more by extending the training period to 5 days. In 5 days we can cover the material deeper have more exercises and additional topics.

The additional topics include:

  • How to work with relations
  • How to test everything using plone.app.testing and robot-framework
  • Building forms and control-panels with z3c.form

We would love to have you with us.

More information is available on our dedicated training page.

Update: By popular demand we moved this training from november 2014 to 2. - 6. March 2015. We will  inform everyone who contacted us about the training about the new date.  

How to handle unknown meta_type in GS

erstellt von pgerken — zuletzt geändert: 2013-05-15T09:21:27+01:00
We were lost when supporting multiple Plone versions with generic setup and the typeinfo step. Soon there won't be the Topic type any more. Removing declarations for the Topic type and leaving users of old Plone-Versions behind is no option. We found a way to handle it in a single profile.

Our package collective.noticeboard should work with somewhat older Plone sites and new and shiny ones that ditch AT in favor of using DX all the way down.

Therefore we must declare an available view for Topics even though Topics might not exist in the targeted Plone sites.

Trying to import our profile in such a case results in a traceback like that:

Module Products.GenericSetup.utils, line 509, in _importBody
Module Products.CMFCore.exportimport.typeinfo, line 210, in _importNode
Module Products.GenericSetup.utils, line 570, in _initObjects
- __traceback_info__: ('Topic', '')
ValueError: unknown meta_type ''

We don't want to create confusion by adding multiple profiles and we don't want to enable different profiles in zcml based on import statements, because if you have a Topic or not is decided during runtime.

Fortunately there is an undocumented feature hidden in GS: You can declare your type declaration as deprecated. This way, GS does not try to initialize the object and does not try to create the type information object if it does not exist.

Be careful about this directive, this works for the typeinfo step, you have to test, if it does not miss important actions when used in other steps.

This is our new types.xml:

<?xml version="1.0"?>
<object name="portal_types"
        meta_type="Plone Types Tool">

    <object name="Folder"/>
    <object name="Topic" deprecated="True"/>
    <object name="Collection"/>
    <object name="Plone Site"/>

</object>

Sprinting towards Plone 5

erstellt von Philip Bauer zuletzt geändert: 2017-03-01T12:22:06+01:00
The drive towards Plone 5 is gaining momentum as the goal seems to be in a reachable distance.

For the first time there actually is a state of Plone 5 that is can be shown to people who are interested in the future of Plone. The essential building-blocks of Plone 5 are starting to look presentable: The new barceloneta-theme is really nice and comes with the new toolbar and the new widgets.

Don't get me wrong, there is still quite some work to be done before a final release but the first alpha-release is in the making and the current state can actually be shown. These screenshots are from a fresh build of the coredev.buildout.

plone5-left-2.png plone5-top-2.png plone5-edit-2.png

To reach Plone 5 the Plone-community is organizing a staggering number of sprints. My sprint-plan for 2014 looks like this: Cologne, Munich, Munich (again), Sorrento, Berlin, Bristol.

I recently attended the cathedral-sprint in Cologne, organized by the tireless Timo Stollenwerk and generously sponsored by GFU Cyrus AG. Timo, whose sole purpose in life sometimes seems to be to keep Jenkins happy, organized another impressive display of the spirit of the Plone-community as 30 people from around the world gathered there to work in groups on pushing Plone 5 towards readiness. It is great to see so many originally separate efforts coming together smoothly and making a whole new thing that will be at the core of Plone 5.

Together with Johannes Raggam, Wolfgang Thomas and some help from others I was continuing the work on plone.app.contenttypes and we made good progress. The current version 1.1b2 of the new default-content-types for Plone 5 has a multitute of bugfixes and some relevant changes compared to version 1.0:

  • Collections are now a behavior that can be enabled on any content-type. The collection-type is basically a folder with that behavior.
  • The shiny new event-type now uses the behaviors provided by plone.app.event including support for recurring events and timezones.
  • Richtext-fields are now a behavior shared by most types.
  • We now have migrations from 14 different content types to the new types including migrations for four (!) iterations of the event-type.

I have been using plone.app.contenttypes since before the project officially existed and I think every plone-developer should give it a try and report any issues especially regarding migrations to make it safe to ship with Plone 5.

It was a real pleasure being reunited with old friends and making new ones. It is especially encouraging that even at sprints there are always new people showing up and contributing to Plone.

The next big sprint on my agenda is the Wine-and-Beer-Sprint in Munich. For the second time we are organizing this sprint together with our friends from Syslab.com and again it is a double-sprint with a leg in Munich and one in Capetown. We will continue working towards Plone 5. The necessary tasks to get Plone 5 out of the door are summarized in this ticket: https://github.com/plone/Products.CMFPlone/issues/184.

Register now since we only have a limited amount of places! If you really need additional incentive to attend, here they come: A fine selection of Single Malt Whiskeys, a great sprint-location that is accessible 24h, Sichuan Hot Pot and white sausages (not to be mixed).

The Wine and Beer-sprint is is preceded by the DocSprint (also in Munich) that focuses on consolidating, improving and versioning(!) the documentation for Plone.

See you in Munich and elsewhere!