[Dev-flock] contrib.auth attribute errors

Lucy Mendel lucy at thoughtandmemory.org
Wed Apr 30 23:08:13 EDT 2008


this seems to be a path problem, since emulating correct environment
settings seems to make things work.

>>> import sys, os>>> PROJECT_PATH="/var/sites/hm_demo";     >>>
sys.path.insert(0, PROJECT_PATH)>>> os.chdir(PROJECT_PATH)
>>> os.environ['DJANGO_SETTINGS_MODULE'] = "settings"
>>> from django.contrib.auth.models import User
>>> from django.contrib import auth
>>> dir(auth);
['BACKEND_SESSION_KEY', 'ImproperlyConfigured', 'REDIRECT_FIELD_NAME',
'SESSION_KEY', '__builtins__', '__doc__', '__file__', '__name__',
'__path__', 'authenticate', 'datetime', 'get_backends', 'get_user',
'load_backend', 'login', 'logout', 'models']
>>> auth.models
<module 'django.contrib.auth.models' from
'/usr/lib/python2.4/site-packages/django/contrib/auth/models.pyc'>
>>>

i think i'll be able to figure out where we go wrong settings-wise. woot.

On Wed, Apr 30, 2008 at 10:57 PM, Lucy Mendel <lucy at thoughtandmemory.org> wrote:
> ratings, and possibly other things, don't work because of user
>  authentication. anyone know what the dilly is on this one?
>
>  in the meantime, i'm moving ahead on svn-izing /var/sites/hm_demo (not
>  hm_production, which i think is a dud), or doing whatever is necessary
>  to publish hm_staging to hm_demo.
>
>  here's the problem:
>
>    Python 2.4.4 (#2, Apr  5 2007, 20:11:18)
>    [GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)] on linux2
>    Type "help", "copyright", "credits" or "license" for more information.
>  >>> from django.contrib import auth;
>  >>> dir(auth);
>    ['BACKEND_SESSION_KEY', 'ImproperlyConfigured',
>  'REDIRECT_FIELD_NAME', 'SESSION_KEY',
>     '__builtins__', '__doc__', '__file__', '__name__', '__path__',
>  'authenticate', 'datetime', 'get_backends',
>    'get_user', 'load_backend', 'login', 'logout']
>  >>> auth.models
>    Traceback (most recent call last):
>      File "<stdin>", line 1, in ?
>    AttributeError: 'module' object has no attribute 'models'
>
>  here are the details:
>  user clicks on a star in order to rate a review. the user can be
>  logged in or be anonymous; same error:
>
>  POST fails (yay firebug, boo viewing html in plain text)
>
>  Request URL:  http://thoughtandmemory.org/Main/add_behavior_rating/
>
>  AttributeError': module' object has no attribute 'models'
>
>  /var/sites/hm_demo/db/utils.py in current_user, line 87
>  def current_user():
>     """
>     @summary:
>
>     @return:
>     @rtype:
>
>     @raise UserNotAuthenticated:
>     """
>     user = threadlocals.get_current_user()
>     if isinstance(user, auth.models.User):    <<<<<<<< line 87
>         return user
>     else:
>         return auth.models.User.objects.all()[0]
>         #raise UserNotAuthenticated()
>



More information about the Dev-flock mailing list