-
Notifications
You must be signed in to change notification settings - Fork 378
GettingStarted
This is an attempt to help newcomers to code sprints to get going with the IETF tools.
-
A working knowledge of python and/or web design
-
Learn the basic concepts of Django, e.g., work through the excellent tutorial.
-
Bring a laptop with Python (2.4/2.5/2.6), subversion and mysql (4.x is ok, 5.x is better) installed, and be ready to check out a branch of the IETF web site from the tools svn server.
-
Check out the source code for the sprint; the SVN command should be on the Sprint's page
The "ietf/templates/" directory contains Django templates used to generate web pages for the datatracker, mailing list, wgcharter and other things.
Most of the other "ietf" sub-directories, such as "idtracker", contain the python/Django model and view information that go with the related templates. In these directories, the key files are:
urls.py |
binds a URL to a view, possibly selecting some data from the model. |
---|---|
models.py |
This has the data models for the tool area. |
views.py |
This has the views for this tool area, and is where views are bound to the template. |
To add a new page to the tools, first explore the models.py
to see if the model you need already exists. Within models.py
are classes such as:
class IETFWG(models.Model):
ACTIVE = 1
group_acronym = models.ForeignKey(Acronym, primary_key=True, unique=True, editable=False)
group_type = models.ForeignKey(WGType)
proposed_date = models.DateField(null=True, blank=True)
start_date = models.DateField(null=True, blank=True)
dormant_date = models.DateField(null=True, blank=True)
...
In this example, the IETFWG
class can be used to reference various fields of the database including group_type
. Of note here is that group_acronym
is the Acronym
model so fields in that model can be accessed (e.g., group_acronym.name
).
Next, add a template for the new page in the proper sub-directory of the ietf/templates
directory. For a simple page that iterates over one type of object, the key part of the template will look something like this:
{% for wg in object_list %}
<tr>
<td><a href="[ wg.email_archive ]">[ wg ]</a></td>
<td>[ wg.group_acronym.name ]</td>
</tr>
{% endfor %}
In this case, we're expecting object_list
to be passed to the template from the view and expecting it to contain objects with the IETFWG
model.
Then add a view for the template to views.py
. A simple view might look like:
def list_wgwebmail(request):
wgs = IETFWG.objects.all();
return render_to_response('mailinglists/wgwebmail_list.html', {'object_list': wgs})
The selects the IETFWG objects from the database and renders the template with them in object_list
. The model you're using has to be explicitly imported at the top of views.py
in the imports statement.
Finally, add a URL to display the view to urls.py
. For this example, the reference to list_wgwebmail
view is called:
urlpatterns += patterns('',
...
(r'^wg/$', views.list_wgwebmail),
)
Assuming you have the database settings configured already, you can run the server locally with:
PYTHONPATH=../ python manage.py runserver localhost:<port>`
where <port>
is arbitrary. Then connect your web browser to localhost:<port>
and provide the URL to see your work.