equal
deleted
inserted
replaced
125 datastore_types.Text: entity_pb.PropertyValue.kstringValue, |
125 datastore_types.Text: entity_pb.PropertyValue.kstringValue, |
126 type(None): 0, |
126 type(None): 0, |
127 unicode: entity_pb.PropertyValue.kstringValue, |
127 unicode: entity_pb.PropertyValue.kstringValue, |
128 users.User: entity_pb.PropertyValue.kUserValueGroup, |
128 users.User: entity_pb.PropertyValue.kUserValueGroup, |
129 } |
129 } |
|
130 |
|
131 WRITE_ONLY = entity_pb.CompositeIndex.WRITE_ONLY |
|
132 READ_WRITE = entity_pb.CompositeIndex.READ_WRITE |
|
133 DELETED = entity_pb.CompositeIndex.DELETED |
|
134 ERROR = entity_pb.CompositeIndex.ERROR |
|
135 |
|
136 _INDEX_STATE_TRANSITIONS = { |
|
137 WRITE_ONLY: frozenset((READ_WRITE, DELETED, ERROR)), |
|
138 READ_WRITE: frozenset((DELETED,)), |
|
139 ERROR: frozenset((DELETED,)), |
|
140 DELETED: frozenset((ERROR,)), |
|
141 } |
130 |
142 |
131 def __init__(self, |
143 def __init__(self, |
132 app_id, |
144 app_id, |
133 datastore_file, |
145 datastore_file, |
134 history_file, |
146 history_file, |
792 value_pb.mutable_referencevalue().set_app('') |
804 value_pb.mutable_referencevalue().set_app('') |
793 |
805 |
794 for name, value_pb in props.items(): |
806 for name, value_pb in props.items(): |
795 prop_pb = kind_pb.add_property() |
807 prop_pb = kind_pb.add_property() |
796 prop_pb.set_name(name) |
808 prop_pb.set_name(name) |
|
809 prop_pb.set_multiple(False) |
797 prop_pb.mutable_value().CopyFrom(value_pb) |
810 prop_pb.mutable_value().CopyFrom(value_pb) |
798 |
811 |
799 kinds.append(kind_pb) |
812 kinds.append(kind_pb) |
800 self.__schema_cache[app_kind] = kind_pb |
813 self.__schema_cache[app_kind] = kind_pb |
801 |
814 |
836 def _Dynamic_UpdateIndex(self, index, void): |
849 def _Dynamic_UpdateIndex(self, index, void): |
837 stored_index = self.__FindIndex(index) |
850 stored_index = self.__FindIndex(index) |
838 if not stored_index: |
851 if not stored_index: |
839 raise apiproxy_errors.ApplicationError(datastore_pb.Error.BAD_REQUEST, |
852 raise apiproxy_errors.ApplicationError(datastore_pb.Error.BAD_REQUEST, |
840 "Index doesn't exist.") |
853 "Index doesn't exist.") |
841 elif index.state() != stored_index.state() + 1: |
854 elif (index.state() != stored_index.state() and |
|
855 index.state() not in self._INDEX_STATE_TRANSITIONS[stored_index.state()]): |
842 raise apiproxy_errors.ApplicationError( |
856 raise apiproxy_errors.ApplicationError( |
843 datastore_pb.Error.BAD_REQUEST, |
857 datastore_pb.Error.BAD_REQUEST, |
844 "cannot move index state from %s to %s" % |
858 "cannot move index state from %s to %s" % |
845 (entity_pb.CompositeIndex.State_Name(stored_index.state()), |
859 (entity_pb.CompositeIndex.State_Name(stored_index.state()), |
846 (entity_pb.CompositeIndex.State_Name(index.state())))) |
860 (entity_pb.CompositeIndex.State_Name(index.state())))) |