getpelican / pelican-plugins

Collection of plugins for the Pelican static site generator
Other
1.38k stars 849 forks source link

[pelican_comment_system] Maximum recursion depth exceeded while using with i18n_subsites #751

Open Regalis opened 8 years ago

Regalis commented 8 years ago

Hi,

I'm getting RecursionError: maximum recursion depth exceeded while calling a Python object while using pelican_comment_system with i18n_subsites.

Steps to reproduce:

Attachments:

@Scheirle

[Edit] Temporary workaround:

  1. Disable feeds
  2. Delete pelican_writer initialization:
diff --git a/pelican_comment_system/pelican_comment_system.py b/pelican_comment_system/pelican_comment_system.py
index 4ecbbe3..9b32adf 100644
--- a/pelican_comment_system/pelican_comment_system.py
+++ b/pelican_comment_system/pelican_comment_system.py
@@ -62,8 +62,8 @@ def pelican_initialized(pelican):
         pelican.settings['PELICAN_COMMENT_SYSTEM_DIR'])
     pelican.settings['ARTICLE_EXCLUDES'].append(
         pelican.settings['PELICAN_COMMENT_SYSTEM_DIR'])
-    global pelican_writer
-    pelican_writer = pelican.get_writer()
+    #global pelican_writer
+    #pelican_writer = pelican.get_writer()

 def initialize(article_generator):
Scheirle commented 8 years ago

The problem is not in the pelican_comment_system. If you use following example plugin in combination with the i18n_subsites plugin you will get the same error.

Example Plugin

# -*- coding: utf-8 -*-

from __future__ import unicode_literals

from pelican import signals

def pelican_initialized(pelican):
    pelican.get_writer()
    print("testplugin init")

def register():
    signals.initialized.connect(pelican_initialized)

The Problem is that the i18n_subsites plugin assumes, that the get_writer signal does only get emitted once per pelican run (if I understand the plugin correctly).[1]

But the Pelican::get_writer[2] method (which emits this signal) is part of the public interface of an pelican object and therefore can be called more than once (e.g. in plugins). Therefore the get_writer signal may be emitted multiple times.

cc: @smartass101

smartass101 commented 8 years ago

Acknowledged. Either we could use a different signal (if such signal exists) or test if this is the 1. call of the signal.Any other suggestions?

smartass101 commented 8 years ago

Seems the all_generators_finalized signal might be a good candidate. It's called almost at the same time and is part of the run method. This signal was apparently added after the creation of this plugin.

justinmayer commented 6 years ago

@smartass101: Any chance you could work on implementing a solution for this?

smartass101 commented 6 years ago

Not in the immediate future, but I think this could be an easy first issues for someone.