This commit is contained in:
mohammed-alkhazrji 2025-12-07 13:19:55 +03:00
parent 329ba55823
commit b9aa096d82
1 changed files with 16 additions and 2 deletions

View File

@ -13,13 +13,12 @@ _logger = logging.getLogger(__name__)
_map_view_validator = None _map_view_validator = None
@view_validation.validate('map') @view_validation.validate('map')
def schema_map_view(arch, **kwargs): def schema_map_view(arch, **kwargs):
global _map_view_validator global _map_view_validator
if _map_view_validator is None: if _map_view_validator is None:
with misc.file_open(os.path.join('odex30_web_map', 'views', 'odex30_web_map.rng')) as f: with misc.file_open('odex30_web_map/views/odex30_web_map.rng') as f:
_map_view_validator = etree.RelaxNG(etree.parse(f)) _map_view_validator = etree.RelaxNG(etree.parse(f))
if _map_view_validator.validate(arch): if _map_view_validator.validate(arch):
@ -28,3 +27,18 @@ def schema_map_view(arch, **kwargs):
for error in _map_view_validator.error_log: for error in _map_view_validator.error_log:
_logger.error(ustr(error)) _logger.error(ustr(error))
return False return False
# @view_validation.validate('map')
# def schema_map_view(arch, **kwargs):
# global _map_view_validator
#
# if _map_view_validator is None:
# with misc.file_open(os.path.join('odex30_web_map', 'views', 'odex30_web_map.rng')) as f:
# _map_view_validator = etree.RelaxNG(etree.parse(f))
#
# if _map_view_validator.validate(arch):
# return True
#
# for error in _map_view_validator.error_log:
# _logger.error(ustr(error))
# return False