@@ -402,6 +402,7 @@ def ping() -> flask.Response:
402402@routes .route (schemas_dict ["kill" ]["route" ], methods = schemas_dict ["kill" ]["methods" ])
403403def kill () -> flask .Response :
404404 print ("Manual server kill, shutting down..." , flush = True )
405+ utils_functions .teardown_request (flask .current_app )
405406 os ._exit (0 )
406407 return flask .make_response ({"message" : "Flask server is dead" }, 200 )
407408
@@ -425,7 +426,7 @@ def export_project() -> flask.Response:
425426 export_vease_path = os .path .join (project_folder , filename )
426427
427428 with get_session () as session :
428- rows = session .query (Data .id , Data .input_file , Data . additional_files ).all ()
429+ rows = session .query (Data .id , Data .native_file ).all ()
429430
430431 with zipfile .ZipFile (
431432 export_vease_path , "w" , compression = zipfile .ZIP_DEFLATED
@@ -434,21 +435,12 @@ def export_project() -> flask.Response:
434435 if os .path .isfile (database_root_path ):
435436 zip_file .write (database_root_path , "project.db" )
436437
437- for data_id , input_file , additional_files in rows :
438+ for data_id , native_file in rows :
438439 base_dir = os .path .join (project_folder , data_id )
439440
440- input_path = os .path .join (base_dir , str (input_file ))
441- if os .path .isfile (input_path ):
442- zip_file .write (input_path , os .path .join (data_id , str (input_file )))
443-
444- for relative_path in (
445- additional_files if isinstance (additional_files , list ) else []
446- ):
447- additional_path = os .path .join (base_dir , relative_path )
448- if os .path .isfile (additional_path ):
449- zip_file .write (
450- additional_path , os .path .join (data_id , relative_path )
451- )
441+ native_path = os .path .join (base_dir , str (native_file ))
442+ if os .path .isfile (native_path ):
443+ zip_file .write (native_path , os .path .join (data_id , str (native_file )))
452444
453445 zip_file .writestr ("snapshot.json" , flask .json .dumps (params .snapshot ))
454446
@@ -523,17 +515,17 @@ def import_project() -> flask.Response:
523515 if os .path .isfile (vpath ):
524516 continue
525517
526- input_file = str (data .input_file or "" )
527- if not input_file :
518+ native_file = str (data .native_file or "" )
519+ if not native_file :
528520 continue
529521
530- input_full = geode_functions .data_file_path (data .id , input_file )
531- if not os .path .isfile (input_full ):
522+ native_full = geode_functions .data_file_path (data .id , native_file )
523+ if not os .path .isfile (native_full ):
532524 continue
533525
534526 geode_object = geode_functions .geode_object_from_string (
535527 data .geode_object
536- ).load (input_full )
528+ ).load (native_full )
537529 utils_functions .save_all_viewables_and_return_info (
538530 geode_object , data , data_path
539531 )
@@ -546,3 +538,48 @@ def import_project() -> flask.Response:
546538 except KeyError :
547539 snapshot = {}
548540 return flask .make_response ({"snapshot" : snapshot }, 200 )
541+
542+
543+ @routes .route (
544+ schemas_dict ["geode_object_inheritance" ]["route" ],
545+ methods = schemas_dict ["geode_object_inheritance" ]["methods" ],
546+ )
547+ def geode_object_inheritance () -> flask .Response :
548+ json_data = utils_functions .validate_request (
549+ flask .request , schemas_dict ["geode_object_inheritance" ]
550+ )
551+ params = schemas .GeodeObjectInheritance .from_dict (json_data )
552+ geode_object_type = params .geode_object_type
553+ target_class = geode_functions .geode_object_from_string (geode_object_type )
554+
555+ def get_all_bases (geode_class : type ) -> set [type ]:
556+ bases = set ()
557+ for base_class in geode_class .__bases__ :
558+ if base_class is not object :
559+ bases .add (base_class )
560+ bases .update (get_all_bases (base_class ))
561+ return bases
562+
563+ def get_all_subclasses (geode_class : type ) -> set [type ]:
564+ subclasses = set ()
565+ for subclass_class in geode_class .__subclasses__ ():
566+ subclasses .add (subclass_class )
567+ subclasses .update (get_all_subclasses (subclass_class ))
568+ return subclasses
569+
570+ # Extract all related Geode classes (parents and children)
571+ base_classes = get_all_bases (target_class )
572+ subclass_classes = get_all_subclasses (target_class )
573+
574+ # Filter GeodeObjectType to only include registered related objects, excluding target
575+ parents = []
576+ children = []
577+ for geode_object_type_str , geode_class in geode_objects .items ():
578+ if geode_class == target_class :
579+ continue
580+ if geode_class in base_classes :
581+ parents .append (geode_object_type_str )
582+ if geode_class in subclass_classes :
583+ children .append (geode_object_type_str )
584+
585+ return flask .make_response ({"parents" : parents , "children" : children }, 200 )
0 commit comments