I'm trying to install OSQA using Python 2.7.1 built with pythonbrew, and mod_wsgi compiled from source. I put this in /opt/example/stack/pythonbrew/. I have successfully gotten a 'hello world' app working using mod_wsgi on this server to ensure that it's working.

I put osqa in /opt/example/application/osqa_7934/htdocs/osqa-server/

osqa.error.log

After getting this all working, I'm running into a configuration error when trying to access the site:

[Mon Jun 20 19:12:58 2011] [warn] RSA server certificate is a CA certificate (BasicConstraints: CA == TRUE !?)
[Mon Jun 20 19:12:58 2011] [warn] RSA server certificate CommonName (CN) `balance.secure.example.net' does NOT match server name!?
[Mon Jun 20 19:12:58 2011] [warn] RSA server certificate is a CA certificate (BasicConstraints: CA == TRUE !?)
[Mon Jun 20 19:12:58 2011] [warn] RSA server certificate CommonName (CN) `balance.secure.example.net' does NOT match server name!?
[Mon Jun 20 19:12:58 2011] [notice] Apache/2.2.8 (Ubuntu) DAV/2 SVN/1.4.6 mod_ssl/2.2.8 OpenSSL/0.9.8g mod_wsgi/3.3 Python/2.7.1 configured -- resuming normal operations
[Mon Jun 20 19:13:03 2011] [error] [client 173.14.5.86] mod_wsgi (pid=11562): Exception occurred processing WSGI script '/opt/example/application/osqa_7934/htdocs/osqa-server/osqa.wsgi'., referer: http://appsapi.example.com/console/configurator/applicationInstances/7935/executeAnalyticsHosted
[Mon Jun 20 19:13:03 2011] [error] [client 173.14.5.86] Traceback (most recent call last):, referer: http://appsapi.example.com/console/configurator/applicationInstances/7935/executeAnalyticsHosted
[Mon Jun 20 19:13:03 2011] [error] [client 173.14.5.86]   File "/opt/example/stack/pythonbrew/pythons/Python-2.7.1/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 250, in __call__, referer: http://appsapi.example.com/console/configurator/applicationInstances/7935/executeAnalyticsHosted
[Mon Jun 20 19:13:03 2011] [error] [client 173.14.5.86]     self.load_middleware(), referer: http://appsapi.example.com/console/configurator/applicationInstances/7935/executeAnalyticsHosted
[Mon Jun 20 19:13:03 2011] [error] [client 173.14.5.86]   File "/opt/example/stack/pythonbrew/pythons/Python-2.7.1/lib/python2.7/site-packages/django/core/handlers/base.py", line 47, in load_middleware, referer: http://appsapi.example.com/console/configurator/applicationInstances/7935/executeAnalyticsHosted
[Mon Jun 20 19:13:03 2011] [error] [client 173.14.5.86]     raise exceptions.ImproperlyConfigured('Error importing middleware %s: "%s"' % (mw_module, e)), referer: http://appsapi.example.com/console/configurator/applicationInstances/7935/executeAnalyticsHosted
[Mon Jun 20 19:13:03 2011] [error] [client 173.14.5.86] ImproperlyConfigured: Error importing middleware forum.middleware.extended_user: "cannot import name mark_safe", referer: http://appsapi.example.com/console/configurator/applicationInstances/7935/executeAnalyticsHosted
[Mon Jun 20 19:13:03 2011] [error] [client 173.14.5.86] mod_wsgi (pid=11561): Exception occurred processing WSGI script '/opt/example/application/osqa_7934/htdocs/osqa-server/osqa.wsgi'.
[Mon Jun 20 19:13:03 2011] [error] [client 173.14.5.86] Traceback (most recent call last):
[Mon Jun 20 19:13:03 2011] [error] [client 173.14.5.86]   File "/opt/example/stack/pythonbrew/pythons/Python-2.7.1/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 250, in __call__
[Mon Jun 20 19:13:03 2011] [error] [client 173.14.5.86]     self.load_middleware()
[Mon Jun 20 19:13:03 2011] [error] [client 173.14.5.86]   File "/opt/example/stack/pythonbrew/pythons/Python-2.7.1/lib/python2.7/site-packages/django/core/handlers/base.py", line 47, in load_middleware
[Mon Jun 20 19:13:03 2011] [error] [client 173.14.5.86]     raise exceptions.ImproperlyConfigured('Error importing middleware %s: "%s"' % (mw_module, e))
[Mon Jun 20 19:13:03 2011] [error] [client 173.14.5.86] ImproperlyConfigured: Error importing middleware forum.middleware.extended_user: "cannot import name mark_safe"

Apache config file

Here are my apache directives:

LoadModule wsgi_module /usr/lib/apache2/modules/mod_wsgi.so
WSGIPythonHome /opt/example/stack/pythonbrew/pythons/Python-2.7.1

<VirtualHost _default_:80>
    ServerName osqa-1234.testapp.example.com
    ServerAlias www.osqa-1234.testapp.example.com

