-
-
Notifications
You must be signed in to change notification settings - Fork 513
Maximum recursion depth exceeded #340
Comments
Looks like this is a common issue. (I searched for the recursion depth and nothing came up.) @mattupstate I can reopen that PR which will at least give a more appropriate error message that you're working outside of the current app context, or we could just raise a custom exception explicitly? Thoughts? |
+1 |
Is there a reason that you simply couldn't do |
I get this recursion problem when using |
@bbenne10 @mcs07 the issue with setting |
@nfvs it won't be. see this comment from last year. the fact that |
@eriktaubeneck awesome lookup skills, I have modified my PR accordingly :) |
👍 |
It seems like the one-line fix could instead be:
That will make |
+1
With Flask-Security there will be infinite loop with getattr when using this pattern. I was able to get it working this way:
this could be stupid way, but at least it is working for me. |
As @eriktaubeneck and @diginikkari said, Flask-Social now dont support flask factory pattern. Also there is manual for it.
[Update 1] Old test: it was my setup problem, now tests fail only for py33, some _ssl3 stuff, w8 for package update. |
👍 this hits us too for the time being we have to
when we init, and
instead of using the decorator patten |
I have searched for the old issues and found that the author has explained here and here in #141 that the constructor and if app is not None and datastore is not None:
self._state = self.init_app(app, datastore, **kwargs)
else:
self._state = None @diginikkari The proper way for initialize is that accessing attributes by from celery import Celery
from flask import Flask
from flask_security import Security, .. datastore stuff ..
from flask_mail import Mail
celery = Celery()
mail = Mail()
security = Security()
def create_app(config):
"""Initialize Flask instance."""
app = Flask(__name__)
mail.init_app(app)
security_ctx = security.init_app(app,..datastore stuff..)
@security_ctx.send_mail_task
def delay_flask_security_mail(msg):
send_flask_mail.delay(msg)
return app |
Looks like this was fixed in #703. |
If the
security
object gets initialized before theapp
exists (i.e. using the factory method) andinit_app
is called later,security._state
is never set. This makes sense because_state
is dependent upon theapp
, however, when an attribute onsecurity
is accessed, the redefinition of__getattr__
looks for_state
, which isn't set, so__getattr__
get's called, looks for_state
, etc, and then bamI opened a PR, but closed it because I'm not sure if it's the right fix. I solved the issue myself by doing:
but at the very least, I think there should be a better exception that gets raised (the max recursion depth really threw me off for a bit.) The solution in the PR would work, but would require the above to become something like
which maybe works? Curious what other people think is a good solution.
The text was updated successfully, but these errors were encountered: