How to upgrade to Dejavu 1.5 (RC 1)
This document is complete up to rev .
Unit.properties and property_type
Unit.properties was a classmethod, but in  is now a (class-level) list, so don't call it. It takes the place of the old Unit._properties, and should contain the same values as the old Unit._properties.keys().
In , we dropped Unit.property_type(key) in favor of Unit.property(key).type. Then, in , Unit.property was dropped in favor of the uglier but faster and safer getattr(Unit, key). So to get property types you would now write getattr(Unit, key).type.
A missing 'bytes', 'precision', or 'scale' hint implies "use the storage default limit", while a hint of 0 (zero) implies "use no limit if possible". Some of the StorageManagers were inconsistent about this in 1.4.
This was a tuple of UnitProperty objects. In , this changed to be the keys of those UnitProperties. For example, instead of writing identifiers = (Name, Place) you would now write identifiers = ('Name', 'Place'). You aren't *required* to make this change in declaration until 1.6, but the values in identifiers will now be strings whether you declared them that way or not.
In Dejavu 1.4, the coerce method used a builtin type's factory function to coerce user-supplied values to the correct type. In Dejavu 1.5, they still do that, but with some important changes:
- UnitProperties that are of .type decimal.Decimal now quantize incoming values inside coerce. They do this according to .hints['scale'].
- The coerce method of a UnitProperty is now called when retrieving values from storage (not just for user input). This was done to facilitate correctly-quantized decimals throughout.
- Any UnitProperty.default will also be run through the coerce method when set.
In 1.4, all of the database adaptation was done in storage/db.py, mostly in StorageManagerDB and subclasses of it. From  to , the database layer was abstracted and is now modeled independently in storage/geniusql.py. If you had written a custom StorageManager for a database, you'll want to take a look at how the builtin DB SM's have changed to take advantage of geniusql. In particular, the new module allows SQL decompilation and inbound coercion to know the database types of each column, and adjust to them more accurately. The Connection classes, the SQLDecompiler base class, and the three Adapter classes have all moved into geniusql, as well.
The inbound and outbound adapters changed their method names, as well, from "coerce_str" to "coerce_str_to_TEXT", for example. This allows M x N adaptation in both directions. If you want a single method to handle any type, use "any" on one side of the name; for example, "coerce_NUMERIC_to_any".
Finally, the default table name prefix has changed from "djv" to "" (empty string). If you have existing data from 1.4 (or older) and did not set your own prefix, you must either add Prefix = djv to your Storage config, or rename all tables in your deployed database.
Expanded columns removed
This was always a bit of a stretch, and was removed in . If you need to have it back, let me know.
These were attributes of dejavu itself; now they're collected into dejavu.logflags, and have all lost their "LOG" prefix. For example, in Dejavu 1.4 you would write "dejavu.LOGSQL"; in 1.5, write "dejavu.logflags.SQL" instead. There's a new logflags.ERROR value (== 1), by the way (and logflags.IO is now 2, not 1). Arena.logflags now defaults to ERROR + IO.
In addition, I found that passing logflags as an argument to Arena.log was far too slow in production. Therefore, Arena.log now takes a single 'msg' argument, and each caller must now do their own logflag testing. For example, if you had written arena.log("DROP DATABASE", dejavu.SQL) you must now write:
if arena.logflags & logflags.SQL: arena.log("DROP DATABASE")
The recur module saw some minor changes. The biggest is that sane_date traded fixMonth=False for highzero=False, which works differently. So if you call sane_date(..., True) anywhere, you should check to make sure it still does what you expect.
The Worker class was also refactored, pulling out a separate Scheduler class. Worker objects now do not manage their own cycle; they merely run() in the current thread or start(secs) a separate Timer thread. Create a Scheduler(workers) object and call its start method to continuously cycle a single worker or a set of workers.
In Dejavu 1.4, the unit, recall, and xrecall methods of Sandboxes would automatically retrieve Units of all subclasses of the given class. In 1.5, you must now call these with inherit=True if you want subclasses to be automatically retrieved.
The ProxyStorage class and all its subclasses (CachingProxy, BurnedProxy) have a 'nextstore' attribute. In Dejavu 1.4, this value was optional, in order to facilitate using a ProxyStorage object as something of a RAM cache. In Dejavu 1.5, there is a full-blown RAMStorage backend, and therefore no need to keep 'nextstore' optional in the ProxyStorage class (it was a bit buggy anyway). If you were using a ProxyStorage manager for a RAM cache, you should now use a RAMStorage manager instead.
codewalk.Visitor.debug and verbose
The Visitor class and its subclasses (EarlyBinder, LambdaDecompiler, etc.) used to call debug(*messages), and the debug function would check if .verbose was True. In order to save cycles, it no longer does--each caller should check .verbose and call debug only if .verbose is True.
- Moved CrossTab, COUNT, SUM back to the analysis namespace.
- Pushed dejavu.errors and containers back down one level.
- arena.defaultStore doesn't exist anymore; look at Arena.storage to see how each store's classnames attribute is now used to find a default.
- All StorageManager constructors have changed from (name, arena, allOptions) to just (arena, allOptions).
- UnitSequencerNull was renamed to UnitSequencer, and is now the base class for other Unit Sequencers.
- Renamed Unit.adjust to Unit.update. It's also safer now: it will only set known properties.
- Renamed Sandbox.xmulti to _xmulti. You should use recall or xrecall instead.