Skip to content

This is an outdated repository containing an old attempt to build a website for the Python UserGroup Cologne. DO NOT USE!

Notifications You must be signed in to change notification settings

pycologne/website

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

87 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PyCologne Website

This is an outdated repository containing the code of an abandoned attempt at building a new website for the Python UserGroup Cologne pyCologne based on djangoCMS.

PLEASE DO NOT USE!

Go to this Bitbucket mercurial repository for the new website instead:

https://bitbucket.org/PySV/pycologne-app

Development

Pre-Requirements

  • Python 2
  • virtualenv
  • PostgreSQL
  • sqlite3

(including header files, i.e. on debian-like systems install the 'postgresql-dev' package)

Installation

  1. Either:

    • Clone this repository directly (website team members):

      $ git clone https://github.com/pycologne/website.git
      
    • Or fork this repository and clone your fork (others).

  1. Make a virtual environment using mkvirtualenv or mkproject, e.g.:

    $ mkvirtualenv [--no-site-packages] pycologne-website
    
  2. Install packages necessary for bootstrapping:

    $ pip install django fabric
    
  3. Change into the checkout directory and run:

    $ python -c "import uuid; print('SECRET_KEY = \"%s\"' % uuid.uuid1())" > \
        pycologne/settings/local.py
    $ fab install_dev_requirements
    $ python manage.py syncdb --all
    $ python manage.py migrate --fake
    $ python manage.py compilemessages
    
  4. Run the development server:

    $ fab devserver
    
  5. Send pull requests.

That's it! Happy developing :)

Staging server setup

Note

Commands noted below prefixed by a dollar-sign ($) prompt are shell commands and should be entered without that prompt.

  1. Install prerequisites via your distribution's package manager:

    $ sudo apt-get install build-essential curl git-core \
        python python-dev python-virtualenv python-pip postgresql nginx
    

    Note

    Make sure that the Python packages you install are for Python 2.7. On newer distribution you might have to change the python part in the package names to python2.

  2. Set up a dedicated user for the application on the server:

    $ sudo mkdir /home/www
    $ sudo adduser --home /home/www/pycologne.de pycologne
    
  3. Install virtualenvwrapper and set it up for the application user:

    $ sudo pip install virtualenvwrapper
    
  4. Create a PostgresSQL database (on debian do this as the user postgres):

    $ su - postgres
    (postgres)$ createuser -P -D -R -S pycologne-staging
    (postgres)$ createdb -O pycologne-staging pycologne-staging
    
  5. Edit /etc/postgresql/9.1/main/pg_hba.conf and add this line:

    local pycologne-staging pycologne-staging md5
    

    after the one that reads:

    local   all     postgres    ident
    

    (for a local trusted development machine, you might want to use instead):

    host    all         all         127.0.0.1/32                trust
    

    and reload the PostgreSQL configuration:

    sudo service postgresql reload
    

Now, log in as the new user pycologne. The following steps should all be carried out as this user, unless stated otherwise.

  1. Add the following to the end of ~ /.profile (or ~/.bash_profile, if you have it):

    if [ -d "$HOME/local" ] ; then
        PATH="$HOME/local/bin:$PATH"
    fi
    
    export WORKON_HOME=$HOME/lib/venvs
    export PIP_VIRTUALENV_BASE=$WORKON_HOME
    export PIP_RESPECT_VIRTUALENV=true
    export PIP_DOWNLOAD_CACHE="$HOME/.pip_download_cache"
    
    source /usr/local/bin/virtualenvwrapper.sh
    
  2. And create a few directories:

    $ mkdir -p ~/bin ~/etc ~/lib/venvs ~/local ~/sites \
        ~/var/{log,run,tmp} ~/.pip_download_cache
    
  3. Log out and log in again as user pycologne for the environment changes to take effect. On logging in you will see a bunch of messages by virtualenvwrappper while it creates some scripts under $WORKON_HOME.

  4. Install Node.js (from source):

    $ cd ~/var/tmp
    $ curl http://nodejs.org/dist/node-latest.tar.gz | tar -xz
    $ cd node-v0.10.*
    $ ./configure --prefix=~/local
    $ make install
    

    You can go and have a LARGE coffee while Node.js compiles.

  5. Install LESS:

    $ npm install -g less
    
  6. Create a virtualenv pycologne-staging:

    mkvirtualenv -p /usr/bin/python2 pycologne-staging
    

    The following commmands assume that you have activated the virtual environment pycologne-staging in your current shell.

  7. Check out the application code:

    $ mkdir -p ~/sites
    $ cd ~/sites
    $ git clone https://github.com/pycologne/website.git staging
    
  8. Create the file ~/sites/staging/pycologne/settings/local.py with the following content and change the password for the Postgres database user pycologne-staging in the DATABASES configuration directory to the one you chose above:

    import os
    
    if os.environ.get('ENV') == 'staging':
        DATABASES = {
            'default': {
                'ENGINE': 'django.db.backends.postgresql_psycopg2',
                'NAME': 'pycologne-staging',
                'USER': 'pycologne-staging',
                'PASSWORD': 'thepassword'
            }
        }
    
    ALLOWED_HOSTS = ["staging.pycologne.de"]
    

    Make sure this file is not world-readable:

    $ chmod 640 ~/sites/staging/pycologne/settings/local.py
    
  9. Install the application and initialize the database, message catalogs and static files:

    $ cd ~/sites/staging
    $ pip install django fabric
    $ python -c "import uuid;print('SECRET_KEY = \"%s\"'%uuid.uuid1())" \
        >> pycologne/settings/local.py
    $ fab install_stable_requirements
    $ ENV=staging python manage.py syncdb --all
    $ ENV=staging python manage.py migrate --fake
    $ ENV=staging python manage.py compilemessages
    $ ENV=staging python manage.py collectstatic --noinput
    

    Choose a user name and a secure password for the django CMS adminstration user when prompted. You will need those later to log into the web administration frontend.

  10. (As root) Install the Nginx configuration:

    $ sudo install -m 644 config/ngingx.conf \
        /etc/nginx/sites-available/staging.pycologne.de
    $ sudo ln -s ../sites-available/staging.pycologne.de \
        /etc/nginx/sites-enabled
    

    Make the log directory writable for the user Nginx runs under (normally www-data):

    $ sudo chgrp www-data ~/var/log
    $ sudo chmod g+w ~/var/log
    

    Then reload the Nginx configuration:

    $ sudo service nginx reload
    
  11. Install the supervisor daemon configuration:

    $ install -m 640 config/supervisor{,d}.conf ~/etc
    $ mkdir ~/etc/supervisor.conf.d
    $ install -m 640 config/supervisord-pycologne.conf \
        ~/etc/supervisord.conf.d/pycologne.conf
    
  12. Finally, you should now be able to start the application server via supervisor:

    $ supervisord -c ~/etc/supervisord.conf
    

    You can check the status of the application server with supervisorctl:

    $ supervisorctl -c ~/etc/supervisor.conf status
    

Credits

Parts of this project are based on work by the Python Software Foundation (PySV) for the PyCon.DE Website (see https://bitbucket.org/PySV/pycon_de_website) - which in turn is based on the Symposion apps.

About

This is an outdated repository containing an old attempt to build a website for the Python UserGroup Cologne. DO NOT USE!

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published