~widelands-dev/widelands-website/django_staticfiles

« back to all changes in this revision

Viewing changes to pybb/util.py

  • Committer: franku
  • Date: 2016-03-16 10:25:56 UTC
  • mto: This revision was merged to the branch mainline in revision 409.
  • Revision ID: somal@arcor.de-20160316102556-vvsjlpdhi1j25423
runthrough deprecation timeline; fixed some things; added NOCOMMs

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
            if not isinstance(output, dict):
33
33
                return output
34
34
            kwargs = {'context_instance': RequestContext(request)}
 
35
 
 
36
            # NOCOMM: 'MIME_TYPE' is never in output as i can see for now.
 
37
            # But if, this should maybe 'content_type' instead
35
38
            if 'MIME_TYPE' in output:
36
39
                kwargs['mimetype'] = output.pop('MIME_TYPE')
37
40
            if 'TEMPLATE' in output:
122
125
    """
123
126
    HttpResponse subclass that serialize data into JSON format.
124
127
    """
125
 
 
 
128
    # NOCOMM: The mimetype argument maybe must be replaced with content_type
126
129
    def __init__(self, data, mimetype='application/json'):
127
130
        json_data = LazyJSONEncoder().encode(data)
128
131
        super(JsonResponse, self).__init__(
150
153
        Do not urlize content of A and CODE tags.
151
154
        """
152
155
 
153
 
        soup = BeautifulSoup(data)
 
156
        soup = BeautifulSoup(data, "html.parser")
154
157
        for chunk in soup.findAll(text=True):
155
158
            islink = False
156
159
            ptr = chunk.parent
240
243
    return page, paginator
241
244
 
242
245
 
 
246
# NOCOMM: This function is never used AFAIK
 
247
# 'django_language' isn't available since django 1.8
243
248
def set_language(request, language):
244
249
    """
245
250
    Change the language of session of authenticated user.
246
251
    """
247
 
 
248
252
    if language and check_for_language(language):
249
253
        if hasattr(request, 'session'):
250
254
            request.session['django_language'] = language