[storm] Storm 0.18 is out!

Gary Poster gary.poster at canonical.com
Tue Oct 26 22:44:51 BST 2010


The Storm team is proud to announce Storm 0.18!

The new release includes a number of new features:

 * Storm includes (optional) code to manage and migrate database schemas
 * storm.zope.testing added testresources
   (https://edge.launchpad.net/testresources) support
 * TimeoutErrors include messages to describe why the Timeout was raised

This release includes official packages for all supported releases
of Ubuntu except 10.10.  10.10 packages will be added after problems with
Storm's release machinery are sorted out.  The packages are available in the
Storm team's PPA:

 https://edge.launchpad.net/~storm/+archive/ppa

You can find the release files at:

 https://launchpad.net/storm/+download

You can always get the latest source code from Launchpad:

 bzr branch lp:storm

Finally, you can join us in the #storm channel on irc.freenode.net
and on the Storm mailing list:

 https://lists.canonical.com/mailman/listinfo/storm

Read on for more...


Code to manage and migrate database schemas
-------------------------------------------

The new ``storm.schema`` package includes a generalized version of the code
used by the Landscape team for their schemas.

The ``Schema`` class can be used to ``create``, ``drop``, ``delete`` and
``upgrade`` database schemas.  A ``Store`` may have a single schema.  The
schema is defined by the series of SQL statements that should be used to
create, drop and clear the schema, respectively; and by a patch package used
to upgrade it.

A patch package is simply a Python package that contains files for each patch
level in the series.  Each file must be  named ``patch_N.py``, where ``N`` is
the numeric version of the patch in the series (using ascending natural
numbers).  The patch files must define an ``apply`` callable taking a
``Store`` instance as its only argument. This will be called when the patch
gets applied.

Here's an example, where ``patch_package`` is a Python module
containing database patches used to upgrade the schema over time, and
``store`` is a Storm ``Store``:

>>> from storm.schema import Schema
>>> creates = ['CREATE TABLE person (id INTEGER, name TEXT)']
>>> drops = ['DROP TABLE person']
>>> deletes = ['DELETE FROM person']
>>> import patch_package
>>> schema = Schema(creates, drops, deletes, patch_package)
>>> schema.upgrade(store)

While you can use the schema's ``create`` method separately, ``upgrade`` is
sufficient alone.  It will create the schema if it does not exist, and
otherwise will run unapplyed patches to an existing schema.  Note that this
approach therefore expects the "creates" SQL (that is, the second line of the 
example above) to be maintained alongside patches--it should be *equivalent*
to running all patches.

storm.zope.testing added testresources support
----------------------------------------------

If you would like to use testresources
(https://edge.launchpad.net/testresources) with your Storm tests, a
storm.zope.testing.ZStormResourceManager class to manage a set of stores
registered with ZStorm is now available.  It can be used roughly like this::

    from testresources import ResourcedTestCase
    from storm.zope.testing import ZStormResourceManager
    from storm.schema import Schema

    name = "test"
    uri = "sqlite:"
    schema = Schema(...)
    manager = ZStormResourceManager({name: (uri, schema)})

    class MyTest(ResourcedTestCase):

        resources = [("zstorm", manager)]

        def test_stuff(self):
            store = self.zstorm.get("test")
            store.execute(...)

Comparable expressions (such as Column and Alias) provide new
startswith(), endswith() and contains_string() methods.  These
methods perform prefix, suffix and substring comparisons using LIKE.
Strings used with these methods are automatically escaped.

Detailed changelog
------------------

Improvements
------------
 - Include code to manage and migrate database schemas.  See the
   storm.schema sub-package (bug #250412).
 - Added a storm.zope.testing.ZStormResourceManager class to manage a
   set of stores registered with ZStorm (bug #618704).
 - When a TimeoutError is raised it includes a description about why
   the exception was raised, to help make it easier to reason about
   timeout-related issues (bug #617973).
 - Improved the IResultSet interface to document the rationale of why some
   attributes are not included (bug #659883).

Bug fixes
---------
 - Make storm compatible with psycopg2 2.2 (bug #585704).
 - Fix bug #620615, which caused lazy expressions to cause subsequent
   loading of objects to explode if unflushed.
 - Fix bug #620508, which caused slicing a ResultSet to break subsequent
   count() calls.
 - Fix bug #659708, correcting the behavior of the sqlobject is_empty
   and __nonzero__ methods.
 - Fix bug #619017, which caused __storm_loaded__ to be called without
   its object's variables defined if the object were in the alive cache but
   disappeared.


More information about the storm mailing list