Improving the CRUD functions and other clean up.
This commit is contained in:
@@ -34,6 +34,7 @@ def create_hosted_file_obj(hosted_file_obj_new:Hosted_File_Base):
|
||||
|
||||
|
||||
# ### BEGIN ### API Hosted File Methods ### load_hosted_file_obj() ###
|
||||
# Updated 2023-08-18
|
||||
@logger_reset
|
||||
def load_hosted_file_obj(
|
||||
hosted_file_id: int|str,
|
||||
@@ -44,7 +45,7 @@ def load_hosted_file_obj(
|
||||
enabled: str = 'enabled', # enabled, disabled, all
|
||||
inc_hosted_file_link_list: bool = False,
|
||||
) -> Hosted_File_Base|dict|bool:
|
||||
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
|
||||
if hosted_file_id := redis_lookup_id_random(record_id_random=hosted_file_id, table_name='hosted_file'): pass
|
||||
@@ -53,7 +54,6 @@ def load_hosted_file_obj(
|
||||
if hosted_file_rec := sql_select(table_name='v_hosted_file', record_id=hosted_file_id): pass
|
||||
elif hosted_file_rec is None: return None
|
||||
else: return False
|
||||
|
||||
log.debug(hosted_file_rec)
|
||||
|
||||
try:
|
||||
@@ -61,25 +61,16 @@ def load_hosted_file_obj(
|
||||
except ValidationError as e:
|
||||
log.error(e.json())
|
||||
return False
|
||||
# log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.info(f'Filename: {hosted_file_obj.filename}; Size: {hosted_file_obj.size}; Hash SHA256: {hosted_file_obj.hash_sha256}; ')
|
||||
log.debug(hosted_file_obj)
|
||||
|
||||
# if inc_x:
|
||||
# x_id = hosted_file_rec.get('x_id', None)
|
||||
# if x_obj_result := load_x_obj(x_id=x_id):
|
||||
# x_obj = x_obj_result
|
||||
# hosted_file_obj.x = x_obj
|
||||
# else: hosted_file_obj.x = None
|
||||
|
||||
if model_as_dict:
|
||||
return hosted_file_obj.dict(by_alias=by_alias, exclude_unset=exclude_unset) # pylint: disable=no-member
|
||||
return hosted_file_obj.dict(by_alias=by_alias, exclude_unset=exclude_unset)
|
||||
else:
|
||||
return hosted_file_obj
|
||||
# ### END ### API Hosted File Methods ### load_hosted_file_obj() ###
|
||||
|
||||
|
||||
|
||||
|
||||
# ### BEGIN ### API Hosted File Methods ### lookup_file_hash() ###
|
||||
# Updated 2022-08-09
|
||||
@logger_reset
|
||||
|
||||
Reference in New Issue
Block a user