Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.
  • Root
  • » Django
  • » django/contrib/auth/models.py goes nuts [RSS Feed]

#1 Dec. 23, 2010 02:44:59

John F.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

django/contrib/auth/models.py goes nuts


Hi,
I had a working website for about the last 2 weeks. I was using a test
database (Postgres). I am also using SVN for my code and have tried to revert
back many versions and I still get these new errors.

The error first appeared as datetime has no Attribute 'None' for a line in my
views.py
user = User.objects.create_user(c.registration_id, c.email,
request.POST)

The error was from in django/contrib/auth/models.py
now = datetime.datetime.now()

No datetime?? But the module imports the datetime module at the top. This is
django code and I made no changes to the code.

So I added the following just for testing (just in case I had re-defined
datetime):
try:
now = datetime.datetime.now()
except:
import datetime
now = datetime.datetime.now()

But now in the same module I get a new error:

TypeError: 'NoneType' object is not callable for
salt = get_hexdigest(algo, str(random.random()), str(random.random()))

This is crazy! I can not understand what has happened!

I'm hoping someone understands this better than I do!

Just running
python manage.py runserver
I get a 500.

I'm on openSUSE 11.3, python 2.6.5, django 1.2.3 (was on 1.2.1). I really
need help!

Johnf

--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

#2 Dec. 23, 2010 03:18:28

John F.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

django/contrib/auth/models.py goes nuts


On Wednesday, December 22, 2010 06:44:47 pm John Fabiani wrote:
> Hi,
> I had a working website for about the last 2 weeks. I was using a test
> database (Postgres). I am also using SVN for my code and have tried to
> revert back many versions and I still get these new errors.
>
> The error first appeared as datetime has no Attribute 'None' for a line in
> my views.py
> user = User.objects.create_user(c.registration_id, c.email,
> request.POST)
>
> The error was from in django/contrib/auth/models.py
> now = datetime.datetime.now()
>
> No datetime?? But the module imports the datetime module at the top. This
> is django code and I made no changes to the code.
>
> So I added the following just for testing (just in case I had re-defined
> datetime):
> try:
> now = datetime.datetime.now()
> except:
> import datetime
> now = datetime.datetime.now()
>
> But now in the same module I get a new error:
>
> TypeError: 'NoneType' object is not callable for
> salt = get_hexdigest(algo, str(random.random()), str(random.random()))
>
> This is crazy! I can not understand what has happened!
>
> I'm hoping someone understands this better than I do!
>
> Just running
> python manage.py runserver
> I get a 500.
>
> I'm on openSUSE 11.3, python 2.6.5, django 1.2.3 (was on 1.2.1). I really
> need help!
>
> Johnf

I'm guessing but could this have something to do with my imports?
from django.shortcuts import render_to_response, get_object_or_404
from django.http import Http404, HttpResponseRedirect, HttpResponse
from django.db import connection, transaction
from django.contrib.auth.models import User
from pesweb.esclient.models import Client, CellCarrier, CCTransactions
from pesweb.course.models import Course
import random
import datetime
import time
import json
import cc
import pycurl

Johnf

--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

#3 Dec. 23, 2010 05:34:10

John F.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

django/contrib/auth/models.py goes nuts


