Ejemplo n.º 1
0
def results(request, result_id=None):
    if result_id:
        result = get_object_or_404(Result, pk=result_id)
        # XXX: remove this when it works
        result.process()
        result.save()
    else:
        action = request.POST.get('action')
        if action == 'text':
            # process text
            form = ValidateTextForm(request.POST)
            if form.is_valid():
                result = Result(input=form.cleaned_data['text'])
                try:
                    result.process()
                except LapinError, exception:
                    return render_to_response('validator/error.html', locals(), request)
                result.save()
                return HttpResponseRedirect(result.get_absolute_url())
            else:
                return HttpResponseRedirect('/')
        else:
Ejemplo n.º 2
0
 def testParser(self):
     path = os.path.join(os.path.dirname(__file__), 'test.galaxy')
     result = Result(input=open(path, 'r').read())
     output = result.process()
     print output