Attention

This document was written for an old version of Plone, Plone 3, and was last updated 1012 days ago.

To learn how to upgrade to the current version of Plone, read the upgrade manual.

Make AT Content Type untranslatable with Products.LinguaPlone Installed

by Taito Horiuchi last modified Aug 14, 2009 10:35 PM
With Products.LinguaPlone installed, all the AT Content Types provide ITranslatable interface. This How-to explains the way to get rid of ITranslatable interface to avoid translating the content type.

Purpose

Products.LinguaPlone is one of the best packages for multilingual Plone sites. However, there are use cases where you have content types that are not necessarily translatable or translatability is not desirable. ITranslatable interface is the key interface for this translatablity. Let's get rid of this interface!

Prerequisites

Products.LinguaPlone needs to be installed. This product belongs in the "magical Products namespace" and can be placed directly in your buildout's Products folder, or installed as any other eggs following the instructions of the Managing projects with buildout - Installing a third party product tutorial.

You need to be familiar with AT Content Type creation. See the Archetypes Developer Manual for more info about this topic.

Step by step

Now, as an example, we want to create a MyContentType class inherited from ATFolder. ATContentTypes types are marked with this marking interface upon the installation of LinguaPlone, so if you inherit from any of these types you'll have to remove the interface manually. But please note that this little hack is not neccessary if you inherit directly from Archetypes base classes like BaseContent or BaseFolder.

The two lines within the MyContentType class (in bold) are key lines.

...
from zope.interface import implementedBy, implementsOnly
from Products.ATContentTypes.content import folder
from plone.locking.interfaces import ITTWLockable
from my.package.intefaces import IMyContentType
...

class MyContentType(ATFolder):
    interfaces = [i for i in list(implementedBy(folder.ATFolder)) if i.__name__ != 'ITranslatable']
    implementsOnly(IMyContentType, ITTWLockable, interfaces)
    ...

Explanation

  • list(implementedBy(folder.ATFolder)) gives you a list of implemented interfaces of ATFolder.
  • The implementsOnly method implements only those values given. ITTWLockable is implemented here bacause this content type is lockable through the web. Add more interfaces for your need, adding more interfaces or lists of interfaces as arguments for this method.

This example will hopefully help you apply for similar use cases.


Contribute

Something wrong or out of date? Anybody can edit or create a new article in the knowledge base. Simply create an account on this site, log in, and click the Edit button to contribute.