Skip to main content

Ralsina.Me — Roberto Alsina's website

Weird Django/PyODB bug

I am fin­ish­ing my first large-ish Djan­go app from scratch [1].

To lo­gin a us­er you can do some­thing like this:

[root@wally app]# python manage.py shell
Python 2.3.4 (#1, May  2 2007, 19:26:00)
[GCC 3.4.6 20060404 (Red Hat 3.4.6-8)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from pyodb import *
>>> import django.contrib.auth
>>> print django.contrib.auth.authenticate(username='user',password='pass')
user

And then you use that us­er ob­ject for djan­go.­con­trib.auth.lo­gin

Some of the au­then­ti­ca­tion da­ta is avail­able on a Mi­cro­soft SQL Server, and I get it via py­o­d­b. And this hap­pens when I try to au­then­ti­cate the us­er (as­sume us­er and pass are valid, this is the small­est snip­pet that trig­gers the bug):

[root@wally app]# python manage.py shell
Python 2.3.4 (#1, May  2 2007, 19:26:00)
[GCC 3.4.6 20060404 (Red Hat 3.4.6-8)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from pyodb import Connect
>>> import django.contrib.auth
>>> c1=Connect("sqlserver",uid="user",pwd="pass")
>>> print django.contrib.auth.authenticate(username='user',password='pass')
None

As you can see, the py­o­db stuff should not in­ter­fere with the djan­go stuff at al­l. I am on­ly im­port­ing one func­tion and con­nect­ing to the DB, I don't even ex­e­cute any SQL or use any da­ta from the SQL con­nec­tion. But the calls to au­then­ti­cate fail.

How are you sup­posed to de­bug this? I worked around it by mov­ing the Py­O­DB stuff to an­oth­er mod­ule, but it's weird.


Contents © 2000-2024 Roberto Alsina