django-bower icon indicating copy to clipboard operation
django-bower copied to clipboard

Don't depend on settings.BASE_DIR, maybe?

Open mpasternak opened this issue 11 years ago • 2 comments

Hi,

this is a part of my traceback, package built from today's git checkout:

  File "/var/lib/jenkins/shiningpanda/jobs/5a1cd455/virtualenvs/d41d8cd9/local/lib/python2.7/site-packages/djangobower/conf.py", line 5, in <module>
    COMPONENTS_ROOT = getattr(settings, 'BOWER_COMPONENTS_ROOT', settings.BASE_DIR)
  File "/var/lib/jenkins/shiningpanda/jobs/5a1cd455/virtualenvs/d41d8cd9/local/lib/python2.7/site-packages/django/conf/__init__.py", line 47, in __getattr__
    return getattr(self._wrapped, name)
AttributeError: 'Settings' object has no attribute 'BASE_DIR'

I don't have settings.BASE_DIR so it breaks, even if I have BOWER_COMPONENTS_ROOT defined.

Is there a policy for BASE_DIR in django settings file? Do I need to have it?

On the other hand, what reasonable default can you choose for BASE_DIR? Maybe it is better to break, because djangobower needs to write to filesystem, so we rather have a defined place where it writes instead of assuming something like /tmp...

mpasternak avatar Oct 28 '14 17:10 mpasternak

Newer versions of django include something like this in the autogenerated settings.py:

import os
PROJECT_PATH = os.path.dirname(os.path.abspath(__file__))              

darkpixel avatar Oct 30 '14 19:10 darkpixel

PROJECT_PATH doesn't sound like BASE_DIR te me :-)

I'd just handle the failure more gracefully. I think a traceback with explanation, what does django-bower really need from the settings.py file would be okay.

mpasternak avatar Oct 31 '14 16:10 mpasternak