<commit_before>from django.shortcuts import render_to_response
from article.models import Article

def articles(request):
    return render_to_response('articles.html', {'articles': Article.objects.all()})

def article(request, article_id):
    return render_to_response('article.html', {'article': Article.objects.get(id=article_id)})
<commit_msg>add session handling to views<commit_after>from django.shortcuts import render_to_response
from article.models import Article
# for sessions and cookies
from django.http import HttpResponse


def articles(request):
    # this on is stored in cookies
    language = 'en-gb'
    # this one is stored in session
    session_language = 'en-gb'

    if 'lang' in request.COOKIES:
        language = request.COOKIES['lang']

    return render_to_response('articles.html',
        {'articles': Article.objects.all(),
        'language' : language}
        )

def article(request, article_id):
    return render_to_response('article.html', {'article': Article.objects.get(id=article_id)})



def language(request, language='en-gb'):
    # this is rendered to the browser window - will print this on the page
    respone = HttpResponse("seting language to %s " % language)

    respone.set_cookie('lang', language)

    return respone
{'fraction_non_alphanumeric': 0.10604870384917518, 'fraction_numerical': 0.0, 'mean_word_length': 4.375527426160337, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1334152', 'n_tokens_mistral': 366, 'n_tokens_neox': 350, 'n_words': 104}