Skip to content

Commit

Permalink
fix(drw): Correct broken link when same object is rendered twice.
Browse files Browse the repository at this point in the history
  • Loading branch information
vinci1it2000 committed Nov 19, 2023
1 parent 5bdfebf commit fff5c5b
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions schedula/utils/drw/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,15 +159,26 @@ def site_view(
'alive_url': 'alive' in app.view_functions and app.url_for('alive')
}
render_ctx.update(app.jinja_env.globals)
if not osp.isfile(osp.join(static_folder, filepath)):
fpath = osp.join(static_folder, filepath)
if not osp.isfile(fpath):
if filepath not in rules:
from flask import abort
return abort(404)

rdir = osp.dirname(fpath)
directory = None
node = rules[filepath]
for v in cached_view(
rules[filepath], static_folder, context, rendered, viz,
executor, **render_ctx).values():
v.result()
node, static_folder, context, rendered, viz, executor,
**render_ctx).values():
fp = v.result()
if directory is None:
directory = osp.dirname(fp)
if fp != fpath:
shutil.copy(fp, fpath)

if directory != rdir:
shutil.copy(fp, osp.join(rdir, osp.relpath(fp, directory)))

return app.send_static_file(filepath)


Expand Down Expand Up @@ -207,10 +218,7 @@ def __init__(

@property
def name(self):
try:
return parent_func(self.item).__name__
except AttributeError:
return self.node_id
return self.node_id

@property
def view_id(self):
Expand Down

0 comments on commit fff5c5b

Please sign in to comment.