On Wednesday, December 22, 2010 07:18:15 pm John Fabiani wrote:
> On Wednesday, December 22, 2010 06:44:47 pm John Fabiani wrote:
> > Hi,
> > I had a working website for about the last 2 weeks. I was using a test
> > database (Postgres). I am also using SVN for my code and have tried to
> > revert back many versions and I still get these new errors.
> >
> > The error first appeared as datetime has no Attribute 'None' for a line
> > in my views.py
> > user = User.objects.create_user(c.registration_id, c.email,
> > request.POST)
> >
> > The error was from in django/contrib/auth/models.py
> > now = datetime.datetime.now()
> >
> > No datetime?? But the module imports the datetime module at the top.
> > This is django code and I made no changes to the code.
> >
> > So I added the following just for testing (just in case I had re-defined
> > datetime):
> >
> > try:
> > now = datetime.datetime.now()
> >
> > except:
> > import datetime
> > now = datetime.datetime.now()
> >
> > But now in the same module I get a new error:
> >
> > TypeError: 'NoneType' object is not callable for
> > salt = get_hexdigest(algo, str(random.random()),
> > str(random.random()))
> >
> > This is crazy! I can not understand what has happened!
> >
> > I'm hoping someone understands this better than I do!
> >
> > Just running
> > python manage.py runserver
> > I get a 500.
> >
> > I'm on openSUSE 11.3, python 2.6.5, django 1.2.3 (was on 1.2.1). I
> > really need help!
> >
> > Johnf
>
> I'm guessing but could this have something to do with my imports?
> from django.shortcuts import render_to_response, get_object_or_404
> from django.http import Http404, HttpResponseRedirect, HttpResponse
> from django.db import connection, transaction
> from django.contrib.auth.models import User
> from pesweb.esclient.models import Client, CellCarrier, CCTransactions
> from pesweb.course.models import Course
> import random
> import datetime
> import time
> import json
> import cc
> import pycurl
>
> Johnf

I don't know - it's working again??????????
I did change the import TO
import datetime as MYDATETIME

I deleted the models.pyc file
I removed
import random
import pycurl
they were not being used.

I'm only changing a views.py file.

and
I rebooted.

None of the above code chages I believe would do anything. And remember this
was running.

In my editor (Wing) there is a list of the modules being used. I did see
something that said 'datetime' but it was not the normal datetime. It said
something about the datetime fast lib. I'm not sure what that is and I doubt
it had anything to do with the server because I only saw it on my devel
machine. But I thought I should bring it up anyway.

This sucks big time. I'm getting ready to deploy and now I'm worried I might
have to reboot the server to get it working again. Not cool!

Johnf

--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

#4 Dec. 23, 2010 08:39:52

bruno d.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

django/contrib/auth/models.py goes nuts


On 23 déc, 06:33, John Fabiani <jo...@jfcomputer.com> wrote:

(snip)

John, may I suggest that instead of trying whatever comes to mind and
wonder what happens, you spend some times learning Python, specially
the part about modules, import and the modules search path ? Your
problem - which has nothing to do with Django BTW - is obviously that
something in your PYTHONPATH shadows the stdlib modules. Launch an
interactive django / python shell ("./manage.py shell" command in your
terminal), then execute the following code:

import sys
print "\n".join(sys.path)
import datetime
print datetime

This should tell you where your modules are searched for by Python,
and where your datetime module is actually imported from.

--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

#5 Dec. 23, 2010 14:37:12

S.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

django/contrib/auth/models.py goes nuts


I have the same problem..hi John!Please talk to me what you have done to
make it work??

Seems the auth/model.py is so weak...which makes me cry

2010/12/23 bruno desthuilliers <bruno.desthuilli...@gmail.com>

> On 23 déc, 06:33, John Fabiani <jo...@jfcomputer.com> wrote:
>
> (snip)
>
> John, may I suggest that instead of trying whatever comes to mind and
> wonder what happens, you spend some times learning Python, specially
> the part about modules, import and the modules search path ? Your
> problem - which has nothing to do with Django BTW - is obviously that
> something in your PYTHONPATH shadows the stdlib modules. Launch an
> interactive django / python shell ("./manage.py shell" command in your
> terminal), then execute the following code:
>
> import sys
> print "\n".join(sys.path)
> import datetime
> print datetime
>
> This should tell you where your modules are searched for by Python,
> and where your datetime module is actually imported from.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
>http://groups.google.com/group/django-users?hl=en.
>
>

--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.<<33A.gif>>

Offline

#6 Dec. 23, 2010 16:55:10

John F.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

django/contrib/auth/models.py goes nuts


