Codebase Documentation¶
This chapter covers the libraries that GNU MediaGoblin uses as well as various recipes for getting things done.
Note
This chapter is in flux. Clearly there are things here that aren’t documented. If there’s something you have questions about, please ask!
See the join page on the website for where we hang out.
For more information on how to get started hacking on GNU MediaGoblin, see the wiki.
Software Stack¶
Project infrastructure
Python: the language we’re using to write this
Nose: for unit tests
virtualenv: for setting up an isolated environment to keep mediagoblin and related packages (potentially not required if MediaGoblin is packaged for your distro)
Data storage
SQLAlchemy: SQL ORM and database interaction library for Python. Currently we support sqlite and postgress as backends.
Web application
Paste Deploy and Paste Script: we’ll use this for configuring and launching the application
WebOb: nice abstraction layer from HTTP requests, responses and WSGI bits
Routes: for URL routing
Beaker: for handling sessions and caching
Jinja2: the templating engine
WTForms: for handling, validation, and abstraction from HTML forms
Celery: for task queuing (resizing images, encoding video, …)
Babel: Used to extract and compile translations.
Markdown (for python): implementation of Markdown text-to-html tool to make it easy for people to write richtext comments, descriptions, and etc.
lxml: nice xml and html processing for python.
Media processing libraries
Python Imaging Library: used to resize and otherwise convert images for display.
GStreamer: (Optional, for video hosting sites only) Used to transcode video, and in the future, probably audio too.
chardet: (Optional, for ascii art hosting sites only) Used to make ascii art thumbnails.
Front end
JQuery: for groovy JavaScript things
What’s where¶
After you’ve run checked out mediagoblin and followed the virtualenv instantiation instructions, you’re faced with the following directory tree:
mediagoblin/
|- mediagoblin/ # source code
| |- tests/
| |- templates/
| |- auth/
| \- submit/
|- docs/ # documentation
|- devtools/ # some scripts for developer convenience
|
| # the below directories are installed into your virtualenv checkout
|
|- bin/ # scripts
|- develop-eggs/
|- lib/ # python libraries installed into your virtualenv
|- include/
|- mediagoblin.egg-info/
|- parts/
|- user_dev/ # sessions, etc
As you can see, all the code for GNU MediaGoblin is in the
mediagoblin
directory.
Here are some interesting files and what they do:
- routing.py:
maps url paths to views
- views.py:
views handle http requests
- models.py:
holds the sqlalchemy schemas—these are the data structures we’re working with
You’ll notice that there are several sub-directories: tests, templates, auth, submit, …
tests
holds the unit test code.
templates
holds all the templates for the output.
auth
and submit
are modules that enacpsulate authentication
and media item submission. If you look in these directories, you’ll
see they have their own routing.py
, view.py
, and
models.py
in addition to some other code.