Download all pages of a forum thread

I recently found myself wanting to save a thread that had over 200 pages. Saving each of them manually would have been long and painful, so I decided to create a small script in python that will save each page:

import urllib
url_prefix = "the site url prefix here"
forum = forum number
thread = thread number
pages = range(thread_start_index, thread_end_index, thread_step)
file_prefix = "file prefix here"
page_count = len(pages)
file_suffix = ".html"

for page in pages:
    url = "thread format here" % (url_prefix,forum,thread,page)
    url_handle = urllib.urlopen(url)
    page_index = (page / thread_step) + 1
    file_page = "%dof%d" % (page_index, page_count)
    filename = "%s%s%s" % (file_prefix, file_page, file_suffix)

    file_handle = open(filename, 'w')

    for lines in url_handle.readlines():
        file_handle.write(lines)

    file_handle.close()
    url_handle.close()

Django save_model not being called on create

I just spent an hour trying to figure out why my save_model was not being called on the creation of a model but got called fine during edits. It's not like the save_model code was particularly complicated or anything like that. It was, in fact, about as simple as it got:

def save_model(self,request,model,form,change):
    if not change:
        model.created_by = request.user
    model.save()

If this doesn't work, make sure you are developing against the latest Django version. A bug was reported and fixed 5-6 months ago, so you might already have the latest version, but make sure.

1 of 1 pages

On the Side