On Thursday, December 23, 2010 12:39:44 am bruno desthuilliers wrote:
> On 23 déc, 06:33, John Fabiani <jo...@jfcomputer.com> wrote:
>
> (snip)
>
> John, may I suggest that instead of trying whatever comes to mind and
> wonder what happens, you spend some times learning Python, specially
> the part about modules, import and the modules search path ? Your
> problem - which has nothing to do with Django BTW - is obviously that
> something in your PYTHONPATH shadows the stdlib modules. Launch an
> interactive django / python shell ("./manage.py shell" command in your
> terminal), then execute the following code:
>
> import sys
> print "\n".join(sys.path)
> import datetime
> print datetime
>
> This should tell you where your modules are searched for by Python,
> and where your datetime module is actually imported from.

You can do more than suggest. I learn daily. And so today I learn where and
how to determine where/which module is used for an import.

But still your suggestion does not solve the issue at hand. Your code reports
import datetime
>>> print datetime
<module 'datetime' from '/usr/lib/python2.6/lib-dynload/datetime.so'>

I believe that is the correct datetime module which explains nothing! Most
important in my mind is how did anything I did cause a difference!

1. I changed the way I import-ed datetime in my views.py. Just a simple name
change on the theory that somewhere I had re-defined datetime. I also removed
two un-used imports. At first I thought they might have been an issue but I
could not see where they conflicted with anything and it did nothing to change
the error.

2. Deleted the django models.pyc (note the pyc). On the theory that some how
the file was corrupt.

3. Rebooted the Linux box. I hated to do this act. In the past I have always
found ways around rebooting a linux box.

But suddenly everything started working again!

But let's assume you are correct I had added some sort of conflicting module.
BTW that was my thought almost immediately! I changed the code causing the
immediate error with the following (used only for testing):

try:
now = datetime.datetime.now()
except:
import datetime
now = datetime.datetime.now()

But suddenly I got a second error from the password method and again the error
was 'None' has no Attribute .... The problem with that error was everything
in the password method is contained in the same module. So if it did not
require anything outside of the module how could it be 'None'. All these
errors from the same module (models.py).

All of this has me very concerned because I was about to deploy (after all
the website has been tested for the last two weeks). I do believe this has
something to do with my code (I believe there had to be some sort of conflict
- but where).

But as to your statement this has nothing to do with Django I can NOT agree.
Like all programs Django should protect it's modules and do everything they
can to insure the correct access to the correct imports. All frameworks need
to protect their code. Yes it true it is hard to protect against someone
willing to shoot them self's in the foot. But some effort is still required!

Johnf






--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

#7 Dec. 23, 2010 17:05:46

Steve H.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

django/contrib/auth/models.py goes nuts


On 12/23/2010 11:54 AM, John Fabiani wrote:
> On Thursday, December 23, 2010 12:39:44 am bruno desthuilliers wrote:
>> On 23 déc, 06:33, John Fabiani <jo...@jfcomputer.com> wrote:
>>
>> (snip)
>>
>> John, may I suggest that instead of trying whatever comes to mind and
>> wonder what happens, you spend some times learning Python, specially
>> the part about modules, import and the modules search path ? Your
>> problem - which has nothing to do with Django BTW - is obviously that
>> something in your PYTHONPATH shadows the stdlib modules. Launch an
>> interactive django / python shell ("./manage.py shell" command in your
>> terminal), then execute the following code:
>>
>> import sys
>> print "\n".join(sys.path)
>> import datetime
>> print datetime
>>
>> This should tell you where your modules are searched for by Python,
>> and where your datetime module is actually imported from.
>
> You can do more than suggest. I learn daily. And so today I learn where and
> how to determine where/which module is used for an import.
>
> But still your suggestion does not solve the issue at hand. Your code reports
> import datetime
>>>> print datetime
> <module 'datetime' from '/usr/lib/python2.6/lib-dynload/datetime.so'>
>
> I believe that is the correct datetime module which explains nothing! Most
> important in my mind is how did anything I did cause a difference!
>
> 1. I changed the way I import-ed datetime in my views.py. Just a simple name
> change on the theory that somewhere I had re-defined datetime. I also
> removed
> two un-used imports. At first I thought they might have been an issue but I
> could not see where they conflicted with anything and it did nothing to
> change
> the error.
>
> 2. Deleted the django models.pyc (note the pyc). On the theory that some how
> the file was corrupt.
>
> 3. Rebooted the Linux box. I hated to do this act. In the past I have
> always
> found ways around rebooting a linux box.
>
> But suddenly everything started working again!
>
> But let's assume you are correct I had added some sort of conflicting module.
>
> BTW that was my thought almost immediately! I changed the code causing the
> immediate error with the following (used only for testing):
>
> try:
> now = datetime.datetime.now()
> except:
> import datetime
> now = datetime.datetime.now()
>
> But suddenly I got a second error from the password method and again the
> error
> was 'None' has no Attribute .... The problem with that error was everything
> in the password method is contained in the same module. So if it did not
> require anything outside of the module how could it be 'None'. All these
> errors from the same module (models.py).
>
> All of this has me very concerned because I was about to deploy (after all
> the website has been tested for the last two weeks). I do believe this has
> something to do with my code (I believe there had to be some sort of conflict
> - but where).
>
> But as to your statement this has nothing to do with Django I can NOT agree.
> Like all programs Django should protect it's modules and do everything they
> can to insure the correct access to the correct imports. All frameworks need
> to protect their code. Yes it true it is hard to protect against someone
> willing to shoot them self's in the foot. But some effort is still required!
>
> Johnf
>
John:

