1. Refactoring form objects and database objects to use inheritance and abstract base class for consistency and reduced redundancy.\n2. Contact us page button links updated to resolve error of missing link causing page refresh instead of expected functionality.
This commit is contained in:
BIN
helpers/DEPRECATED/__pycache__/helper_abc.cpython-312.pyc
Normal file
BIN
helpers/DEPRECATED/__pycache__/helper_abc.cpython-312.pyc
Normal file
Binary file not shown.
38
helpers/DEPRECATED/helper_abc.py
Normal file
38
helpers/DEPRECATED/helper_abc.py
Normal file
@@ -0,0 +1,38 @@
|
||||
from abc import abstractmethod
|
||||
from functools import wraps
|
||||
import inspect
|
||||
|
||||
def Interface_ABC(cls):
|
||||
abstract_methods = {}
|
||||
for name, value in vars(cls).items():
|
||||
if getattr(value, '__isabstractmethod__', False):
|
||||
if isinstance(value, classmethod):
|
||||
abstract_methods[name] = 'classmethod'
|
||||
elif isinstance(value, staticmethod):
|
||||
abstract_methods[name] = 'staticmethod'
|
||||
else:
|
||||
abstract_methods[name] = 'method'
|
||||
|
||||
def decorator(subclass):
|
||||
for method, method_type in abstract_methods.items():
|
||||
if not hasattr(subclass, method):
|
||||
raise NotImplementedError(
|
||||
f"'{subclass.__name__}' must implement abstract {method_type} '{method}' from interface '{cls.__name__}'"
|
||||
)
|
||||
|
||||
subclass_value = getattr(subclass, method)
|
||||
|
||||
if method_type == 'classmethod' and not isinstance(subclass_value, classmethod):
|
||||
raise TypeError(f"'{method}' must be a classmethod in '{subclass.__name__}'")
|
||||
elif method_type == 'staticmethod' and not isinstance(subclass_value, staticmethod):
|
||||
raise TypeError(f"'{method}' must be a staticmethod in '{subclass.__name__}'")
|
||||
elif method_type == 'method' and (isinstance(subclass_value, (classmethod, staticmethod)) or inspect.isfunction(subclass_value)):
|
||||
# For normal methods, we accept either functions or methods, as unbound methods are functions in Python 3
|
||||
pass
|
||||
else:
|
||||
raise TypeError(f"'{method}' has incorrect type in '{subclass.__name__}'")
|
||||
|
||||
return subclass
|
||||
|
||||
return decorator
|
||||
|
||||
BIN
helpers/__pycache__/helper_abc.cpython-312.pyc
Normal file
BIN
helpers/__pycache__/helper_abc.cpython-312.pyc
Normal file
Binary file not shown.
Binary file not shown.
@@ -19,13 +19,17 @@ class Helper_App(BaseModel):
|
||||
|
||||
@staticmethod
|
||||
def get_request_data(request):
|
||||
print(f'request={request}')
|
||||
data = {}
|
||||
try:
|
||||
return request.json
|
||||
data = request.json
|
||||
except:
|
||||
try:
|
||||
return request.data
|
||||
data = request.data
|
||||
except:
|
||||
try:
|
||||
return request.form
|
||||
data = request.form
|
||||
except:
|
||||
return {}
|
||||
pass
|
||||
print(f'data={data}')
|
||||
return data
|
||||
Reference in New Issue
Block a user