Unable to monkey patch openwisp_network_topology.admin.TopologyAdmin

26 views
Skip to first unread message

Ajay Tripathi

unread,
Jan 29, 2020, 5:19:37 PM1/29/20
to OpenWISP
I want to monkey patch TopologyAdmin to change `receive_url` function,
for that, I want to access TopologyAdmin.receive_url_querystring_arg,

However, I get 
```
AttributeError: type object 'TopologyAdmin' has no attribute 'receive_url_querystring_arg'
```

1. I created a new django project
3. Do the following commands in `python manage.py shell`
```
from openwisp_utils.admin import ReceiveUrlAdmin
from openwisp_network_topology.admin import TopologyAdmin
TopologyAdmin.receive_url_querystring_arg
```

I tried the same thing inside the network-topology's manage.py shell and it worked.
Is there a different way to access it from a different project?




Thanks,
Ajay Tripathi

Federico Capoano

unread,
Jan 30, 2020, 4:16:19 AM1/30/20
to OpenWISP
I advice against monkey patching, we did a lot of clean up lately and if we go back to shortcuts we'll soon be filled again with a lot of maintenance work.

I think we should make the change in the modules to accommodate the deployment we're implementing in docker-openwisp.
Better to invest in that rather than monkey patching, don't you think? Can you open an issue in openwisp-utils please?

Can you also open issues to resolve the several monkey patching or additions done in docker-openwisp so we allow to do those things in the base openwisp modules?
For example, the celery beat tasks that replicate the management commands. If we create issues I'm sure new contributors over time will help us out in case we don't have time to do all of those.

Federico

--
You received this message because you are subscribed to the Google Groups "OpenWISP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openwisp+u...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/openwisp/8666004c-0b8b-44ee-a30b-20844e064ecb%40googlegroups.com.

Ajay Tripathi

unread,
Jan 30, 2020, 8:29:23 AM1/30/20
to OpenWISP
Hi,


On Thursday, January 30, 2020 at 2:46:19 PM UTC+5:30, Federico Capoano wrote:
I advice against monkey patching, we did a lot of clean up lately and if we go back to shortcuts we'll soon be filled again with a lot of maintenance work.

Better to invest in that rather than monkey patching, don't you think? Can you open an issue in openwisp-utils please?

I didn't think that it could be useful for other modules as well, hence I was monkey patching.
I have opened a PR in openwisp-utils for the same.

Just FYI, finally, the issue why monkey patching was not working is because `receive_url` function was recently moved to openwisp-utils and I completely forgot about it. 



Thanks,
Ajay Tripathi

Federico Capoano

unread,
Feb 23, 2020, 1:07:38 PM2/23/20
to OpenWISP
Reply all
Reply to author
Forward
0 new messages