9331: Empty handle, bsddb backend and place
This commit is contained in:
		| @@ -1588,7 +1588,7 @@ class DbGeneric(DbWriteBase, DbReadBase, UpdateCallback, Callback): | ||||
|         >>> self.get_from_name_and_handle("Person", "a7ad62365bc652387008") | ||||
|         >>> self.get_from_name_and_handle("Media", "c3434653675bcd736f23") | ||||
|         """ | ||||
|         if table_name in self.get_table_func(): | ||||
|         if table_name in self.get_table_func() and handle: | ||||
|             return self.get_table_func(table_name,"handle_func")(handle) | ||||
|         return None | ||||
|  | ||||
|   | ||||
| @@ -211,15 +211,12 @@ class Struct(object): | ||||
|             current = getattr(current, item) | ||||
|         return current | ||||
|  | ||||
|     def get_media_from_handle(self, handle): | ||||
|         return self.db.get_from_name_and_handle(handle.classname, str(handle)) | ||||
|  | ||||
|     def handle_join(self, item): | ||||
|         """ | ||||
|         If the item is a handle, look up reference object. | ||||
|         """ | ||||
|         if isinstance(item, HandleClass) and self.db: | ||||
|             obj = self.get_media_from_handle(item) | ||||
|             obj = self.db.get_from_name_and_handle(item.classname, str(item)) | ||||
|             if obj: | ||||
|                 return Struct(obj.to_struct(), self.db) | ||||
|             else: | ||||
| @@ -263,7 +260,8 @@ class Struct(object): | ||||
|             if struct is None:       # invalid part to set, skip | ||||
|                 return | ||||
|             if isinstance(struct, HandleClass): | ||||
|                 struct = self.get_media_from_handle(struct).to_struct() | ||||
|                 obj = self.db.get_from_name_and_handle(struct.classname, str(struct)) | ||||
|                 struct = obj.to_struct() | ||||
|             # keep track of primary object for update, below | ||||
|             if isinstance(struct, dict) and "_class" in struct and self.primary_object_q(struct["_class"]): | ||||
|                 primary_obj = struct | ||||
|   | ||||
| @@ -716,7 +716,7 @@ class DbBsddbRead(DbReadBase, Callback): | ||||
|         >>> self.get_from_name_and_handle("Person", "a7ad62365bc652387008") | ||||
|         >>> self.get_from_name_and_handle("Media", "c3434653675bcd736f23") | ||||
|         """ | ||||
|         if table_name in self.get_table_func(): | ||||
|         if table_name in self.get_table_func() and handle: | ||||
|             return self.get_table_func(table_name,"handle_func")(handle) | ||||
|         return None | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user