Skip to content

Commit

Permalink
Now simply use mock settings
Browse files Browse the repository at this point in the history
To use ``nose.vim`` with this script. Add PYTHONPATH in ``.profile``::

    export PYTONPATH="$PYTHONPATH:$HOME/.vim/bundle/vim-django-support/ftplugin/python/lib"
  • Loading branch information
lambdalisue committed Dec 8, 2011
1 parent 96c32a6 commit b6b9916
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 25 deletions.
19 changes: 10 additions & 9 deletions ftplugin/python/lib/vim_django_support_mock_project/settings.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# vim: set fileencoding=utf8:
#
# Mock of django settings
import os
ROOT=os.path.dirname(os.path.abspath(__file__))
DEBUG = True
TEMPLATE_DEBUG = DEBUG
ADMINS = (,)
ADMINS = []
MANAGERS = ADMINS
DATABASES = {}
TIME_ZONE = ''
Expand All @@ -17,12 +19,11 @@
SECRET_KEY = ''
STATIC_URL = ''
ADMIN_MEDIA_PREFIX = ''
STATICFILES_DIRS = (,)
STATICFILES_FINDERS = (,)
TEMPLATE_LOADERS = (,)
MIDDLEWARE_CLASSES = (,)
TEMPLATE_CONTEXT_PROCESSORS = (,)
STATICFILES_DIRS = []
STATICFILES_FINDERS = []
TEMPLATE_LOADERS = []
MIDDLEWARE_CLASSES = []
TEMPLATE_CONTEXT_PROCESSORS = []
ROOT_URLCONF = ''
TEMPLATE_DIRS = (,)
INSTALLED_APPS = (,)
LOGGING = {}
TEMPLATE_DIRS = []
INSTALLED_APPS = []
19 changes: 3 additions & 16 deletions ftplugin/python/vim-django-support.vim
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import sys

if sys.version_info[:2] < (2, 5):
raise AssertionError('Vim must be compiled with Python 2.5 or higher; you have ' + sys.version)

# get the directory of this script is in
scriptroot = os.path.dirname(vim.eval('expand("<sfile>")'))
scriptroot = os.path.abspath(scriptroot)
Expand All @@ -29,21 +28,9 @@ def find_django_settings_module(root):
sys.path.insert(0, root)
return "%s.settings" % project_name
if 'DJANGO_SETTINGS_MODULE' not in os.environ:
# try to find settings.py
settings = None
if os.path.exists('settings.py'):
settings = find_django_settings_module('')
elif os.path.exists(u'src'):
files = os.listdir(u'src')
for file in files:
file = os.path.join('src', file)
if os.path.exists(os.path.join(file, 'settings.py')):
settings = find_django_settings_module(file)
break
if not settings:
# use mock settings
mock = os.path.join(scriptroot, 'lib/vim_django_support_mock_project')
settings = find_django_settings_module(mock)
# use mock settings
mock = os.path.join(scriptroot, r'lib/vim_django_support_mock_project')
settings = find_django_settings_module(mock)
os.environ['DJANGO_SETTINGS_MODULE'] = settings
# Now try to load django.db. Without this code, pythoncomplete doesn't work correctly
try:
Expand Down

0 comments on commit b6b9916

Please sign in to comment.