Removing old style migrations... not in use anymore
[mediagoblin.git] / docs / hackinghowto.rst
CommitLineData
5a40e1ec
WKG
1.. _hacking-howto:
2
00fdc7bd
WKG
3===============
4 Hacking HOWTO
5===============
6
6729d65a
WKG
7.. contents:: Sections
8 :local:
9
10
5a40e1ec
WKG
11So you want to hack on GNU MediaGoblin?
12=======================================
56d507b6 13
9d952fdc 14First thing to do is check out the `Web site
9610848c 15<http://mediagoblin.org/join/>`_ where we list all the project
9d952fdc 16infrastructure including:
56d507b6 17
56d507b6 18* the IRC channel
9610848c
WKG
19* the mailing list
20* the issue tracker
56d507b6
WKG
21
22Additionally, we have information on how to get involved, who to talk
23to, what needs to be worked on, and other things besides!
24
9610848c
WKG
25Second thing to do is take a look at :ref:`codebase-chapter` where
26we've started documenting how GNU MediaGoblin is built and how to add
27new things.
28
4564da22
WKG
29Third you'll need to :ref:`get the requirements
30<get-requirements-section>`.
56d507b6 31
2aa3bb11
WKG
32Fourth, you'll need to build a development environment. We use buildout,
33but if you want to use virtualenv, there's a set of mediocre not-very-supported
34steps in the `wiki <https://gitorious.org/mediagoblin/pages/Home>`_.
4564da22
WKG
35
36
37.. _get-requirements-section:
56d507b6 38
c66d0f5c 39Getting requirements
4564da22 40====================
56d507b6 41
c66d0f5c
WKG
42First, you need to have the following installed before you can build
43an environment for hacking on GNU MediaGoblin:
56d507b6 44
c66d0f5c 45* Python 2.6 or 2.7 - http://www.python.org/
56d507b6 46
c66d0f5c 47 You'll need Python as well as the dev files for building modules.
56d507b6 48
c66d0f5c
WKG
49* python-lxml - http://lxml.de/
50* git - http://git-scm.com/
51* MongoDB - http://www.mongodb.org/
52
53If you're running Debian GNU/Linux or a Debian-derived distribution
54such as Mint or Ubuntu, running the following should install these
55requirements::
56
5740a0d6
WKG
57 sudo apt-get install mongodb git-core python python-dev \
58 python-lxml
c66d0f5c 59
983e11f0
CAW
60On Fedora::
61
62 yum install mongodb-server python-paste-deploy python-paste-script \
63 git-core python python-devel
64
4564da22 65.. YouCanHelp::
52be418a 66
4564da22
WKG
67 If you have instructions for other GNU/Linux distributions to set
68 up requirements, let us know!
52be418a 69
52be418a 70
7a5ddb45
CAW
71.. _hacking-with-buildout:
72
2aa3bb11 73
7a5ddb45
CAW
74How to set up and maintain an environment for hacking with buildout
75===================================================================
76
7a5ddb45
CAW
77**Requirements**
78
79No additional requirements.
80
81
82**Create a development environment**
83
84After installing the requirements, follow these steps:
85
861. Clone the repository::
87
88 git clone http://git.gitorious.org/mediagoblin/mediagoblin.git
89
902. Bootstrap and run buildout::
91
92 cd mediagoblin
93 python bootstrap.py && ./bin/buildout
94
95
96That's it! Using this method, buildout should create a ``user_dev``
97directory, in which certain things will be stored (media, beaker
98session stuff, etc). You can change this, but for development
99purposes this default should be fine.
100
101
102**Updating for dependency changes**
103
104While hacking on GNU MediaGoblin over time, you'll eventually have to
105update your development environment because the dependencies have
106changed. To do that, run::
107
f4cfb4e9 108 ./bin/buildout && ./bin/gmg migrate
7a5ddb45
CAW
109
110
111**Updating for code changes**
112
113You don't need to do anything---code changes are automatically
114available.
115
116
117**Deleting your buildout**
118
119At some point, you may want to delete your buildout. Perhaps it's to
120start over. Perhaps it's to test building development environments
121with buildout.
122
123To do this, do::
124
125 rm -rf bin develop-eggs eggs mediagoblin.egg-info parts user_dev
126
4564da22 127
11e5b197
CAW
128Running the server
129==================
130
f1fadb64
CAW
131If you want to get things running quickly and without hassle, just
132run::
133
134 ./lazyserver.sh
135
136This will start up a python server where you can begin playing with
137mediagoblin. It will also run celery in "always eager" mode so you
138don't have to start a separate process for it.
139
140This is fine in development, but if you want to actually run celery
141separately for testing (or deployment purposes), you'll want to run
142the server independently::
11e5b197 143
41f965c5 144 ./bin/paster serve paste.ini --reload
11e5b197
CAW
145
146
1c424df5
CAW
147Running celeryd
148===============
149
f1fadb64
CAW
150If you aren't using ./lazyserver.sh or otherwise aren't running celery
151in always eager mode, you'll need to do this if you want your media to
152process and actually show up. It's probably a good idea in
153development to have the web server (above) running in one terminal and
154celeryd in another window.
1c424df5 155
2aa3bb11 156Run::
1c424df5 157
073b61fe 158 CELERY_CONFIG_MODULE=mediagoblin.init.celery.from_celery ./bin/celeryd
1c424df5
CAW
159
160
11e5b197
CAW
161Running the test suite
162======================
163
2aa3bb11 164Run::
11e5b197 165
8b7663a0 166 ./runtests.sh
11e5b197
CAW
167
168
3e4a2f2b
CAW
169Running a shell
170===============
171
172If you want a shell with your database pre-setup and an instantiated
2aa3bb11 173application ready and at your fingertips....
3e4a2f2b 174
2aa3bb11 175Run::
3e4a2f2b
CAW
176
177 ./bin/gmg shell
178
3e4a2f2b 179
4564da22
WKG
180Troubleshooting
181===============
5740a0d6 182
4564da22
WKG
183pymongo.errors.AutoReconnect: could not find master/primary
184-----------------------------------------------------------
9d952fdc 185
4564da22 186If you see this::
9d952fdc 187
4564da22 188 pymongo.errors.AutoReconnect: could not find master/primary
9d952fdc 189
4564da22 190then make sure mongodb is installed and running.
5740a0d6 191
2aa3bb11
WKG
192If it's installed, check the mongodb log. On my machine, that's
193``/var/log/mongodb/mongodb.log``. If you see something like::
2704f7a6
WKG
194
195 old lock file: /var/lib/mongodb/mongod.lock. probably means...
196
197Then delete the lock file and relaunch mongodb.
198
5740a0d6 199
4564da22
WKG
200Wiping your user data
201=====================
202
203.. Note::
204
205 Unless you're doing development and working on and testing creating
206 a new instance, you will probably never have to do this. Will
207 plans to do this work and thus he documented it.
9610848c
WKG
208
209.. YouCanHelp::
210
1b734c4d
CAW
211 If you're familiar with MongoDB, we'd love to get a `script that
212 removes all the GNU MediaGoblin data from an existing instance
213 <http://bugs.foocorp.net/issues/296>`_. Let us know!
5740a0d6
WKG
214
215
9610848c
WKG
216Quickstart for Django programmers
217=================================
5740a0d6 218
9610848c
WKG
219We're not using Django, but the codebase is very Django-like in its
220structure.
5740a0d6 221
9610848c
WKG
222* ``routing.py`` is like ``urls.py`` in Django
223* ``models.py`` has mongokit ORM definitions
224* ``views.py`` is where the views go
5740a0d6 225
9610848c
WKG
226We're using MongoDB. Basically, instead of a relational database with
227tables, you have a big JSON structure which acts a lot like a Python
228dict.
5740a0d6
WKG
229
230
9610848c 231.. YouCanHelp::
5a40e1ec 232
9610848c
WKG
233 If there are other things that you think would help orient someone
234 new to GNU MediaGoblin but coming from Django, let us know!
5a40e1ec
WKG
235
236
237Bite-sized bugs to start with
238=============================
239
9610848c
WKG
240**May 3rd, 2011**: We don't have a list of bite-sized bugs, yet, but
241this is important to us. If you're interested in things to work on,
242let us know on `the mailing list <http://mediagoblin.org/join/>`_ or
243on the `IRC channel <http://mediagoblin.org/join/>`_.
9d952fdc
WKG
244
245
246Tips for people new to coding
247=============================
248
845c3ae2
WKG
249Learning Python
250---------------
9d952fdc
WKG
251
252GNU MediaGoblin is written using a programming language called `Python
253<http://python.org/>`_.
254
255There are two different incompatible iterations of Python which I'll
256refer to as Python 2 and Python 3. GNU MediaGoblin is written in
257Python 2 and requires Python 2.6 or 2.7. At some point, we might
258switch to Python 3, but that's a future thing.
259
260You can learn how to code in Python 2 from several excellent books
261that are freely available on the Internet:
262
263* `Learn Python the Hard Way <http://learnpythonthehardway.org/>`_
264* `Dive Into Pyton <http://diveintopython.org/>`_
265* `Python for Software Design <http://www.greenteapress.com/thinkpython/>`_
266* `A Byte of Python <http://www.swaroopch.com/notes/Python>`_
267
268These are all excellent texts.
269
9610848c
WKG
270.. YouCanHelp::
271
272 If you know of other good quality Python tutorials and Python
273 tutorial videos, let us know!
9d952fdc
WKG
274
275
845c3ae2
WKG
276Learning Libraries GNU MediaGoblin uses
277---------------------------------------
9d952fdc
WKG
278
279GNU MediaGoblin uses a variety of libraries in order to do what it
3dca2776 280does. These libraries are listed in the :ref:`codebase-chapter`
9d952fdc
WKG
281along with links to the project Web sites and documentation for the
282libraries.
283
284There are a variety of Python-related conferences every year that have
285sessions covering many aspects of these libraries. You can find them
286at `Python Miro Community <http://python.mirocommunity.org>`_ [0]_.
287
288.. [0] This is a shameless plug. Will Kahn-Greene runs Python Miro
289 Community.
290
291If you have questions or need help, find us on the mailing list and on
292IRC.
845c3ae2
WKG
293
294
295.. _hacking-howto-git:
296
297Learning git
298------------
299
300git is an interesting and very powerful tool. Like all powerful
301tools, it has a learning curve.
302
303If you're new to git, we highly recommend the following resources for
304getting the hang of it:
305
306* `Learn Git <http://learn.github.com/p/intro.html>`_ --- the GitHub
307 intro to git
308* `Pro Git <http://progit.org/book/>`_ --- fantastic book
309* `Git casts <http://gitcasts.com/>`_ --- screencast covering git
310 usage
311* `Git Reference <http://gitref.org/>`_ --- Git reference that makes
312 it easier to get the hang of git if you're coming from other version
313 control systems
314
2aa3bb11
WKG
315There's also a git mission at `OpenHatch <http://openhatch.org/>`_.
316
845c3ae2
WKG
317
318Learning other utilities
319------------------------
320
321The `OpenHatch <http://openhatch.org/>`_ site has a series of
322`training missions <http://openhatch.org/missions/>`_ which are
323designed to help you learn how to use these tools.
324
2aa3bb11
WKG
325If you're new to tar, diff, patch and git, we highly recommend you sign
326up with OpenHatch and do the missions.