thirdparty/google_appengine/google/appengine/api/datastore_file_stub.py
changeset 1278 a7766286a7be
parent 828 f5fd65cc3bf3
child 2273 e4cb9c53db3e
--- a/thirdparty/google_appengine/google/appengine/api/datastore_file_stub.py	Thu Feb 12 10:24:37 2009 +0000
+++ b/thirdparty/google_appengine/google/appengine/api/datastore_file_stub.py	Thu Feb 12 12:30:36 2009 +0000
@@ -128,6 +128,18 @@
     users.User: entity_pb.PropertyValue.kUserValueGroup,
     }
 
+  WRITE_ONLY = entity_pb.CompositeIndex.WRITE_ONLY
+  READ_WRITE = entity_pb.CompositeIndex.READ_WRITE
+  DELETED = entity_pb.CompositeIndex.DELETED
+  ERROR = entity_pb.CompositeIndex.ERROR
+
+  _INDEX_STATE_TRANSITIONS = {
+    WRITE_ONLY: frozenset((READ_WRITE, DELETED, ERROR)),
+    READ_WRITE: frozenset((DELETED,)),
+    ERROR: frozenset((DELETED,)),
+    DELETED: frozenset((ERROR,)),
+  }
+
   def __init__(self,
                app_id,
                datastore_file,
@@ -794,6 +806,7 @@
         for name, value_pb in props.items():
           prop_pb = kind_pb.add_property()
           prop_pb.set_name(name)
+          prop_pb.set_multiple(False)
           prop_pb.mutable_value().CopyFrom(value_pb)
 
         kinds.append(kind_pb)
@@ -838,7 +851,8 @@
     if not stored_index:
       raise apiproxy_errors.ApplicationError(datastore_pb.Error.BAD_REQUEST,
                                              "Index doesn't exist.")
-    elif index.state() != stored_index.state() + 1:
+    elif (index.state() != stored_index.state() and
+          index.state() not in self._INDEX_STATE_TRANSITIONS[stored_index.state()]):
       raise apiproxy_errors.ApplicationError(
         datastore_pb.Error.BAD_REQUEST,
         "cannot move index state from %s to %s" %