# MiddleKit 0.8 Release Notes

Version 0.8
Webware for Python 0.8

## Changes

- The ObjectStore keeps track of new objects, modified objects and to-be-deleted objects on a per-thread basis. This prevents the ObjectStore from trying to save the same changes twice, and prevents the situation where one thread commits an object which a different thread modified (and wasn't necessarily ready to commit).

  This new tracking is enabled when your ObjectStore is in "Threaded" mode, which is enabled by default. You can run in single-threaded mode by adding the following line to the Settings.config file in your model directory:

      'Threaded': 0,

  The behaviour of the following methods has changed:

  - saveChanges() - commits only objects which were modified by the current thread

  New ObjectStore methods:

  - hasChangesForCurrentThread() - returns whether the store has any uncommitted changes for the current thread

  - saveAllChanges() - commits all added/modified/deleted objects to the database, regardless of which thread made the changes. This could be called on application exit just to be extra safe.

    When using MiddleKit from WebKit, though, you be calling saveChanges() at the end of any request which modifies MK objects, so I recommend putting

        assert not store.hasChangesForCurrentThread()

    into your SitePage.sleep() method to catch programming errors early.

  For upgrading older MiddleKit applications, you'll probably want to replace calls to store.hasChanges() with store.hasChangesForCurrentThread(). Nothing else should need to change.

- A new 'Database' setting in Settings.config. Set this if the model name isn't the same as the database name.
- Also, the database name can be passed via the constructor. See the User's Guide for more info.
- Support for the SQL 'decimal' type, previously found only in the MSSQL adapter, has been brought up to the generic SQL adapter level which means that MySQL inherits it. Use the attribute keys Precision and Scale to specify the precision and scale just like you see in SQL manuals: decimal(precision, scale).

  If (and only if!) you have "legacy" code from the old decimal support, you could enable the UseMaxForDecimalPrecision setting. However, you might get fried down the road when MiddleKit starts enforcing min/max constraints on decimal types. (Getting fried implies you would have to edit/fix your model.)

- "Dangling obj refs" now print much more useful information. The old message:

      WARNING: Obj ref dangles. dec=266287972390  hex=3e00000026  class.obj=Stop.97.

  The new message:

      WARNING: MiddleKit: In object <PendingTrade 'TIVO long 4.25' 129>, attribute
      Trade.initialStop dangles with value Stop.97

  In other words:

      WARNING: MiddleKit: In object <REPR()>, attribute
      FULL ATTR NAME dangles with value CLASS.SERIAL_NUM VALUE

- The Classes.csv text file is now cached as a binary pickle file named Classes.pickle.cache. This reduces subsequent load times by about 40%. The cache will be ignored if it can't be read, is older than the CSV file, has a different Python version, etc. You don't normally even need to think about this, but if for some reason you would like to turn off the use of the cache, you can do so via the UsePickledClassesCache setting.