Webalchemy and mod_wsgi

1 view
Skip to first unread message

vishnu.kumar

unread,
Aug 12, 2009, 6:31:12 AM8/12/09
to modwsgi
Hi,

Is it possible to use webalchemy in a mod_wsgi to accelerate django
apps?
If it is a yes, then where can i find docs for achieving the same?

Vishnu

Graham Dumpleton

unread,
Aug 12, 2009, 6:51:36 AM8/12/09
to mod...@googlegroups.com
2009/8/12 vishnu.kumar <vishnu...@mahiti.org>:

Did you try a Google search? One of the top posts explains how to do
it for mod_python. As the method isn't really anything to do with the
hosting mechanism, but Django and static file serving with Apache, it
is just as applicable. See:

http://www.mysoftparade.com/blog/webalchemy-django-apache/

Also read up on Django flat pages app as it is sort of related. See:

http://docs.djangoproject.com/en/dev/ref/contrib/flatpages/

Graham

vishnu

unread,
Aug 14, 2009, 3:27:35 AM8/14/09
to modwsgi
hi Graham,

The doc first doc u showed mentions of using mod_python with apache2.
How or what differs when we use the mod_wsgi was what i wanted to
know?

Thanks
Vishnu

On Aug 12, 3:51 pm, Graham Dumpleton <graham.dumple...@gmail.com>
wrote:
> 2009/8/12 vishnu.kumar <vishnu.ku...@mahiti.org>:

vishnu

unread,
Aug 14, 2009, 3:39:18 AM8/14/09
to modwsgi
Also,
is it possible to have a dual setup of both mod_wsgi and mod_python
with webalchemy?
Would it be safe?

Thanks again
Vishnu

gert

unread,
Aug 14, 2009, 4:36:37 AM8/14/09
to modwsgi
If I am not mistaken
-Possible: yes using daemon mode
-Safe: no c level malfunctions
-Recommendation: defenatly not :)

Graham Dumpleton

unread,
Aug 14, 2009, 6:27:29 AM8/14/09
to mod...@googlegroups.com
2009/8/14 gert <gert.c...@gmail.com>:

Gert, please stop confusing matters. If you don't know for absolute
certain, leave it to me to answer.

I possibly will not get a chance to properly answer these questions
until tomorrow. The answers to both are most covered in the
documentation. That is, there is documentation on how to host static
files in:

http://code.google.com/p/modwsgi/wiki/ConfigurationGuidelines

There is documentation on issues that come up with using mod_python
and mod_wsgi together in:

http://code.google.com/p/modwsgi/wiki/InstallationIssues

I will say more later.

Graham

Graham Dumpleton

unread,
Aug 16, 2009, 1:13:35 AM8/16/09
to mod...@googlegroups.com
2009/8/14 Graham Dumpleton <graham.d...@gmail.com>:

The short answer on WebAlchemy is that the way that WebAlchemy does
things is stupid. There is no need to go modifying the .htaccess file
to add special rewrite rules for each static overlay file.

Instead, in:

http://code.google.com/p/modwsgi/wiki/ConfigurationGuidelines

in section 'The Apache Alias Directive' there is an example for using
resource base WSGI script file, but a single rewrite rule, with WSGI
script fixup, to make it appear at root of web server, or in place of
a directory for a sub URL scenario.

The rewrite rule for the root of site case is:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /site.wsgi/$1 [QSA,PT,L]

What this rule says is that if a static file exists corresponding to
the URL, then serve up that static file. If no such file, then instead
route the request through the WSGI application.

Thus, all that something like WebAlchemy or FlatPages needs to do is
write out the preformatted response to a static file in the necessary
location within the document tree an it will be automatically served.
When the view needs to be invalidated, it removes the file, or could
also update it instead to refresh it. As such, elaborate rewrite rules
shouldn't be required unless the URL needing to be mapped cannot be
represented in normal directory hierarchy.

BTW, the above can also be adapted to case where fastcgi being used as
well. So, no need for silly .htaccess rewrites there either.

Graham

vishnu

unread,
Aug 17, 2009, 5:58:13 AM8/17/09
to modwsgi
On Aug 16, 10:13 am, Graham Dumpleton <graham.dumple...@gmail.com>
wrote:
> 2009/8/14 Graham Dumpleton <graham.dumple...@gmail.com>:
>
>
>
> > 2009/8/14 gert <gert.cuyk...@gmail.com>:
Thanks for the reply Graham.

I will have a look at it.

So, does that mean that we have to follow the same steps for modwsgi
as modpython?

Vishnu

Graham Dumpleton

unread,
Aug 17, 2009, 6:03:19 AM8/17/09
to mod...@googlegroups.com
2009/8/17 vishnu <vishnu...@mahiti.org>:

What I am saying is that how that blog explains to do it is a stupid
way of doing it. There are better ways of doing it. So, in some
respects I am saying now, you shouldn't follow the same steps as done
for mod_python.

What I very much suggest you do is to experiment with that
configuration I described on a simple test case, without using
WebAlchemy, and see how a static file can take precedence over one
served by WSGI application. Once you work out how that works, you
should be able to adapt how WebAlchemy was used to do it for
mod_python.

From memory, if you search back in the mailing list archives on Google
Groups, you you will some discussions about this static file overlay
technique previously.

Graham

Reply all
Reply to author
Forward
0 new messages