Fixed an exception when composite_key is not defined for an object
diff --git a/xos/core/models/plcorebase.py b/xos/core/models/plcorebase.py
index 68c9c12..377bf19 100644
--- a/xos/core/models/plcorebase.py
+++ b/xos/core/models/plcorebase.py
@@ -30,7 +30,7 @@
         if value is not None:
             value = value.strip()
         return super(StrippedCharField, self).clean(value, *args, **kwds)
-            
+
 
 # This manager will be inherited by all subclasses because
 # the core model is abstract.
@@ -152,7 +152,7 @@
     write_protect = models.BooleanField(default=False)
 
     # XXX Django has no official support for composite primray keys yet
-    # so we will hack in an inefficient solution here.  
+    # so we will hack in an inefficient solution here.
     composite_primary_key = []
 
     class Meta:
@@ -186,34 +186,40 @@
             super(PlCoreBase, self).delete(*args, **kwds)
         else:
             if (not self.write_protect):
-                    self.deleted = True
-                    self.enacted=None
-                    self.save(update_fields=['enacted','deleted'], silent=silent)
+                self.deleted = True
+                self.enacted=None
+                self.save(update_fields=['enacted','deleted'], silent=silent)
 
     def check_composite_primary_key(self):
-        if not self.composite_primary_key:
-            return 
+        try:
+            composite_key_exists = self.composite_primary_key
+        except AttributeError:
+            composite_key_exists = False
+
+            if (not composite_key_exists):
+                return
+
         # dictionary containing cpk field name and value
         cpk_fields = dict([(name, getattr(self, name)) for name in self.composite_primary_key])
         objs = self.__class__.objects.filter(**cpk_fields)
-        # we can only continue if there are no matches or 
-        # if this record is updating itself         
+        # we can only continue if there are no matches or
+        # if this record is updating itself
         if (len(objs) == 0 or
             (len(objs) == 1 and self.id and objs[0].id == self.id)):
-            return 
-        # if we reach this point then we've matched more than 1 
-        # existing record or we are trying to  
+            return
+        # if we reach this point then we've matched more than 1
+        # existing record or we are trying to
         msg = "%s violates composite primray key constraint on fields: %s " % (self, self.composite_primary_key)
         raise db.Error, msg
-                 
-               
+
+
     def save(self, *args, **kwargs):
         # let the user specify silence as either a kwarg or an instance varible
         silent = self.silent
         if "silent" in kwargs:
             silent=silent or kwargs.pop("silent")
 
-        self.check_composite_primary_key()    
+        self.check_composite_primary_key()
 
         super(PlCoreBase, self).save(*args, **kwargs)
 
@@ -245,10 +251,4 @@
 
     @classmethod
     def is_ephemeral(cls):
-	return cls in ephemeral_models
-
-
-
-
-
-
+        return cls in ephemeral_models