Google Groups Home
Help | Sign in
virtualhosts, mod_python, and Django's cache
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  17 messages - Collapse all
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
rokclimb15@gmail.com  
View profile
 More options Jun 21 2007, 3:20 am
From: "rokclim...@gmail.com" <rokclim...@gmail.com>
Date: Thu, 21 Jun 2007 07:20:12 -0000
Local: Thurs, Jun 21 2007 3:20 am
Subject: virtualhosts, mod_python, and Django's cache
I am having a terrible time getting multiple vhosts running Django up
and running.

I have two sites configured just like the configuration below (except
with different ServerName directives and different
DJANGO_SETTINGS_MODULE variables.  The trouble is that Django's cache
is confusing the two sites and is saying that one table from a project
doesn't exist in the other project's db when I try to access it!  I
tried setting different PythonInterpreters, but it had no effect.  It
seems if I don't use different PythonPath directives for my sites, the
cache gets confused.  But if I do that, the settings don't work
correctly and the site won't load.  What am I doing wrong?

My site's config looks like this:

<VirtualHost *>
        ServerName sitename.com
        ServerAdmin rokclim...@gmail.com
        DocumentRoot /djangosites/project/
        <Location "/">
                SetHandler python-program
                PythonHandler django.core.handlers.modpython
                SetEnv DJANGO_SETTINGS_MODULE project.settings
                PythonPath "['/djangosites/'] + sys.path"
                PythonDebug Off
        </Location>
        <Location "/images">
                SetHandler None
        </Location>
        <Location "/js">
                SetHandler None
        </Location>
        <Location "/flash">
                SetHandler None
        </Location>
        <Location "/admin-media">
                SetHandler None
        </Location>

        ErrorLog /var/log/apache2/sitename.com-error.log

        # Possible values include: debug, info, notice, warn, error,
crit,
        # alert, emerg.
        LogLevel warn

        CustomLog /var/log/apache2/sitename.com-access.log combined
        ServerSignature Off
</VirtualHost>


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kenneth Gonsalves  
View profile
 More options Jun 21 2007, 3:46 am
From: Kenneth Gonsalves <law...@thenilgiris.com>
Date: Thu, 21 Jun 2007 13:16:07 +0530
Local: Thurs, Jun 21 2007 3:46 am
Subject: Re: virtualhosts, mod_python, and Django's cache

On 21-Jun-07, at 12:50 PM, rokclim...@gmail.com wrote:

> cache gets confused.  But if I do that, the settings don't work
> correctly and the site won't load.  What am I doing wrong?

you need a pythonInterpretor line in each Location with a different  
name. It is in the documentation

--

regards
kg
http://lawgon.livejournal.com
http://nrcfosshelpline.in/web/


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Graham Dumpleton  
View profile
 More options Jun 21 2007, 5:45 am
From: Graham Dumpleton <Graham.Dumple...@gmail.com>
Date: Thu, 21 Jun 2007 09:45:29 -0000
Local: Thurs, Jun 21 2007 5:45 am
Subject: Re: virtualhosts, mod_python, and Django's cache
On Jun 21, 5:46 pm, Kenneth Gonsalves <law...@thenilgiris.com> wrote

> On 21-Jun-07, at 12:50 PM, rokclim...@gmail.com wrote:

> > cache gets confused.  But if I do that, the settings don't work
> > correctly and the site won't load.  What am I doing wrong?

> you need a pythonInterpretor line in each Location with a different
> name. It is in the documentation

Not true if each is in its own VirtualHost as the default behaviour of
mod_python is to give each VirtualHost its own sub interpreter. You
should only need to set PythonInterpreter if you were running two
Django instances within the same VirtualHost at different mount
points.

For completeness, it would help if OP posted both VirtualHost
configurations side by side in the same message, so one can see
properly the PythonPath setting for each and the
DJANGO_SETTINGS_MODULE setting.

BTW, if using recent mod_python, to confirm that distinct Python sub
interpreters are being used one can use:

  from mod_python import apache
  apache.log_error("INTERPRETER %s" % apache.interpreter)

Then check the Apache error log file.

I would also suggest printing the value of sys.path to make sure it is
what you expect.

More importantly, when you say "Django's cache is confusing the two
sites and is saying that one table from a project doesn't exist in the
other project's db", can you post the actual full message you are
getting, and state where you are getting it. If it has a traceback,
also include the traceback.

Graham


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Deryck Hodge  
View profile
 More options Jun 21 2007, 6:54 am
From: "Deryck Hodge" <der...@samba.org>
Date: Thu, 21 Jun 2007 05:54:24 -0500
Local: Thurs, Jun 21 2007 6:54 am
Subject: Re: virtualhosts, mod_python, and Django's cache
On 6/21/07, rokclim...@gmail.com <rokclim...@gmail.com> wrote:

> I have two sites configured just like the configuration below (except
> with different ServerName directives and different
> DJANGO_SETTINGS_MODULE variables.  The trouble is that Django's cache
> is confusing the two sites and is saying that one table from a project
> doesn't exist in the other project's db when I try to access it!

Are you using the site-wide cache, and did you set your
CACHE_MIDDLEWARE_KEY_PREFIX?  See that setting under
http://www.djangoproject.com/documentation/cache/#the-per-site-cache.
If you're not using caching site-wide, explain more about how you're
using caching and how it's getting confused.

Cheers,
deryck

--
Deryck Hodge
Lead Developer, Product Development
Washington Post.Newsweek Interactive


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
rokclimb15@gmail.com  
View profile
 More options Jun 21 2007, 9:39 am
From: "rokclim...@gmail.com" <rokclim...@gmail.com>
Date: Thu, 21 Jun 2007 13:39:23 -0000
Local: Thurs, Jun 21 2007 9:39 am
Subject: Re: virtualhosts, mod_python, and Django's cache
Error can be seen here http://beta.atlantaicecompany.com/

AGDWeb is an app in a totally separate project under the same
PythonPath.  It has a separate settings file.

I am not using any Django cache, I am referring to some sort of
internal caching that mod_python is doing.

The settings file looks like this

<VirtualHost *>
        ServerName beta.atlantaicecompany.com
        ServerAdmin rokclim...@gmail.com
        DocumentRoot /djangosites/atlantaice/
        <Location "/">
                SetHandler python-program
                PythonHandler django.core.handlers.modpython
                SetEnv DJANGO_SETTINGS_MODULE atlantaice.settings
                PythonPath "['/djangosites/'] + sys.path"
                PythonDebug Off
        </Location>
        <Location "/images">
                SetHandler None
        </Location>
        <Location "/js">
                SetHandler None
        </Location>
        <Location "/flash">
                SetHandler None
        </Location>
        <Location "/admin-media">
                SetHandler None
        </Location>

        ErrorLog /var/log/apache2/beta.atlantaicecompany.com-error.log

        # Possible values include: debug, info, notice, warn, error,
crit,
        # alert, emerg.
        LogLevel warn

        CustomLog /var/log/apache2/beta.atlantaicecompany.com-
access.log combined
        ServerSignature Off
</VirtualHost>

and

<VirtualHost *>
        ServerName agdweb.gtagd.org
        ServerAdmin rokclim...@gmail.com
        DocumentRoot /djangosites/AGD/
        <Location "/">
                SetHandler python-program
                PythonHandler django.core.handlers.modpython
                SetEnv DJANGO_SETTINGS_MODULE AGD.settings
                PythonPath "['/djangosites/'] + sys.path"
                PythonDebug Off
        </Location>
        <Location "/site-media">
                SetHandler None
        </Location>
        <Location "/admin-media">
                SetHandler None
        </Location>

        ErrorLog /var/log/apache2/agdweb.gtagd.org-error.log

        # Possible values include: debug, info, notice, warn, error,
crit,
        # alert, emerg.
        LogLevel warn

        CustomLog /var/log/apache2/agdweb.gtagd.org-access.log
combined
        ServerSignature Off
</VirtualHost>

On Jun 21, 5:45 am, Graham Dumpleton <Graham.Dumple...@gmail.com>
wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Joe  
View profile
 More options Jun 21 2007, 3:42 pm
From: Joe <josephdr...@gmail.com>
Date: Thu, 21 Jun 2007 19:42:26 -0000
Local: Thurs, Jun 21 2007 3:42 pm
Subject: Re: virtualhosts, mod_python, and Django's cache
Are you using Apache Prefork or MPM?

On Jun 21, 9:39 am, "rokclim...@gmail.com" <rokclim...@gmail.com>
wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
rokclimb15@gmail.com  
View profile
 More options Jun 21 2007, 6:44 pm
From: "rokclim...@gmail.com" <rokclim...@gmail.com>
Date: Thu, 21 Jun 2007 22:44:32 -0000
Local: Thurs, Jun 21 2007 6:44 pm
Subject: Re: virtualhosts, mod_python, and Django's cache
prefork

On Jun 21, 3:42 pm, Joe <josephdr...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Graham Dumpleton  
View profile
 More options Jun 21 2007, 7:12 pm
From: Graham Dumpleton <Graham.Dumple...@gmail.com>
Date: Thu, 21 Jun 2007 23:12:10 -0000
Local: Thurs, Jun 21 2007 7:12 pm
Subject: Re: virtualhosts, mod_python, and Django's cache
What is in:

  atlantaice.urls

If the details in the error page are to be believed, it would look
like one of the URL mapping rules is referencing the other site.

I really wish the Django error page would show the interpreter name
when using mod_python. I guess another suggestion I should create a
ticket for when I can catch up with my list of things to do.. :-)

Graham

On Jun 21, 11:39 pm, "rokclim...@gmail.com" <rokclim...@gmail.com>
wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
rokclimb15@gmail.com  
View profile
 More options Jun 21 2007, 8:14 pm
From: "rokclim...@gmail.com" <rokclim...@gmail.com>
Date: Fri, 22 Jun 2007 00:14:36 -0000
Local: Thurs, Jun 21 2007 8:14 pm
Subject: Re: virtualhosts, mod_python, and Django's cache
Interestingly, I am getting some strange errors when trying to output
the interpreter ID to my error log.  Attempting to do so generates an
error in my logs:

[Thu Jun 21 20:00:23 2007] [error] [client 209.155.235.13]
PythonHandler django.core.handlers.modpython:   File "/djangosites/
atlantaice/settings.py", line 3, in ?\n
apache.log_error("INTERPRETER %s" % apache.interpreter)
[Thu Jun 21 20:00:23 2007] [error] [client 209.155.235.13]
PythonHandler django.core.handlers.modpython: AttributeError: 'module'
object has no attribute 'interpreter'

atlantaice.urls doesn't reference AGDWeb in any way.

urlpatterns = patterns('',
    (r'^$', 'atlantaice.web.views.homepage'),
    (r'^alliedpartners/$', 'atlantaice.web.views.allied_partners'),
    (r'^contact/$', 'atlantaice.web.views.contact'),
    (r'^contact/confirm/$', 'atlantaice.web.views.contact_confirm'),
    (r'^emergency/$', 'atlantaice.web.views.emergency'),
    (r'^employmentopp/$', 'atlantaice.web.views.list_jobs'),
    (r'^employmentopp/(?P<job_id>\d+)/$',
'atlantaice.web.