[Chandler-dev] chandlerdb updated (0.6-76)

Andi Vajda vajda at osafoundation.org
Tue Jan 23 12:06:44 PST 2007


After your next 'svn update' you need to get the latest chandlerdb version
by running in 'chandler':
      make chandlerdb  - OR -
      make install

This update introduces a new NilValue type that has a few instances, Nil, 
Default and Empty. Empty is the one of interest here. It can be persisted (as 
opposed to Nil which can't be, by design).

Empty is immutable and behaves as a null iterator, sequence and mapping and is 
intended to be used as a default value for collection or ref collection 
attributes. Using Empty as a default value spares code accessing these kinds 
of attributes from having to check that there is a value or that it is not 
None. Since Empty is immutable, code changing the collection attribute still 
needs to check that it holds a mutable collection intead.

Empty is available from the 'chandlerdb.util.c' package.
Empty's type, Nil, is not a subclass of dict or list but behaves like them and 
has some their methods defined. Especially, dict's itervalues()/keys()/items() 
are defined.

len(Empty) always returns 0
blah in Empty always returns False
iter(Empty) always stops right away
Empty.get(key, defaultValue) always returns defaultValue (or None)
Empty[key] always raises KeyError

Empty is a singleton, "item.attribute is Empty" is valid, safe code.

Andi..


More information about the chandler-dev mailing list