This chapter covers the libraries that GNU MediaGoblin uses as well as various recipes for getting things done.
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, and specifically, go through the Hacking HOWTO which explains generally how to get going with running an instance for development.
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 | |- db/ # database setup | |- tools/ # various utilities | |- init/ # "initialization" tools (arguably should be in tools/) | |- tests/ # unit tests | |- templates/ # templates for this application | |- media_types/ # code for processing, displaying different media | |- storage/ # different storage backends | |- gmg_commands/ # command line tools (./bin/gmg) | |- themes/ # pre-bundled themes | | | | # ... some submodules here as well for different sections | | # of the application... here's just a few | |- auth/ # authentication (login/registration) code | |- user_dev/ # user pages (under /u/), including media pages | \- submit/ # submitting media for processing | |- docs/ # documentation |- devtools/ # some scripts for developer convenience | |- user_dev/ # local instance sessions, media, etc | | # 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/
As you can see, all the code for GNU MediaGoblin is in the
Here are some interesting files and what they do:
maps URL paths to views
views handle HTTP requests
wtforms stuff for this submodule
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.
submit are modules that encapsulate authentication
and media item submission. If you look in these directories, you’ll
see they have their own
view.py, and forms.py in
addition to some other code.
You’ll also notice that mediagoblin/db/ contains quite a few things, including the following:
This is where the database is set up
Certain functions appended to models from here
When creating a new migration (a change to the database structure), we put it here
SQLAlchemy: SQL ORM and database interaction library for Python. Currently we support SQLite and PostgreSQL as backends.
werkzeug: nice abstraction layer from HTTP requests, responses and WSGI bits
itsdangerous: for handling sessions
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.
lxml: nice XML and HTML processing for python.
Media processing libraries