FYI: this does the trick:

from django.db import connection
connection.close()



On Tue, Aug 23, 2011 at 12:29 AM, Julian Hodgson <
julian.of.lon...@googlemail.com> wrote:

> Ok, that makes sense.
>
> The thing is, we've written some python plugins for Softimage to read and
> write to the db that get loaded and stay in memory.   When the plugins are
> loaded, the django models are imported.  So during the lifetime of the host
> application, the python session is the same.
>
> So I really need a way of closing the transaction or flushing the sql in
> django,  without starting a new python session.
>
> Any ideas warmly received.
>
> Julian.
> On Aug 22, 2011 8:30 PM, "Daniel Roseman" <dan...@roseman.org.uk> wrote:
> > On Monday, 22 August 2011 17:16:24 UTC+1, Julian Hodgson wrote:
> >>
> >> Hi there,
> >>
> >> I'm running a production linux django server using wsgi, and have found
> the
> >> following issue. Django version (1, 2, 5, 'final', 0).
> >>
> >> If I open a python shell I get:
> >>
> >> >>> from passion.cg.models import *
> >> >>> print Sequence.objects.all()
> >> [<Sequence: DA>, <Sequence: DB>, <Sequence: DC>, <Sequence: DD>]
> >>
> >>
> >> But if I go into the admin and delete sequence DD, leaving the python
> >> session running, then I still get
> >>
> >> >>> print Sequence.objects.all()
> >> [<Sequence: DA>, <Sequence: DB>, <Sequence: DC>, <Sequence: DD>]
> >>
> >> so the Sequence table doesn't appear to be updated as far as the model
> is
> >> concerned.
> >>
> >> It's pretty fundamental that this can be resolved since many different
> >> users will be using the database at the same time, and it should be
> possible
> >> for each user to see the latest state of the DB.
> >>
> >> Any suggestions welcomed.
> >>
> >> Cheers,
> >>
> >> Julian
> >>
> >
> > This isn't anything to do with caching. It's a result of the fact that
> the
> > shell session is running within a single transaction, and therefore
> doesn't
> > see changes from outside that. If you quit the shell and restart it,
> you'll
> > be able to see the change.
> >
> > This isn't a problem in production, because transactions in views are
> tied
> > to the request/response cycle, which is short-lived.
> > --
> > DR.
> >
> >>
> >>
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> "Django users" group.
> > To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/qX11CSPon3MJ.
> > 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.
> >
>

-- 
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