Skip to content

Request is None when child calls a parent's method #579

@hendi

Description

@hendi
class ParentView(UnicornView): def mount(self): print("parent mount: request=", self.request) def foo(self): print("parent foo: request=", self.request) class ChildView(UnicornView): def mount(self): print("child mounted, parent=", self.parent) def foo(self): print("calling parent.foo()") self.parent.foo()

Calling the child's foo method (e.g. by clicking a button in the child component) prints in the terminal:

parent mount: request= <WSGIRequest: GET '/parent'> child mounted, parent= <unicorn.components.parent.ParentView object at 0x7fe536d3ad90> calling parent.foo() parent foo: request= None # <-- request is None 

If the parent's foo method is called directly from the component, its request is set.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions