Setting up Filmaster locally

This page aims at guiding you through setting up the Filmaster development environment locally. You are going to need the following software:

  • Python 2.5
  • Django framework (1.0.2 or 1.1)
  • Additional python modules
  • PostgreSQL database
  • A Linux box (or a lot of patience to set it up under Windows or Mac OS)

Installing required software

a) Django framework

We're using stable django 1.0.x The installation process is described at: http://docs.djangoproject.com/en/dev/topics/install/
However, you need a special hacked version that can be downloaded from here: http://dev.filmaster.pl/static/db/django.tar.bz2
(this is a standard 1.0 release patched to add a new parameter in extra() method for queries, allowing to perform custom joins).

You can also use the hacked version of django 1.1 from here: http://dev.filmaster.pl/static/db/django-1.1.tar.gz

User: justlookingaround, password: film@ster.

wget --http-user=justlookingaround --http-passwd=film@ster \
http://dev.filmaster.pl/static/db/django-1.1.tar.gz

Install django using a standard method, i.e. 

python setup.py install

in the unpacked hacked django directory.

You'll also need gettext package to be able to generate po/mo files. Easiest way via apt-get (on a Debian-based system):

apt-get install gettext

Or install it using your favorite software manager in your distribution / OS.

b) Database

Database settings are configured in settings.py. We're using PostgreSQL 8.3.5 database. Using other engines is not supported due to custom SQL used in a few views.

PostgreSQL, short howto:

  • Install postgresql-8.3 and python-psycopg2 (its python driver)
  • In case you need to compile psycopg, get it from here: http://initd.org/pub/software/psycopg/
  • Create a test database:
    $ sudo su - postgres
    $ createdb test
  • Next log into the test db:
    $ psql
  • and create the proper database, user and password:
    create user film20;
    create database film20 with owner = film20;
    ALTER USER film20 WITH ENCRYPTED PASSWORD 'justenter';
  • Add this line to /etc/postgresql/8.3/main/pg_hba.conf :
    local   all         all                               trust
  • Restart postgres:
    # /etc/init.d/postgresql-8.3 restart

Creating tables

  • enter the relevant data (db, user, pass) in settings.py
  • run in film20 directory:
    $ manage.py syncdb
  • One more thing you need to do is to create a django Site record:
  • Filmaster as most django sites require a single record in django_site table to function normally. The SITE_ID in settings.py has to point to this one.
    Log in to the psql console and simply insert one row like:
    film20=> insert into django_site (id, domain, name) values (1, 'localhost', 'Filmaster.com');
    And you should have something like that in the database now:
    film20=> select * from django_site;
     id |    domain     |     name    
    1 | localhost  | Filmaster.com
  • Done! Good job!

Now you can start hacking with Filmaster. Itwould be probably a good idea to import a few movies first and enter some test data. You can do it manually using the fetcher module and then log into Filmaster locally, rate some films and add some data. You can also load a sample database dump we provide.

Loading a database dump

If you'd like to work on some more real life data, we have a simple database dump that you can use. It weights 50MB so we don't want to expose it publicly but drop us an e-mail at filmaster@filmaster.com and we'll be glad to provide you with the FTP connection details.

c) Other dependencies

As we're using a few external modules, they need to be installed as well. What you could do is to download the pinax project and install the following python modules. We made it easy for you by providing the required packages in film20/dependencies. So, just go there and install the following:

  • gdata.py-1.0.13
  • pytz-2008b
  • simplejson-1.9.1
  • ybrowserauth
  • vobject-0.6.6
  • feedparser
  • django-compress
  • BeautifulSoup

using the standard command:

python setup.py install

You also need python-tz, python-openid and python-epydoc modules, python-geoip, csstidy as well as an instance of imdbpy and csstidy. They can be installed in Debian using:

apt-get install python-setuptools python-tz python-openid python-epydoc python-imdbpy csstidy python-geoip

You may also need: pil, python-urljr and python-yadis (Windows users claimed they had to install those modules, they are probably in Ubuntu/Debian installed by default with Python).

Finally, you may want to install memcached. You don't need to install memcached unless you want to test/fix caching. The installation here: http://leavingcorporate.com/2008/05/04/installing-cmemcache-on-ubuntu. If you do not wish to use/test memcached locally, just enter _dummy//_as your caching engine in settings.py -- this is a dummy interface that does not actually do any cachingbut also does not break the app

d) Geo location

Geo-location is turned off by default. If you want to turn it on (e.g. you need to test it locally), you need to download the data file with locations from http://dev.filmaster.pl/static/db/GeoLiteCity.dat (guest/jakilinux) and place it at film20/film20/static. Then activate the geo module and geoMiddleware in settings.py.

Installing and running the actual app

  • Create a film20/settings.py file and fetcher/settings.py file
    Create it basing on settings.template if you haven't done it, yet. Changing the local paths should be enough to make it work.
  • Run either setup_english.sh or setup_polish.sh script to create missing symlinks:
./setup_english.sh
  • Alternatively, create the links yourself:

Create a symlink config/urls.py to config/urls/pl.py or config/urls/en.py depending on the configuration (choose one language):

ln -s film20/config/urls/en.py film20/config/urls.py

Similar symlink needs to be created for images and css files

ln -s film20/static/english.css film20/static/localized.css
ln -s film20/static/img/en film20/static/img/localized

We also need a folder with generic avatars

ln -s film20/static/avatars-dev film20/static/avatars
  • Eventually, run the app local server (by default we're using the django dev server to develop locally but if you prefer apache, you can set it up as well) using the manage.py script:
    python manage.py runserver
    

    Open a web browser (or IE) with url like: http://127.0.0.1:8000/
    The admin interface is here: http://127.0.0.1:8000/admin
    If you want to access the db as administrator you'll need to create a user account and then grant it the proper permissions manually in database.
    TODO: create a simple script that does that!
    And for avatars, as we don't want to keep them in svn

The DEV server

DEV server is localized at: http://dev.filmaster.com

It should always host a reasonably up-to-date version of the app (filmaster-test branch).

If dev does not work, please e-mail dev@filmaster.com.

If you checked something in that you believe makes the dev server not functional, try to correct it yourself by analyzing the recent commits in filmaster-test and if anything needs to be done on the dev server itself (like a settings.py change or a database change, also contect dev@filmaster.com to make us perform the tasks if you don't have the rights to ssh to the server to do it yourself).

Unit tests

The unit tests can be run by issuing a command like:

./manage.py test # whole app
./manage.py test import_ratings # only a specific module (like import_ratings)

Not that we have tons of tests. They are on constant TODO list, but we're planning to actually prioritize this task as regression testing becomes more and more of an issue.

In order to perform the tests, the postgres user needs permissions to drop/create tables (needs to be a super user). To achieve that, execute:

psql> ALTER USER film20 SET superuser = true;

or if you have PostgreSQL>8.3, do:

psql> ALTER USER film20 SUPERUSER

If you're using sqlite for unit tests, you don't need to worry about it.

Labels

setup setup Delete
documentation documentation Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.