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.

27Jan/105

Password protected auto login on Ubuntu : auto lock screen after login

If you have one single user on your Ubuntu box and want to allow auto login to speed up boot process and avoid typing your user name every time you boot, but feel concerned about security, this is for you.

In fact, if auto login is activated, everybody can turn on your box and use it. This is even more annoying when you have a laptop.

To prevent that, you can lock the screen as soon as gnome desktop gets started. This will lock your screen, but Ubuntu will load in background while you type in your pass, so there is no time loss.

Here we go :

  • First activate auto login in Ubuntu :
    Go in Ubuntu Menu > System > Administration > Login Window and select a user for auto login
  • Then add auto lock at Gnome start up :
    press Alt + F2
    type "gedit .profile"
    paste following lines at the end of the file :

    if [ !"$AUTOLOGINDONE" ]
    then
        export AUTOLOGINDONE=true
        gnome-screensaver
        gnome-screensaver-command --lock
        gnome-screensaver-command --poke
    fi
  • Save the file and restart your computer, the system will auto login and ask for password while finishing loading Gnome.
26Jan/100

Aero Snap feature for Ubuntu

Windows 7 came with some good UI features like Aero Snap.

Here's how to make it available on Ubuntu :

First you need compiz config settings manager and wmctrl. The first is used to configure compiz and add custom commands like snap to the left, right or top. The second to change size and state of active window.
Type this in your shell to install those packages :

sudo apt-get install compizconfig-settings-manager wmctrl

Next you need to add some custom commands in compiz that will snap the window :Open ConpizConfig Settings Manager
Click on the Commands button
Enter following three lines respectively in command 0, command 1 and command 2:

wmctrl -r :ACTIVE: -b remove,maximized_horz && WIDTH=`xdpyinfo | grep 'dimensions:' | cut -f 2 -d ':' | cut -f 1 -d 'x'` && HALF=$(($WIDTH/2)) && wmctrl -r :ACTIVE: -b add,maximized_vert && wmctrl -r :ACTIVE: -e 0,0,0,$HALF,-1
wmctrl -r :ACTIVE: -b remove,maximized_horz && WIDTH=`xdpyinfo | grep 'dimensions:' | cut -f 2 -d ':' | cut -f 1 -d 'x'` && HALF=$(($WIDTH/2)) && wmctrl -r :ACTIVE: -b add,maximized_vert && wmctrl -r :ACTIVE: -e 0,$HALF,0,$HALF,-1
wmctrl -r :ACTIVE: -b add,maximized_vert,maximized_horz

Finally you must activate those three commands when you click respectively to the left edge, the right edge and the top edge of the screen.
Click on Button Bindings tab
Activate Run command 0 by pressing Deactivated button right of it, click on Activate, select left edge and validate
Activate Run command 1 by pressing Deactivated button right of it, click on Activate, select right edge and validate
Activate Run command 2 by pressing Deactivated button right of it, click on Activate, select top edge and validate

Close CompizConfig, open a random window and click to the left, top or right edge to enjoy window snapping on Ubuntu.

31Oct/090

Enhance PuTTY user interface

PuTTY's user interface is limited if you compare it to Gnome's Terminal. No tabs, no color schemes, ...

So I searched for mods or add-ons that could make it a better tool.

I won't list them all, but just point out the useful ones.

PuTTY Connection Manager

PuTTY Connection Manager

PuTTY Connection Manager

I tried it and now can't do without it ! It is the killer add-on  for PuTTY.

It gathers PuTTY instances in a common interface using tabs and dockable windows (see screenshot taken from author's site above).

It has extra features like automatic login, connection manager, import/export, see full list here.

You can download it from here.

PuTTY Tray

PuTTY Tray Logo

This one adds tray minimize to tray feature to PuTTY but I don't use it for that as I use it with PuTTY connection manager. The features I like are auto-reconnection (after network connection failure or computer wake-up from stand-by or hibernation) and hyper-links support.

It can be used as portable application too by storing sessions configuration in files (to use it from an USB key).

You can download it from here.

PuTTY color schemes

PuTTY comes with a bad color scheme. Default standard blue is quite difficult to read on default black background.

Some color schemes are available on the web to correct this, you can google for them or look here for some samples (the igvita-light.reg looks just perfect for me).

They are available as .reg files that need to be imported using regedit.

17Oct/094

Restore Windows boot option in grub 2 menu after installing Ubuntu Karmic Koala 9.10

After installing Ubuntu Karmic Koala 9.10, grub 2 doesn't detect whether windows is installed or not (at least it did not for me), so you can't boot windows any more.

To fix this, there is a tool called grub-mkconfig that generates automatically a grub configuration file in /boot/grub/grub.cfg by detecting which operating systems are installed on your box.

To re-generate grub.cfg and install it as boot loader configuration, follow below instructions :

sudo grub-mkconfig -o /boot/grub/grub.cfg
# edit grub.cfg and look if there is non-ascii characters (accentuated ones) in labels, if so, replace them with ascii characters
sudo nano /boot/grub/grub.cfg
#replace /dev/sda with the device where grub boot loader should be installed
sudo grub-install /dev/sda
sudo grub-install --recheck /dev/sda

Reboot your computer.

Now a line that allows you to boot your Windows installation should appear in grub's menu.

7Sep/090

Fix Compiz memory leak on Ubuntu Jaunty Jackalope 9.04 with Intel graphic cards

There's a memory leak in Compiz when you are using UXA mode for Intel graphic cards driver. After a few hours, Compiz eats all available memory and the system crash.

To prevent this you must change some Compiz startup options :

Open a console and type

sudo vim /usr/bin/compiz

Round line 74 replace the line ...

COMPIZ_OPTIONS="--ignore-desktop-hints --replace"

... by this one

COMPIZ_OPTIONS="--replace --sm-disable --ignore-desktop-hints ccp --indirect-rendering"

This will fix Compiz memory leak, but there seams to be a problem about rendering transparent windows when intirect rendering is activated.

I didn't notice this problem on my configuration. I followed tutorial in ticket Drastically improve Intel graphics performance under Ubuntu Jackalope 9.04 before, this might help... or not.

For further informations you can read this bug report, especially comment 17.

25Aug/090

Drastically improve Intel graphics performance under Ubuntu Jackalope 9.04

The new Ubuntu Jackalope 9.04 has some performance issues with the EXA acceleration method of Intel graphic cards due to actual Kernel. This causes poor 2D performance (eg in Compiz).

There is no available fixes atm in Ubuntu Jackalope repositories but you can update to kernel 2.6.30.3 and configure your Intel graphic device following instructions on this page : HOWTO: Jaunty Intel Graphics Performance Guide.

I used "Optimal configuration" on a Dell Vostro 220s and noticed a drastic performance improvement, especially in Compiz (even in normal mode).

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
5Aug/093

Using Microsoft’s Browser Test VMs in Virtual Box

Edit : this solution no longer works with latest Microsoft's vm :( .

If you are a web developer, you may have noticed that Microsoft's browser test virtual machines don't work out of the box in Sun VirtualBox.

Here's a step-by-step how-to you can follow to make them work like a charm : Using Microsoft's Browser Test VMs in Virtual Box