Skip to content

Commit

Permalink
Fix render converter
Browse files Browse the repository at this point in the history
  • Loading branch information
radiac committed Dec 7, 2024
1 parent 033f1fc commit 528c22a
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions nanodjango/convert/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,23 @@ def collect_references(self):
self.references = self.visitor.globals_ref

def rewrite_app_render(self):
app_attr_nodes = []
# Go over all app references we found
# Find all app references in this view
dirty = False
for node in self.visitor.globals_lookup.get(self.converter.app._instance_name):
app_nodes = self.visitor.globals_lookup.get(self.converter.app._instance_name)
if not app_nodes:
return

# Find the ones which are app.render calls
app_attr_nodes = []
for node in app_nodes:
attr_node = getattr(node, "attribute_parent", None)

if attr_node and attr_node.attr == "render":
app_attr_nodes.append(attr_node)
else:
dirty = True

# Try to clean up - we don't want any app references
if dirty:
print(f"Unexpected reference to `app` in view {self.name}")
elif app_attr_nodes:
Expand Down

0 comments on commit 528c22a

Please sign in to comment.