Re: is it uses the memcache..?

2010-03-10 Thread Janusz Harkot
Django documentation is very clear in this matter.

All standard cache functions/decorators are using cache backend
specified in the settings,
defaults to local memory, with an option to use memcache.

J.

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



Re: Forcing HTTPS in admin

2010-02-28 Thread Janusz Harkot
no, but you can do this very easy on the fronted-webserver (nginx,
apache, cherokee etc.)

J.

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



Re: Serving https with runserver

2010-02-28 Thread Janusz Harkot
So you can use stunnel: http://www.stunnel.org/

J.

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



OperationalError server closed the connection unexpectedly

2009-11-11 Thread Janusz Harkot

Request Method: GET
Request URL:http://localhost/
Exception Type: OperationalError
Exception Value:
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.

Have you ever get such an exception running django as fastcgi?

First time I've got this exception was on pre-1.0 Django, only when
runfcgi's "method" was set to prefork,
fortunately on threaded code was working fine.

Until recently I was curious to test this on Django 1.1.1. Will this
exception be thrown again... surprise, there it was again.

It took me some time to debug this, helpful hint was that it only
shows when (pre)forking.

So for those who getting randomly those exceptions, I can say... fix
your code :)
Ok.. seriously, there are always few ways of doing this, so let me
firs explain where is a problem first.

If you access database when any of your modules will import as, e.g.
reading configuration from database then you will get this error.

When your fastcgi-prefork application starts, first it imports all
modules, and only after this forks children.
If you have established db connection during import all children
processes will have an exact copy of that object.

This connection is being closed at the end of request phase
(request_finished signal).
So first child which will be called to process your request, will
close this connection.
But what will happen to the rest of the child processes?
They will believe that they have open and presumably working
connection to the db, so any db operation will cause an exception.


Why this is not showing in threaded execution model? I suppose because
threads are using same object and know when any other thread is
closing connection.

How to fix this?
Best way is to fix your code... but this can be difficult sometimes.

Other option, in my opinion quite clean, is to write somewhere in your
application small piece of code:
from django.db import connection
from django.core import signals

def close_connection(**kwargs):
connection.close()

signals.request_started.connect(close_connection)


Is this a best way? Not sure, but is working for me without
performance penalties - django doesn't have connection pooling - so no
harm is done.

Is this a django bug? Not really - this is something on the
application, not framework side - but let me know if you thing
otherwise.
Do you have a better fix?

J.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---