JulianEberius / SublimeRope

ST2 only, use SublimePythonIDE with ST3: Adds Python completions and some IDE-like functions to Sublime Text 2, through the use of the Rope library
GNU General Public License v2.0
250 stars 26 forks source link

"Go to definition" not working with flask extensions : flask.ext.login #53

Closed mickey06 closed 11 years ago

mickey06 commented 11 years ago

My project settings contain :+1: { "folders": [ { "path": "/Users/ke/repos/fl-login" } ], "settings": { "rope_autoimport_modules": [ "flask.ext.*" ] } }

My python path is set in config.py to prefs.add('python_path', '/Users/ke/.virtualenvs/flogin/lib/python2.7/site-packages')

DamnWidget commented 11 years ago

Did you regenerate the Global Module Cache?

mickey06 commented 11 years ago

Yes I did.

JulianEberius commented 11 years ago

Hi! It's not working for me either. I already had some problems with flask's way of dealing with extensions in the past. The packages name is flask.ext but the extension files in the site-packages folders are located in site-packages/flaskext ... (flask.ext logically merges these paths together at runtime) I guess Rope gets confused by this layout. I guess the only solution would be to patch Rope to deal with this scenario, which may not be easy.

Julian

klen commented 11 years ago

Flask uses some magic for import plugins. Import flask plugins like this:

Before:

from flask.ext.cache import Cache
from flask.ext.login import current_user
from flask.ext.mail import Mail
...

After:

from flask_cache import Cache
from flask_login import current_user
from flask_mail import Mail

It's different from Flask docs recommendations, but work with Rope very nice.

PS: For oldest plugins (like flask babel) use this form:

from flaskext.babel import Babel
mickey06 commented 11 years ago

It's working. Thanks klen.