getpelican / pelican

Static site generator that supports Markdown and reST syntax. Powered by Python.
https://getpelican.com
GNU Affero General Public License v3.0
12.55k stars 1.81k forks source link

signals.content_object_init.connect not working as described in docs #1711

Closed bkfunk closed 9 years ago

bkfunk commented 9 years ago

The docs suggest adding a sender parameter when connecting the content_object_init signal. However, when I do that, just copying the example in the docs, nothing happens. When I just put the method name, with no additional argument, the signal appears to be sent correctly. Searching through the plugins repo, it appears that none of the plugins use the additional sender argument as suggested in the docs. Is this functionality no longer there? If so, the docs should be corrected.

The relevant section of the documentation:

The signal content_object_init can send a different type of object as the argument. If you want to register only one type of object then you will need to specify the sender when you are connecting to the signal.

from pelican import signals
from pelican import contents

def test(sender, instance):
        print "%s : %s content initialized !!" % (sender, instance)

def register():
        signals.content_object_init.connect(test, sender=contents.Article)
ingwinlu commented 9 years ago

@bbinet why did you break that functionality in https://github.com/getpelican/pelican/commit/ed907b4094c49d5014716bca82a77265bcc49091 ?

//edit: break was the wrong word, since the original implementation was 'strange' to begin with. I think that example from the docs just needs to get removed, if you want to know what instance sent the signal you can test sender

ingwinlu commented 9 years ago

we actually have a test in place for that signal, but it is fairly useless as it does not check if the signal actually gets called... https://github.com/getpelican/pelican/blob/master/pelican/tests/test_contents.py#L193