Re: Lazy loading

  • Post author:
  • Post category:Uncategorized

Emmanuel: if you are using a language like Python, you can let the language keep track of your state machine for something like that:

def load_items(treeview, liststore, items):
    for obj in items:
        liststore.append((obj.get_foo(),
                          obj.get_bar(),
                          obj.get_baz()))
        yield True
    treeview.set_model(liststore)
    yield False

def lazy_load_items(treeview, liststore, items):
    gobject.idle_add(load_items(treeview, liststore, item).next)

Here, load_items() is a generator that will iterate over a sequence like [True, True, ..., True, False]. The next() method is used to get the next value from the iterator. When used as an idle function with this particular generator, it results in one item being added to the list store per idle call til we get to the end of the generator body where the “yield False” statement results in the idle function being removed.

For a lot of algorithms, this removes the need to design and debug a state machine equivalent. Of course, it is possible to do similar things in C but that’s even more obscure 🙂.

pygpgme 0.1 released

  • Post author:
  • Post category:Uncategorized

Back in January I started working on a new Python wrapper for the GPGME library. I recently put out the first release:

http://cheeseshop.python.org/pypi/pygpgme/0.1

This library allows you to encrypt, decrypt, sign and verify messages in the OpenPGP format, using gpg as the backend. In general, it stays fairly close to the C API with the following changes:

  • Represent C structures as Python classes where appropriate (e.g. contexts, keys, etc). Operations on those data types are converted to methods.
  • The gpgme_data_t type is not exposed directly. Instead, any Python object that looks like a file object can be passed (including StringIO objects).
  • In cases where there are gpgme_op_XXXX() and gpgme_op_XXXX_result() function pairs, these have been replaced by a single gpgme.Context.XXXX() method. Errors are returned in the exception where appropriate.
  • No explicit memory management. As expected for a Python module, memory management is automatic.

The module also releases the global interpreter lock over calls that fork gpg subprocesses. This should make the module multithread friendly.

This code is being used inside Launchpad to verify incoming email and help manage users’ PGP public keys.

In other news, gnome-gpg 0.4 made it into dapper, so users of the next Ubuntu release can see the improvements.

London

  • Post author:
  • Post category:Uncategorized

I’ve been in London for a bit over a week now at the Launchpad sprint. We’ve been staying in a hotel near the Excel exhibition centre in Docklands, which has a nice view of the docs and you can see the planes landing at the airport out the windows of the conference rooms.

I met up with James Bromberger (one of the two main organisers of linux.conf.au 2003) on Thursday, which is the first time I’ve seen him since he left for the UK after the conference.

There has been a lot of interesting stuff going on so far, some of which is already live on the production site now. Expect to see better integration with the bzr branch management features in the future.

Gnome Logo on Slashdot

  • Post author:
  • Post category:Uncategorized

Recently, Jeff brought up the issue of the use of the old Gnome logo on Slashdot. The reasoning being that since we decided to switch to the new logo as our mark back in 2002, it would be nice if they used that mark to represent stories about us.

Unfortunately this request was shot down by Rob Malda, because the logo is “either ugly or B&W (read:Dull)”.

Not to be discouraged, I had a go at revamping the logo to meet Slashdot’s high standards. After all, if they were going to switch to the new logo, they would have done so when we first asked. The result is below:

This is based on an earlier design, but I think the drop shadow really completes the image. Iain managed to come up with a variant suitable for use on the games sub-site.

Gnome-gpg 0.4.0 Released

  • Post author:
  • Post category:Uncategorized

I put out a new release of gnome-gpg containing the fixes I mentioned previously.

The internal changes are fairly extensive, but the user interface remains pretty much the same. The main differences are:

  • If you enter an incorrect passphrase, the password prompt will be displayed again, the same as when gpg is invoked normally.
  • If an incorrect passphrase is stored in the keyring (e.g. if you changed your key’s passphrase), the passphrase prompt will be displayed. Previously you would need to use the --forget-passphrase option to tell gnome-gpg to ignore the passphrase in the keyring.
  • The passphrase dialog is now set as a transient for the terminal that spawned it, using the same algorithm as zenity. This means that the passphrase dialog pops up on the same workspace as the terminal, and can’t be obscured by the terminal.