Jonathan Riboux – Technical Blog Python, Zope, Plone and more

25May/100

Gemstone theme for Plone 4

Gemstone theme for plone 4 screenshotThis week end i've just tried to create a theme for Plone 4 to see what's different from theming Plone 3.

Theming plone 4 is not so different, you just have to deal with the new theme and with the Deco CSS framework, no big deal.

For more informations about Plone 4 theming, see http://www.noenieto.com/blog/theming-plone-4 and http://www.noenieto.com/blog/theming-plone-4-part-2 . If you want to adapt an existing Plone 3 theme to Plone 4, you can read http://plone.org/.../updating-plone-3-themes-for-plone-4 .

Here is the theme I created : http://pypi.python.org/pypi/plonetheme.gemstone

It has only been tested on IE8 and FF3.x and need Plone 4 to work. This has been done in one day of work so don't blame me if there is some bugs. Feel free to report issues or to contribute.

5Aug/090

Generate pot files for all development eggs

With the following script, you can generate pot files for each egg in development in your Zope/Plone project.

It creates three pot files per egg

  • [EGG_NAME]-generated.pot : generated from the egg sources using i18ndude
  • [EGG_NAME]-extra.pot : empty pot generated if it doesn't exist, you can put your extra msgid/msgstr
  • [EGG_NAME].pot : merged from generated and extra

Requirements

  • egg must have a locales subdirectory
  • i18n domain used in the egg must have the same name as the egg
  • i18ndude must be installed

generate_i18n.sh

#!/bin/sh
 
# Change this to the path containing your
SRC="src"
 
for EGG_NAME in `ls $SRC`
do
  EGG_SUBDIR=`echo $EGG_NAME|sed "s/\./\//g"`
  EGG_DIR=`echo $SRC/$EGG_NAME/$EGG_SUBDIR`
  LOC_DIR=`echo $EGG_DIR/locales`
 
  if [ -d $LOC_DIR ]; then
    echo "========================================"
    echo "Found locales in $EGG_DIR"
    echo "Generating pot..."
    # Make sure pot files exist, create them if not
    touch $LOC_DIR/$EGG_NAME-generated.pot
    touch $LOC_DIR/$EGG_NAME-extra.pot
    # Create pot generated from sources
    i18ndude rebuild-pot --pot $LOC_DIR/$EGG_NAME-generated.pot --create $EGG_NAME $SRC/$EGG_NAME
    # Merge it with the extra pot (manual one) and create the final pot
    cp $LOC_DIR/$EGG_NAME-generated.pot $LOC_DIR/$EGG_NAME.pot
    i18ndude merge --pot $LOC_DIR/$EGG_NAME.pot --merge $LOC_DIR/$EGG_NAME-extra.pot
  fi
done
5Aug/090

Get all versions of your development eggs

On a big Zope/Plone project with a long list of eggs in development, you must know each version of each egg when you want to release them and configure production / pre-production buildout.

Instead of looking into each egg's VERSION.txt or setup.py, here's a script to list them all. The result can be copy/past in your buildout's version.cfg .

list_versions.py

import stat, os, re
 
re_version = re.compile(r"""^version\s*=\s*(?:"|')(.*?)(?:"|')""", re.MULTILINE|re.DOTALL)
re_name = re.compile(r"""name\s*=\s*(?:"|')(.*?)(?:"|')""", re.MULTILINE|re.DOTALL)
 
def _get_setup(base):
    """returns setup content"""
    setup_py = os.path.join(os.getcwd(), base, 'setup.py')
    return open(setup_py).read()
 
if __name__ == '__main__':
    print 'src versions :\n==============\n\n'
 
    files=os.listdir(".")
    files=[filename for filename in files if filename[0] != '.']
 
    for egg in files:
        if egg[0]=='.':
            continue # ignore hidden files
        try:
            stat_info=os.lstat(egg)
        except:
            continue # bad file
        if not stat.S_ISDIR(stat_info.st_mode):
            continue # ignore files
 
        try:
            setup = _get_setup(egg)
            print '%s = %s'%(re_name.search(setup).group(1), re_version.search(setup).group(1), )
        except:
            continue # prevent crash when setup.py doesn't exist
Tagged as: , , No Comments