Permalink
Browse files

Improve ``node.utils.Unset``. Add ``Unset`` instance at ``node.utils.…

…UNSET``.
  • Loading branch information...
1 parent b3e2d7b commit ca6a4196781658c186453539a723a84a52053970 @rnixx rnixx committed Feb 10, 2013
Showing with 26 additions and 12 deletions.
  1. +1 −1 LICENSE.rst
  2. +5 −1 README.rst
  3. +3 −3 src/node/behaviors/mapping.py
  4. +17 −7 src/node/utils.py
View
@@ -2,7 +2,7 @@
License
=======
-Copyright (c) 2009-2011, BlueDynamics Alliance, Austria
+Copyright (c) 2009-2013, BlueDynamics Alliance, Austria
All rights reserved.
Redistribution and use in source and binary forms, with or without
View
@@ -288,7 +288,10 @@ Changes
0.9.11dev
---------
-- no changes yet.
+- Improve ``node.utils.Unset``. Add ``Unset`` instance at
+ ``node.utils.UNSET``.
+ [rnix, 2013-02-10]
+
0.9.10
------
@@ -297,6 +300,7 @@ Changes
failed.
[rnix, 2012-11-07]
+
0.9.9
-----
@@ -16,7 +16,7 @@
IExtendedWriteMapping,
IFullMapping,
)
-from ..utils import Unset
+from ..utils import UNSET
@implementer(IItemMapping)
@@ -204,14 +204,14 @@ def setdefault(self, key, default=None):
return default
@default
- def pop(self, key, default=Unset):
+ def pop(self, key, default=UNSET):
"""works only if together with ReadMapping
"""
try:
val = self[key]
del self[key]
except KeyError:
- if default is Unset:
+ if default is UNSET:
raise
val = default
return val
View
@@ -11,16 +11,26 @@
class Unset(object):
- """Used to identify unset values in contrast to None
+ """Used to identify unset values in contrast to None.
- use for example by node.behaviors.nodify.Nodify
-
- XXX: instanciate directly here??
- XXX: yafowil contains another unset object, use the one from node
- XXX: call me UNSET as constant?
- UNSET = object()
+ use for example by node.behaviors.nodify.Nodify.
"""
+ def __nonzero__(self):
+ return False
+
+ def __str__(self):
+ return ''
+
+ def __len__(self):
+ return 0
+
+ def __repr__(self):
+ return '<UNSET>'
+
+
+UNSET = Unset()
+
def LocationIterator(object):
"""Iterate over an object and all of its parents.

0 comments on commit ca6a419

Please sign in to comment.