Draft: WebSite.py: fix find common part logic
while using erp5
with python3
in renderjs interface
, i found that the development mode is broken
the reason is manage_main return something like
<!doctype html>
....
<link rel="stylesheet" type="text/css" href="/erp5/web_site_module/renderjs_runner/bootstrap-4.6.0/bootstrap.min.css" />
<link rel="stylesheet" type="text/css" href="/erp5/web_site_module/renderjs_runner/fontawesome-free-5.15.2/css/all.css" />
<link rel="stylesheet" type="text/css" href="/erp5/web_site_module/renderjs_runner/zmi_base.css" />
<script src="/erp5/web_site_module/renderjs_runner/jquery-3.5.1.min.js"></script>
<script src="/erp5/web_site_module/renderjs_runner/bootstrap-4.6.0/bootstrap.bundle.min.js"></script>
<script src="/erp5/web_site_module/renderjs_runner/ace.ajax.org/ace.js"></script>
<script src="/erp5/web_site_module/renderjs_runner/zmi_base.js"></script>
<script src="/erp5/web_site_module/renderjs_runner/zmi.localstorage.api.js"></script>
.....
and request to all those files return 404
after some search, it's because in python3
, we use Zope 5.11.1
in this version, the logic to process those files are changed , instead of those in 4.8.11
in the new version, it call physicalPathToURL
, which call then the our custom _physicalPathToVirtualPath
while checking the codes to find the common part
it seems there has a bug when website_path
and path
has nothing common
in our case above,
website_path = ('', 'erp5', 'web_site_module', 'renderjs_runner')
path = ('++resource++zmi', 'bootstrap-4.6.0', 'bootstrap.bundle.min.js')
there has no common part, common_index is already 0
but those codes are still running
if path_len > common_index + 1:
path = website_path + path[common_index + 1:]
finally path = ('', 'erp5', 'web_site_module', 'renderjs_runner', 'bootstrap-4.6.0', 'bootstrap.bundle.min.js')
without ++resource++zmi, thus it can't be found and return 404
@jerome what do you think about the fix ?