aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndré Erdmann <dywi@mailerd.de>2013-09-12 18:29:57 +0200
committerAndré Erdmann <dywi@mailerd.de>2013-09-12 18:29:57 +0200
commitea52078df34aab6562e49a73844e295d934a440d (patch)
treec88e5be7f7e10fd8b91c1053d71d2ee40d80228c /roverlay/util
parentroverlay/fsutil: get fs dict from os.walk() (diff)
downloadR_overlay-ea52078df34aab6562e49a73844e295d934a440d.tar.gz
R_overlay-ea52078df34aab6562e49a73844e295d934a440d.tar.bz2
R_overlay-ea52078df34aab6562e49a73844e295d934a440d.zip
roverlay/util/objects, NoneRef: get_static()
Diffstat (limited to 'roverlay/util')
-rw-r--r--roverlay/util/objects.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/roverlay/util/objects.py b/roverlay/util/objects.py
index a20b707..5ba2d69 100644
--- a/roverlay/util/objects.py
+++ b/roverlay/util/objects.py
@@ -66,6 +66,16 @@ class SafeWeakRef ( weakref.ref ):
class NoneRef ( object ):
"""A 'reference' to None (compat object)."""
+ __instance = None
+
+ @classmethod
+ def get_static ( cls, obj=None ):
+ assert obj is None
+ if cls.__instance is None:
+ cls.__instance = cls ( obj=obj )
+ return cls.__instance
+ # --- end of get_static (...) ---
+
def __init__ ( self, obj=None ):
super ( NoneRef, self ).__init__()
assert obj is None
@@ -101,7 +111,7 @@ def get_object_ref ( obj ):
* obj --
"""
if obj is None:
- return NoneRef()
+ return NoneRef.get_static()
elif isinstance ( obj, ( SafeWeakRef, NoneRef, weakref.ref ) ):
return obj
elif hasattr ( obj, 'get_ref' ):