DocumentRoot /opt/example/application/osqa_7934/htdocs
    ErrorLog /opt/example/application/osqa_7934/log/error.log

<Directory /opt/example/application/osqa_7934/htdocs>
            AllowOverride All
    </Directory>

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

CustomLog /opt/example/application/osqa_7934/log/access.log combined

# Monitor Bandwidth
    CustomLog /opt/example/application/osqa_7934/log/logio.log  "%h %t \\"%r\\" %I %O"

#run mod_wsgi process for django in daemon mode
    #this allows avoiding confused timezone settings when
    #another application runs in the same virtual host
    #WSGIDaemonProcess OSQA
    #WSGIProcessGroup OSQA

#force all content to be served as static files
    #otherwise django will be crunching images through itself wasting time
    Alias /m/ "/opt/example/application/osqa_7934/htdocs/osqa-server/forum/skins/"
            <Directory "/home/osqa/osqa-server/forum/skins">
                    Order allow,deny
                    Allow from all
            </Directory>
    Alias /upfiles/ "/opt/example/application/osqa_7934/htdocs/osqa-server/forum/upfiles/"
    <Directory "/opt/example/application/osqa_7934/htdocs/osqa-server/forum/upfiles">
    Order deny,allow
    Allow from all
    </Directory>

#this is your wsgi script described in the prev section
    WSGIScriptAlias / /opt/example/application/osqa_7934/htdocs/osqa-server/osqa.wsgi

CustomLog /opt/example/application/osqa_7934/log/osqa.access.log common
    ErrorLog /opt/example/application/osqa_7934/log/osqa.error.log

</VirtualHost>

osqa.wsgi

My osqa.wsgi contains:

import os
import sys
sys.path.append('/opt/example/application/osqa_7934/htdocs')
sys.path.append('/opt/example/application/osqa_7934/htdocs/osqa-server')
# The first part of this module name should be identical to the directory name
# of the OSQA source.  For instance, if the full path to OSQA is
# /home/osqa/osqa-server, then the DJANGO_SETTINGS_MODULE should have a value
# of 'osqa-server.settings'.
os.environ['DJANGO_SETTINGS_MODULE'] = 'osqa-server.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

asked 20 Jun '11, 19:37

TrinitronX's gravatar image

TrinitronX
31115
accept rate: 0%

edited 20 Jun '11, 19:38

1

There did used to be an error importing mark_safe - http://wiki.osqa.net/display/docs/Ubuntu+with+Apache+and+MySQL?focusedCommentId=3047880#comment-3047880 - but I thought that had been fixed by now. And your error looks to be happening in a slightly different place to the previous one.

(21 Jun '11, 05:20) Andrew_S ♦

As it turns out, I ran into this issue as well as the one described here.

To fix it:

  • I added the change from this answer (thanks Simon Yan!)
  • I added the change from this comment (thanks Michael & Matt Joyce!)

Here is a patch incorporating both of these fixes:

diff -Naur a/osqa-server/forum/urls.py b/osqa-server/forum/urls.py
--- a/osqa-server/forum/urls.py 2011-03-16 19:29:56.000000000 -0400
+++ b/osqa-server/forum/urls.py 2011-06-21 12:48:35.000000000 -0400
@@ -20,7 +20,7 @@

core_urls = (
     url(r'^$', app.readers.index, name='index'),
-    url(r'^%s(.*)' % _('nimda/'), admin.site.root),
+    url(r'^%s(.*)' % _('nimda/'), admin.site.urls),

url(r'^sitemap.xml$', 'forum.sitemap.index', {'sitemaps': sitemaps}),
     url(r'^sitemap-(?P<section>.+)\\.xml$', 'forum.sitemap.sitemap', {'sitemaps': sitemaps}),
diff -Naur a/osqa-server/forum/utils/html.py b/osqa-server/forum/utils/html.py
--- a/osqa-server/forum/utils/html.py   2011-01-31 18:08:32.000000000 -0500
+++ b/osqa-server/forum/utils/html.py   2011-06-21 12:08:48.000000000 -0400
@@ -3,7 +3,7 @@
 from html5lib import sanitizer, serializer, tokenizer, treebuilders, treewalkers, HTMLParser
 from django.utils.html import strip_tags
 from forum.utils.html2text import HTML2Text
-from django.template import mark_safe
+from django.utils.safestring import mark_safe
 from forum import settings

class HTMLSanitizerMixin(sanitizer.HTMLSanitizerMixin):
link

answered 21 Jun '11, 13:21

TrinitronX's gravatar image

TrinitronX
31115
accept rate: 0%

edited 21 Jun '11, 13:24

I had the error

ImproperlyConfigured: Error importing middleware forum.middleware.extended_user: "cannot import name mark_safe"

with fantasy-island-0.9.0-beta3 on Solaris with Oracle

I had no issue with osqa-1.0rc-20110802

link

answered 21 Nov '11, 05:24

cucurb's gravatar image

cucurb
112
accept rate: 0%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×156
×113

Asked: 20 Jun '11, 19:37

Seen: 1,091 times

Last updated: 21 Nov '11, 05:24

powered by OSQA