def ajax_get_state(request, **kwargs):
    formdata = request.REQUEST.copy()

    try:
        if formdata.has_key("country"):
            country_field = 'country'
        elif formdata.has_key("ship_country"):
            country_field = 'ship_country'
        else:
            raise AjaxGetStateException("No country specified")

        form = ContactInfoForm(data=formdata)
        country_data = formdata.get(country_field)
        try:
            country_obj = form.fields[country_field].clean(country_data)
        except:
            raise AjaxGetStateException("Invalid country specified")

        areas = area_choices_for_country(country_obj, ugettext)

        context = RequestContext(request, {
            'areas': areas,
        })
        return render_to_response('contact/_state_choices.html',
                                  context_instance=context)
    except AjaxGetStateException, e:
        log.error("ajax_get_state aborting: %s" % e.message)

    return http.HttpResponseServerError()
dataset/ETHPy150Open dokterbob/satchmo/satchmo/apps/satchmo_store/contact/views.py/ajax_get_state/original