I’m trying to use Anvil Extras Messaging to pass a message from a row template to the parent form. I thought I’d got my head around it but clearly not.
The idea is that clicking a link in the row template deletes the item (this bit works) and this sends a message. In the parent form the message handler refreshes the form.
What I’ve tried and what’s not working:
I have module named ‘common’ in which a Publisher is created
from anvil_extras.messaging import Publisher
publisher = Publisher()
In the row template (RowTemplate5) I import the publisher
from ...common import publisher
and I have a handler for the link_click which tries to publish the message
@handle("lnkDeleteAccount", "click")
def lnkDeleteAccount_click(self, **event_args):
un = self.item['username']
fn = self.item['forename']
sn = self.item['surname']
ar = alert("Are you sure you want to delete the member " + fn + ' ' + sn + " (" + un + ")", large=True, title='Delete Member?', buttons=[('Yes','y'),('No','n')])
if ar == 'y':
pass
#delete the user
rowtodelete = app_tables.users.get(username=un)
rowtodelete.delete()
#delete yns
self.RemoveYNs(un)
#refresh main form
88 publisher.publish(channel="Members", title="Member Deleted")
When I click the link the code in the handler runs, deleting the record I want deleted. but the attempt to publish the message fails with this error:-
TypeError: 'NoneType' object is not callable
at app/anvil_extras/messaging.py:52called from frmAdminMembers.RowTemplate5, line 88
Can anyone see what I’m doing wrong?
Clone link:
share a copy of your app