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 at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to