Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython
INSTALL>
pypm install archetypes.languagebugfix

How to install archetypes.languagebugfix

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install archetypes.languagebugfix
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
1.0.2 Available View build log
Windows (64-bit)
1.0.2 Available View build log
Mac OS X (10.5+)
1.0.2 Available View build log
Linux (32-bit)
1.0.2 Available View build log
Linux (64-bit)
1.0.2 Available View build log
 
License
GPL
Dependencies
Lastest release
version 1.0.2 on Jan 5th, 2011

Archetypes Language Field Bug Fix

Introduction

archetypes.languagebugfix package aims to fix an issue with the default vocabulary for ExtensibleMetadata language field in Archetypes.

This issue affects only contents created in languages which code are in the form lc-cc(lc, language code; cc, contry code) and its effects appear when you have a Lingua Plone installation and a combined language code is used as default language for the site -- translations losing their reference to canonical versions of the content.

Keep in mind this package is to be used until an Archetypes version with the proper fix is released, so, probably there won't be another release.

Testing the issue

Let's setup our basic test variables:

>>> from Products.CMFPlone.utils import getToolByName
>>> self.loginAsPortalOwner()
>>> portal = self.portal
>>> lt = getToolByName(portal,'portal_languages')
>>> pp = getToolByName(portal,'portal_properties')

This issue is related to the vocabulary used for the language field on the default Archetypes types. The vocabulary field does not display combined language codes, even when this option is set on portal_languages.

The default ExtensibleMetadata language field uses the method 'languages' as vocabulary, so we will create a new content and check the returned values.

>>> id = portal.invokeFactory(type_name='Document',id='foo', title='Foo')
>>> foo = portal.foo
>>> languageField = foo.getField('language')
>>> defaultVocabulary = 'languages'
>>> languages = getattr(foo,defaultVocabulary)()

Then we enable combined language codes on our portal. Also we set pt-br as default language and disable "Start as Neutral":

>>> defaultLanguage = 'pt-br'
>>> supportedLanguages = ['pt-br', 'en','de','no']
>>> lt.manage_setLanguageSettings(defaultLanguage,

System Message: ERROR/3 (<string>, line 50)

Inconsistent literal block quoting.

... supportedLanguages, ... setUseCombinedLanguageCodes=True, ... startNeutral=False)

After setting portal_languages to allow combined language codes we should get a large number of languages from the vocabulary, but it doesn't happen as we have the same results:

>>> foo = portal.foo
>>> languageField = foo.getField('language')
>>> languagesCombined = getattr(foo,defaultVocabulary)()
>>> languages == languagesCombined

System Message: ERROR/3 (<string>, line 62)

Inconsistent literal block quoting.

True

So, we now use our vocabulary method and see we will have the complete language list:

>>> foo = portal.foo
>>> languageField = foo.getField('language')
>>> newVocabulary = 'languagesVoc'
>>> languagesCombined = getattr(foo,newVocabulary)()
>>> languages == languagesCombined

System Message: ERROR/3 (<string>, line 72)

Inconsistent literal block quoting.

False >>> 'pt-br' in languagesCombined True

And if we go back to use only simple language codes

>>> defaultLanguage = 'en'
>>> supportedLanguages = ['en','de','no']
>>> lt.manage_setLanguageSettings(defaultLanguage,

System Message: ERROR/3 (<string>, line 81)

Inconsistent literal block quoting.

... supportedLanguages, ... setUseCombinedLanguageCodes=False, ... startNeutral=False)

It must work as planned:

>>> foo = portal.foo
>>> languageField = foo.getField('language')
>>> newVocabulary = 'languagesVoc'
>>> languagesCombined = getattr(foo,newVocabulary)()
>>> 'pt-br' in languagesCombined

System Message: ERROR/3 (<string>, line 92)

Inconsistent literal block quoting.

False

Installing the fix

If your using a buildout-based installation all you need to do is declare archetypes.languagebugfix in eggs and zcml sections for you instance.

Credits

Development and tests:

System Message: WARNING/2 (<string>, line 106)

Bullet list ends without a blank line; unexpected unindent.

(products at simplesconsultoria dot com dot br)

Efforts to research and fix this issue were sponsored by:

Changelog

1.0.2 (2010-03-13)
  • Explicitly include folder docs [erico_andrei]
1.0.1 (2009-12-17)
  • In some cases our patch is applied after other content types alredy copied the

System Message: WARNING/2 (<string>, line 125)

Bullet list ends without a blank line; unexpected unindent.

original schema from ExtensibleMetadata, so we patched method itself [erico_andrei]

1.0 - (2009-12-17)

System Message: WARNING/2 (<string>, line 132)

Bullet list ends without a blank line; unexpected unindent.

to getLanguageListing [erico_andrei]

Subscribe to package updates

Last updated Jan 5th, 2011

Download Stats

Last month:1

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.