I know it's disturbing when computers appear to behave in a
non-deterministic way. Perhaps when the system is failing you could copy
and paste the whole traceback?

Your original statement of the problem is far from clear. You said:

"""
The error first appeared as datetime has no Attribute 'None' for a line
in my
views.py
user = User.objects.create_user(c.registration_id, c.email,
request.POST)

The error was from in django/contrib/auth/models.py
now = datetime.datetime.now()
"""

Presumably that line appeared in the traceback but was only the
*indirect* cause of the failure? You don't say *which* line number that
line is from the django.contrib.auth.models.py, let alone which function
or method was active when the exception occurred. While there are many
fine minds in this group you aren't really giving them much of a chance
to help you.

With more information someone might not only be able to diagnose the
error but also to help you avoid it.

regards
Steve
--
DjangoCon US 2011 Portland, OR: September 6-8http://djangocon.us/--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

#8 Dec. 23, 2010 18:09:17

John F.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

django/contrib/auth/models.py goes nuts


On Thursday, December 23, 2010 09:05:21 am Steve Holden wrote:
> On 12/23/2010 11:54 AM, John Fabiani wrote:
> > On Thursday, December 23, 2010 12:39:44 am bruno desthuilliers wrote:
> >> On 23 déc, 06:33, John Fabiani <jo...@jfcomputer.com> wrote:
> >>
> >> (snip)
> >>
> >> John, may I suggest that instead of trying whatever comes to mind and
> >> wonder what happens, you spend some times learning Python, specially
> >> the part about modules, import and the modules search path ? Your
> >> problem - which has nothing to do with Django BTW - is obviously that
> >> something in your PYTHONPATH shadows the stdlib modules. Launch an
> >> interactive django / python shell ("./manage.py shell" command in your
> >> terminal), then execute the following code:
> >>
> >> import sys
> >> print "\n".join(sys.path)
> >> import datetime
> >> print datetime
> >>
> >> This should tell you where your modules are searched for by Python,
> >> and where your datetime module is actually imported from.
> >
> > You can do more than suggest. I learn daily. And so today I learn where
> > and how to determine where/which module is used for an import.
> >
> > But still your suggestion does not solve the issue at hand. Your code
> > reports import datetime
> >
> >>>> print datetime
> >
> > <module 'datetime' from '/usr/lib/python2.6/lib-dynload/datetime.so'>
> >
> > I believe that is the correct datetime module which explains nothing!
> > Most important in my mind is how did anything I did cause a difference!
> >
> > 1. I changed the way I import-ed datetime in my views.py. Just a simple
> > name change on the theory that somewhere I had re-defined datetime. I
> > also removed two un-used imports. At first I thought they might have
> > been an issue but I could not see where they conflicted with anything
> > and it did nothing to change the error.
> >
> > 2. Deleted the django models.pyc (note the pyc). On the theory that some
> > how the file was corrupt.
> >
> > 3. Rebooted the Linux box. I hated to do this act. In the past I have
> > always found ways around rebooting a linux box.
> >
> > But suddenly everything started working again!
> >
> > But let's assume you are correct I had added some sort of conflicting
> > module. BTW that was my thought almost immediately! I changed the code
> > causing the immediate error with the following (used only for testing):
> >
> > try:
> > now = datetime.datetime.now()
> >
> > except:
> > import datetime
> > now = datetime.datetime.now()
> >
> > But suddenly I got a second error from the password method and again the
> > error was 'None' has no Attribute .... The problem with that error was
> > everything in the password method is contained in the same module. So
> > if it did not require anything outside of the module how could it be
> > 'None'. All these errors from the same module (models.py).
> >
> > All of this has me very concerned because I was about to deploy (after
> > all the website has been tested for the last two weeks). I do believe
> > this has something to do with my code (I believe there had to be some
> > sort of conflict - but where).
> >
> > But as to your statement this has nothing to do with Django I can NOT
> > agree. Like all programs Django should protect it's modules and do
> > everything they can to insure the correct access to the correct imports.
> > All frameworks need to protect their code. Yes it true it is hard to
> > protect against someone willing to shoot them self's in the foot. But
> > some effort is still required!
> >
> > Johnf
>
> John:
>
> I know it's disturbing when computers appear to behave in a
> non-deterministic way. Perhaps when the system is failing you could copy
> and paste the whole traceback?
>
> Your original statement of the problem is far from clear. You said:
>
> """
> The error first appeared as datetime has no Attribute 'None' for a line
> in my
> views.py
> user = User.objects.create_user(c.registration_id, c.email,
> request.POST)
>
> The error was from in django/contrib/auth/models.py
> now = datetime.datetime.now()
> """
>
> Presumably that line appeared in the traceback but was only the
> *indirect* cause of the failure? You don't say *which* line number that
> line is from the django.contrib.auth.models.py, let alone which function
> or method was active when the exception occurred. While there are many
> fine minds in this group you aren't really giving them much of a chance
> to help you.
>
> With more information someone might not only be able to diagnose the
> error but also to help you avoid it.
>
> regards
> Steve
The first issue is the traceback. I'm not getting a traceback at the command
line or the website. I'm running (python manage.py runserver). There is no
traceback that appears. Other than a 500. I am able to run the django
website via my editor Wing. That does provide a traceback and I was able to
trace it back to the line as reported. I don't recall the line number at the
moment. But it is the only line that contains the code in the module. BTW I
also have considered that my editor is involved in the cause of the traceback!
I did post the traceback on pastebin.com yesterday.

That said - the traceback I doubt would have made any sense anyway! I placed
print statements around the offending code and indeed the datetime line was
causing the error. The import for the datetime was at the top of the module
and still the I got the error message. Just for the record the error came
from line 110 in class UserManger->create_user(). This did not make sense and
I immediately realized that something was wrong in a general sense. To prove
that I added code to the module to insure that in fact the import datatime was
done just before the offending code. That of course that worked!

But I immediately got a new error from the same module in set_password() (same
module models.py). This method is almost self contained and should not have
caused any error. Again this does not make sense! There had to be some sort
of module conflict. But where and how come a working website suddenly
develops such errors?

At the moment the damm thing is working! I can't repeat any of the errors! I
get no 500's nothing! Assuming you read my earlier post - I hope you agree
that nothing I did should have changed anything. The code I have uses just
standard python with one exception pycurl. In my views I have imports but I
do NOT see any conflicts.


Johnf

--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

  • Root
  • » Django
  • » django/contrib/auth/models.py goes nuts [RSS Feed]

Board footer

Moderator control

Enjoy the 17th of August
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support