Update signals.rst for Python 3 compatibility

The send_to_slack example was not compatible with Python 3. Example is updated using the requests & json libraries (instead of urllib & urllib2)
pull/6075/head
GTpyro 2020-05-20 20:55:45 -05:00 zatwierdzone przez Martin Sandström
rodzic a7ddb056b8
commit 147fda12fa
2 zmienionych plików z 3 dodań i 5 usunięć

Wyświetl plik

@ -463,6 +463,7 @@ Contributors
* Brylie Christopher Oxley
* Lacey Williams Henschel
* Dan Bentley
* GTpyro
Translators
===========

Wyświetl plik

@ -26,8 +26,7 @@ example showing how you might notify your team when something is published:
.. code-block:: python
from wagtail.core.signals import page_published
import urllib
import urllib2
import requests
# Let everyone know when a new page is published
@ -41,9 +40,7 @@ example showing how you might notify your team when something is published:
"icon_emoji": ":octopus:"
}
data = urllib.urlencode(values)
req = urllib2.Request(url, data)
response = urllib2.urlopen(req)
response = requests.post(url, values)
# Register a receiver
page_published.connect(send_to_slack)