I'm working on an application that uses two databases -- one is the main
database that Django ORM talks to, where sessions are stored, etc. and the
other is an external database where we need to run some storedprocs to
retrieve some data.

This is all working fine for the most part but I ran into a situation today
that's causing some odd behavior so I figured I'd seek clarification. (This
is SQL Server using django-pyodbc in case that matters.)

I have the functions that talk to the "other" database in a Python class,
so their methods are more or less like so:
def get_stuff(self, foo):
    cursor = connections['otherConnection'].cursor()
    stuff = cursor.execute('exec myStoredproc').fetchall()
    return stuff

In and of themselves, the methods in this class work fine. Also note these
functions only retrieve data; there's no writing going on.

Now in the context of a view function I'm handling a posted form and this
interacts with the "primary" database connection (i.e. NOT the
'otherConnection' referenced above), and I'm using the
@transaction.commit_on_success decorator.

Inside that function I instantiate the class containing the methods like
the one above to retrieve data, and when I call that method it seems to
blow away my session because I'm logged out of the application and taken
back to my login page. If I change that method to NOT communicate with the
other database and instead just return dummy data I don't get kicked out of
the application.

Any ideas what's going on here? If the answer is that I can't do things
this way that's fine, but if that is the case what's the "right" way to
handle this situation?

Hopefully I explained that well but I'm happy to clarify as needed.

Thanks!

-- 
Matthew Woodward
m...@mattwoodward.com
http://blog.mattwoodward.com
identi.ca / Twitter: @mpwoodward

Please do not send me proprietary file formats such as Word, PowerPoint,
etc. as attachments.
http://www.gnu.org/philosophy/no-word-attachments.html

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@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