@@ -516,18 +516,13 @@ def delete_file(file_id):
516
516
517
517
518
518
@cache .memoize ()
519
- def get_config (key ):
519
+ def get_app_config (key ):
520
520
value = app .config .get (key )
521
- if value :
522
- if value and value .isdigit ():
523
- return int (value )
524
- elif value and isinstance (value , six .string_types ):
525
- if value .lower () == 'true' :
526
- return True
527
- elif value .lower () == 'false' :
528
- return False
529
- else :
530
- return value
521
+ return value
522
+
523
+
524
+ @cache .memoize ()
525
+ def get_config (key ):
531
526
config = Config .query .filter_by (key = key ).first ()
532
527
if config and config .value :
533
528
value = config .value
@@ -774,7 +769,7 @@ def update_check(force=False):
774
769
775
770
776
771
def export_ctf (segments = None ):
777
- db = dataset .connect (get_config ('SQLALCHEMY_DATABASE_URI' ))
772
+ db = dataset .connect (get_app_config ('SQLALCHEMY_DATABASE_URI' ))
778
773
if segments is None :
779
774
segments = ['challenges' , 'teams' , 'both' , 'metadata' ]
780
775
@@ -826,7 +821,7 @@ def export_ctf(segments=None):
826
821
backup_zip .writestr ('db/alembic_version.json' , result_file .read ())
827
822
828
823
# Backup uploads
829
- upload_folder = os .path .join (os .path .normpath (app .root_path ), get_config ('UPLOAD_FOLDER' ))
824
+ upload_folder = os .path .join (os .path .normpath (app .root_path ), app . config . get ('UPLOAD_FOLDER' ))
830
825
for root , dirs , files in os .walk (upload_folder ):
831
826
for file in files :
832
827
parent_dir = os .path .basename (root )
@@ -838,7 +833,7 @@ def export_ctf(segments=None):
838
833
839
834
840
835
def import_ctf (backup , segments = None , erase = False ):
841
- side_db = dataset .connect (get_config ('SQLALCHEMY_DATABASE_URI' ))
836
+ side_db = dataset .connect (get_app_config ('SQLALCHEMY_DATABASE_URI' ))
842
837
if segments is None :
843
838
segments = ['challenges' , 'teams' , 'both' , 'metadata' ]
844
839
@@ -924,7 +919,7 @@ def import_ctf(backup, segments=None, erase=False):
924
919
entry_id = entry .pop ('id' , None )
925
920
# This is a hack to get SQlite to properly accept datetime values from dataset
926
921
# See Issue #246
927
- if get_config ('SQLALCHEMY_DATABASE_URI' ).startswith ('sqlite' ):
922
+ if get_app_config ('SQLALCHEMY_DATABASE_URI' ).startswith ('sqlite' ):
928
923
for k , v in entry .items ():
929
924
if isinstance (v , six .string_types ):
930
925
match = re .match (r"\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d" , v )
0 commit comments