App Store Code Structure

Terminology

Explanation of important files

How requests are handled

  1. HTTP request is made to the Apache server.
  2. Apache looks in /etc/apache2/sites-enabled to see how to handle the request. The appstore configuration file is set to handle requests made to http://apps.cytoscape.org.

  3. /etc/apache2/sites-enabled/appstore tells Apache to use mod_wsgi. mod_wsgi runs a Python interpreter within Apache. appstore tells mod_wsgi to start Python with /var/www/CyAppStore/django.wsgi.

  4. django.wsgi starts the Django library. It also specifies the location of settings.py, which is needed by Django to start the site.

  5. settings.py specifies the location of urls.py, a list of URLs and the Python functions that handle them

  6. urls.py dispatches the request to the appropriate function. Functions are always located in views.py files.

  7. The handler function returns with a processed HTML page.

Debugging

  1. /etc/apache2/sites-enabled/appstore

    • This file tells Apache and mod_wsgi where to find the site. The most important line is this:
      WSGIScriptAlias / /var/www/CyAppStore/django.wsgi

      This tells Apache and mod_wsgi where to locate the site code. Make sure the path to django.wsgi is correct.

  2. /var/www/CyAppStore/django.wsgi

    • This file invokes Django's WSGI handler. It needs to correctly reference settings.py to start the site. Make sure these two lines are correct:

      SITE_PARENT_DIR = '/var/www'
      SITE_DIR = filejoin(SITE_PARENT_DIR, 'CyAppStore')
      To check if these variables are being defined correctly, you can launch a separate Python interpreter and enter these lines:
      from os.path import join as filejoin
      SITE_PARENT_DIR = '/var/www'
      SITE_DIR = filejoin(SITE_PARENT_DIR, 'CyAppStore')

      Then check if the variables SITE_PARENT_DIR and SITE_DIR are correct.

  3. /var/www/CyAppStore/settings.py

    • This file is pretty complicated. But if you've checked everything at this point, here's some ways to pinpoint problems in settings.py.

      1. If you're getting an HTTP 500 error, you can get the stack trace by turning on debug mode then reloading the page. Note that debug mode exposes sensitive information about the site to the public. Make sure to keep debug mode off as much as possible. Change to following line to True:

        DEBUG = False
      2. You can poke at the code by running a Python shell. Enter this command at the shell prompt in the same directory as settings.py:

        python manage.py shell
        You can check to see if the site's code is working correctly without having debug mode on. For example, to see if the list of all apps is working, enter this into the Python interpreter:
        from apps.models import App
        App.objects.all()
      3. If you're getting database errors, enter this command at the shell prompt in the same directory as settings.py:

        python manage.py dbshell
        If you're able to get a SQL prompt, that means the log in settings into the SQL database are correct.
      4. If you make changes to a Python file but you're not seeing the changes taking effect, you may have to delete all the .pyc files, which are compiled Python code. To do so, type this:

        make svnclean

Tips

Funding for Cytoscape is provided by a federal grant from the U.S. National Institute of General Medical Sciences (NIGMS) of the Na tional Institutes of Health (NIH) under award number GM070743-01. Corporate funding is provided through a contract from Unilever PLC.

MoinMoin Appliance - Powered by TurnKey Linux