pythonapachemod-wsgipyramidfanstatic

Pyramid - fanstatic application cannot find static resources under apache wsgi module


I have a Pyramid-Fanstatic application that I created using pcreate:

pcreate -s starter -s pyramid_fanstatic

All works ok if I use /bin/pserve-fanstatic to start the server. However when I use the Apache WSGI module to load the app, a link like:

<link rel="stylesheet" type="text/css" href="/fanstatic/services/bootstrap/bootstrap.min.css" />

returns 404 Not Found by Apache.

This is my WSGI application:

import os
activate_this = os.path.join('/opt/services/services/bin/activate_this.py')
execfile(activate_this, dict(__file__=activate_this))
os.environ['PYTHON_EGG_CACHE'] = '/opt/services/python-eggs'


from pyramid.paster import get_app, setup_logging
ini_path = '/opt/services/services/development.ini'
setup_logging(ini_path)
application = get_app(ini_path, 'main') 

This is my Apache conf file:

<VirtualHost *:80>
    ServerAdmin a.orth@cgiar.org
    ServerName data.ilri.org

    # Pass authorization info on (needed for rest api).
    WSGIPassAuthorization On

    WSGIDaemonProcess services python-path=/opt/services/services display-name=services processes=2 threads=15
    WSGIScriptAlias /services /opt/services/services/services/services.wsgi process-group=services application-group=%{GLOBAL}

    <Location /services>
                WSGIProcessGroup services
    </Location>

    ErrorLog /var/log/httpd/services.error.log
    CustomLog /var/log/httpd/services.custom.log combined

</VirtualHost>

I can see that /bin/pserve-fanstatic includes my resource directory before loading the application:

"""A script aware of static resource"""
    import pyramid.scripts.pserve
    import pyramid_fanstatic
    import os

    dirname = os.path.dirname(__file__)
    dirname = os.path.join(dirname, 'resources')
    pyramid.scripts.pserve.add_file_callback(
                pyramid_fanstatic.file_callback(dirname))
    pyramid.scripts.pserve.main()

But even if I include such lines in my init.py Apache cannot find the fanstatic resources.

I also added this to my ini file:

[filter:fanstatic]
use = egg:fanstatic#fanstatic

[pipeline:main]
pipeline = fanstatic services

What else should I check/do?


Solution

  • Fixed!!

    I had to add this lines to the ini file in [app:main]:

    fanstatic.publisher_signature = fanstatic
    fanstatic.use_application_uri = true
    

    as per the documentation at: https://pypi.python.org/pypi/pyramid_fanstatic