Advanced features

Managing schema generations

Renaming persistent classes

PyAMS provides zodbupdate script to update easily update the change in ZODB. Because, when you develop new features to PyAMS we sometimes have to rename or modify classes of already stored objects and if you do that you will never access yours objects.

To rename classes of existing objects:

1) Include you package in the require resource for you webapp

requires = [
    'mypackage',
    ...
]

2) Add the Entry points

In the setup.py file add ‘zodbupdate’ params into entry_points where is store zodbupdate directives

entry_points={
    'zodbupdate': [
        'renames = mypackage.generations:RENAMED_CLASSES'
    ]
}

3) Create a module named generation with the migration directives

RENAMED_CLASSES = {
    'mypackage.mymodule MyOldClass': 'mypackage.mymodule MyNewClass'
}

4) Run the commands buildout .

$ mypackage/bin/buildout
$ webapp/bin/buildout

The buildout command going to install correctly the package and add the new entry_points references in entry_points.txt

5) Run the commands zodbupdate

To finish run zodbupdate to apply the changes describe in RENAMED_CLASSES

$   bin/zodbupdate --config etc/zodbupdate-zeo.conf

Where zodbupdate-zeo.conf is the configuration file to access to the ZODB.

Including SQLAlchemy

Using GIS features

Internationalization

Internationalization is the process of developing your plugin so it can easily be translated into other languages It’s called also i18n (because there are 18 letters between the i and the n)

Introduction to Gettext

For i18n gettext libraries and tools is widely used in the open-source world.

Here is how it works in a few sentences:

Developers wrap translatable strings in special gettext functions Special tools parse the source code files and extract the translatable strings into POT (Portable Objects Template) files. Translators translate the strings and the result is a PO file (POT file, but with translations inside) PO files are compiled to binary MO files, which give faster access to the strings at run-time

In source code the _() function which refers to the native gettext-compliant translation function.

PyAMS help us to generated this translation file with the tool pot-create:

pot-create -o ref.pot <path/to/sources>

Example to update PyAMS package:

#bin/pot-create -o src/<package>/locales/.pot src/
#msgmerge -U --previous --sort-by-file  src/<package>/locales/fr/LC_MESSAGES/ref.po src/<package>/locales/ref.pot
#msgfmt  src/<package>/locales/fr/LC_MESSAGES/ref.po -o src/<package>/locales/fr/LC_MESSAGES/ref.mo