vasuporov / snapboard

Automatically exported from code.google.com/p/snapboard
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

global name 'SnapboardProfile' is not defined #19

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
revision 166 (with patches from issues 16-18), django revision 4934

getting the following error when attempting to load up the default view for
the app:

Request Method:     GET
Request URL:    http://www.example.com:8080/forum/
Exception Type:     NameError
Exception Value:    global name 'SnapboardProfile' is not defined
Exception Location:     /src/example/snapboard/managers.py in
get_user_query_set, line 107

Looking at this, there's the following import at the top of the managers
module:

from models import *

Which brings in all the models for use.  However, the model classes
themselves don't get imported:

> python manage.py shell
Python 2.4.4 (#1, Jan  1 2007, 20:38:41) 
[GCC 3.4.4 [FreeBSD] 20050518] on freebsd6
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from snapboard import managers
>>> dir(managers)
['Group', 'Http404', 'HttpResponse', 'HttpResponseRedirect',
'HttpResponseServerError', 'InvalidPage', 'Manager', 'ObjectPaginator',
'PhotoField', 'PostManager', 'Q', 'RequestContext', 'ThreadManager',
'User', '__builtins__', '__doc__', '__file__', '__name__', 'datetime',
'decorators', 'dispatcher', 'forms', 'login', 'logout', 'models',
'redirect_to', 'render_to_response', 'sets', 'settings', 'signals',
'simplejson', 'threadlocals', 'validators']
>>>                      

I'm still digging into it.   If I had to venture a guess right now though,
it has to do with circular imports.  

Example:

 * managers.py imports models.py for models like Post.
 * models.py in turn imports managers.py to add ThreadManager as the
manager for Thread and PostManager as the manager for Post.
 * managers.py never actually gets the models (not sure why yet).
 * 

Original issue reported on code.google.com by johnnie....@gmail.com on 6 Apr 2007 at 12:34

GoogleCodeExporter commented 8 years ago
 I put a dir() in get_user_query_set and it shows only ['self', 'user']. I added a 'from models import 
SnapboardProfile' and all was well. I also needed to add a import for WatchList 
to  get_favorites and an import 
Post to get_private. I'm not really a python guru but it does seem that these 
imports shouldn't be required.

Original comment by crispywa...@gmail.com on 8 Apr 2007 at 9:15

GoogleCodeExporter commented 8 years ago
These recent errors have been introduced due to an internal reorganization (I 
moved
all SQL logic out of views.py and into managers.py).  I'll apply the patches 
I've
recieved and do a review.

Original comment by bs1...@gmail.com on 9 Apr 2007 at 10:47

GoogleCodeExporter commented 8 years ago
circular import bug, fixed

seems to be okay in rev 168

Original comment by bs1...@gmail.com on 12 Apr 2007 at 8:58

GoogleCodeExporter commented 8 years ago

Original comment by bs1...@gmail.com on 12 Apr 2007 at 8:58

GoogleCodeExporter commented 8 years ago
Verified in rev 168.  

Original comment by johnnie....@gmail.com on 12 Apr 2007 at 10:03