Koozali.org: home of the SME Server

Obsolete Releases => SME 7.x Contribs => Topic started by: mophilly on May 28, 2007, 11:24:37 PM

Title: Adding an Alias via custom template
Post by: mophilly on May 28, 2007, 11:24:37 PM
I installed Django on SME 7 and created a Location for the Django project in httpd.conf. As an aside, I am not using an iBay now although I did at the beginning; at this point the ibay isn't involved so I deleted it.

Part of Django is a built-in admin interface that needs access to a "media" directory for css and so on. The media directory, along with the whole django project, is in /python2.3/site_packages/. The Django doc's suggest placing a symlink to the media directory in the document root or copying the media directory into the document root.

Django picks up the absolute path to the Primary ibay so Django sails along merrily with a copy of the media directory in Primary/html. The symlink didn't work; IIRC, the SME default is to disable symlinks in iBays so I didn't pursue enabling symlinks.

I would rather not have the extra directory in Primary/html. One solution I read about is to add an Alias and a Directory to the httpd.conf. I put these in the custom template "80AddHandler00", which I copied and amended.

Code: [Select]
Alias /media "path-to-site-packages/django/contrib/admin/media"
That almost worked. Although the path was correct, apache raised nn error for denied access permission so I added:
Code: [Select]
<Directory path-to-site-packages/django/contrib/admin/media>
        Order allow,deny
        Allow from all
    </Directory>

That upset things so that apache would not respond at all, and I removed the alias and the directory statements.

Here is what I have added to my custom template, "80AddHandler00", at the moment. This works, as far as it goes.
Code: [Select]
<Location "/mysite/">
    SetHandler python-program
    PythonPath "['/usr/local/mydjangoproject'] + sys.path"
    PythonHandler django.core.handlers.modpython
    SetEnv DJANGO_SETTINGS_MODULE settings
    PythonDebug On
    PythonAutoReload On
</Location>

What would be the correct way to implement an Alias or similar for this in SME?

Thanks, in advance,
Title: Re: Adding an Alias via custom template
Post by: xboxer21 on March 19, 2008, 12:39:17 AM
I'm trying to use django using mod_python but I have no luck as well. I keep getting the following error. I know mod_python is working successfully because trac seems to work fine. Please let us know if you have successfully got everything to work in SME. Also I'm trying to use the same setting in my hhtpd.conf as you have suggested.

Code: [Select]
Mod_python error: "PythonHandler django.core.handlers.modpython"

Traceback (most recent call last):

  File "/usr/lib/python2.3/site-packages/mod_python/apache.py", line 287, in HandlerDispatch
    log=debug)

  File "/usr/lib/python2.3/site-packages/mod_python/apache.py", line 454, in import_module
    f, p, d = imp.find_module(parts[i], path)

ImportError: No module named django
Title: Re: Adding an Alias via custom template
Post by: cactus on March 19, 2008, 09:34:19 PM
What would be the correct way to implement an Alias or similar for this in SME?

Thanks, in advance,
I am not sure but you can syntax-test your httpd.conf file before starting apache:

Code: [Select]
httpd -t.