Table of Contents
Overview
This document describes the soup-to-nuts engineering process for creating and maintaining a "cspace_django_project" Project for your institution. This process is the culmination of some months of experimentation and development at UCB, and what you see here is really the tip of the iceberg. The many details of how this process came about, its motivations, and its justification, are here.
...
Creating a new CSpace Django Project for an institution
Skip this step unless you are the one creating a GitHub repo for your institution's Project(s).
The UCB practice for Django Webapps is to have one (or perhaps more) Django Projects per institution. Each of these is forked from the parent project, called cspace_django_project and is maintained as a separate entity.
The "normal" project creation workflow assumes you are the developer who will be creating the instituitioninstitution's initial project and webapps, and further that you are a CollectionSpace committer who can add repos under http://github.com/cspace-deployment. However, such permissions are not required. Read up here for the distinction in roles
...
Checking out an existing institution's project for development
Once More likely, however, an institutional project already exists in GitHub (typically, it will be called something like myinstitution_project)
, you and
you can check the code for it out from GitHub and do what you need to do on your local system. In general, we don't modify code directly on our VM deployments. The process of getting your code back into a GitHub repo and making deployments and releases is described further below.
- From PyCharm checkout the project, or better yet, your own fork of the project; : from the command line: git git clone http://github.com/cspace-deployment/myinstitution_project.git
- Open this directory in PyCharm on your local machine
- Configure the project to run locally (i.e. created needed local infrastructure (directories, etc.), local configuration files, etc.)
- Run the development server or debugger in PyCharm
For the gory details, you can look at:
Creating of a new webapp for an existing project
If Once you have a local clone of the institution's repo, you can add or modify the code. If the webapp you want to work on exists, go to the next step, otherwise:
- Run startapp (link to Django docs) or copy an existing app directory to a new directory and customize from there.
- Edit cspace_django_site/settings.py (INSTALLED_APPS)
- Edit cspace_django_site/urls.py (urlpatterns)
- Resolve any other site-level dependencies: logging, cacheing, configuration, other python or code dependencies
- Create an example config file (if necessary) See: Use of the config directory and .cfg files
There is nothing special about the steps here: they are the standard steps for creating an application within a Django project. Except that you should plan to adhere to some of the coding and configuration conventions used for these CSpace-enable webapps.
Maintaining an existing webapp
"Maintaining" here means making modifications to existing code and pushing them back to GitHub. The actual release process is documented
- Check out latest code (details?see Checking out an existing institution's project for development, above)
- Modify
- Test on your local system
git add
and test, modify and test, ...git add ...
git commit -m ...
git push
(where exactly?to your own Git repo, or directly up to the cspace-deployment repo. See Making a Release.)
Deploying an institution project to a "Linux Server"
...
Basically the procedure is as follows:
...
the same as those for development deployment with PyCharm, but some important details differ. Here are the steps.
- Verify operating environment, resolve dependencies (Apache and mod_wsgi, Python, Django, virtenv, SELinux, python packages)
- Clone project to
/usr/local/share/django
(this is the UCB "standard" for Django deployments) - Modify Apache configuration to accomodate new project (i.e. edit conf/wsgi.conf, see )
- Copy example config configuration file(s) to
config/
and customize per deployment (if anyneeded) - Restart Apache (
sudo service httpd graceful
) - Verify webapp function (e.g. by visiting their start pages in a browser)
The myriad practical details that need to be considered at UCB may be found herefound at:
- CSpace-Django webapps - setting up a production environment using Apache
- CSpace-Django webapps - setting up configuration for your project
Pushing your spiffy revised project to Dev or Production Server
Your Let's suppose your project is already deployed and running (see the step above). You have made some wonderful fixes and improvements and you need to update the code on the server to the latest version. Assuming your changes have been pushed up to the master branch of your institutions repo, you need only pull the code changes for that release into the deployed project's repo on the target server (keeping any local mods via git stash
) and restarting Apache:
ssh
in to the servercd /usr/local/share/django/my_project
sudo git pull -v
- make any local mods required: e.g. update/add configuration file(if neededs) (: "
sudo vi config/webapp.cfg
") sudo manage.py collectstatic
sudo service httpd graceful
...