From 8f75a9133fae3a75f459aa5314934bb58db042e5 Mon Sep 17 00:00:00 2001
From: Nico Schottelius <nico@brief.schottelius.org>
Date: Mon, 13 Feb 2012 10:38:36 +0100
Subject: [PATCH] do not fail validation on empty object_id

Signed-off-by: Nico Schottelius <nico@brief.schottelius.org>
---
 lib/cdist/core/cdist_object.py | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/lib/cdist/core/cdist_object.py b/lib/cdist/core/cdist_object.py
index f425ca60..3c2de01b 100644
--- a/lib/cdist/core/cdist_object.py
+++ b/lib/cdist/core/cdist_object.py
@@ -166,13 +166,15 @@ class CdistObject(object):
         Remove leading and trailing slash (one only)
         """
 
-        # Remove leading slash
-        if self.object_id[0] == '/':
-            self.object_id = self.object_id[1:]
+        # Allow empty object id for singletons
+        if self.object_id:
+            # Remove leading slash
+            if self.object_id[0] == '/':
+                self.object_id = self.object_id[1:]
 
-        # Remove trailing slash
-        if self.object_id[-1] == '/':
-            self.object_id = self.object_id[:-1]
+            # Remove trailing slash
+            if self.object_id[-1] == '/':
+                self.object_id = self.object_id[:-1]
 
     # FIXME: still needed?
     @property