Switch to unified view

a/Allura/allura/lib/utils.py b/Allura/allura/lib/utils.py
...
...
3
import hashlib
3
import hashlib
4
import binascii
4
import binascii
5
import logging
5
import logging
6
import random
6
import random
7
import mimetypes
7
import mimetypes
8
from itertools import groupby
8
from logging.handlers import WatchedFileHandler
9
from logging.handlers import WatchedFileHandler
9
10
10
import tg
11
import tg
11
import pylons
12
import pylons
12
import webob.multidict
13
import webob.multidict
...
...
148
        while (ord(s[k]) & 0xc0) == 0x80:
149
        while (ord(s[k]) & 0xc0) == 0x80:
149
            k -= 1
150
            k -= 1
150
        return s[:k]
151
        return s[:k]
151
    return s
152
    return s
152
153
154
155
def chunked_iter(iterable, max_size):
156
    '''return iterable 'chunks' from the iterable of max size max_size'''
157
    eiter = enumerate(iterable)
158
    keyfunc = lambda (i,x): i//max_size
159
    for _, chunk in groupby(eiter, keyfunc):
160
        yield (x for i,x in chunk)
153
161
154
class AntiSpam(object):
162
class AntiSpam(object):
155
    '''Helper class for bot-protecting forms'''
163
    '''Helper class for bot-protecting forms'''
156
    honey_field_template=string.Template('''<p class="$honey_class">
164
    honey_field_template=string.Template('''<p class="$honey_class">
157
    <label for="$fld_id">You seem to have CSS turned off.
165
    <label for="$fld_id">You seem to have CSS turned off.
...
...
341
349
342
    def update(self, *args, **kwargs):
350
    def update(self, *args, **kwargs):
343
        super(CaseInsensitiveDict, self).update(*args, **kwargs)
351
        super(CaseInsensitiveDict, self).update(*args, **kwargs)
344
        self._reindex()
352
        self._reindex()
345
353
354
def postmortem_hook(etype, value, tb): # pragma no cover
355
    import sys, pdb, traceback
356
    try:
357
        from IPython.ipapi import make_session; make_session()
358
        from IPython.Debugger import Pdb
359
        sys.stderr.write('Entering post-mortem IPDB shell\n')
360
        p = Pdb(color_scheme='Linux')
361
        p.reset()
362
        p.setup(None, tb)
363
        p.print_stack_trace()
364
        sys.stderr.write('%s: %s\n' % ( etype, value))
365
        p.cmdloop()
366
        p.forget()
367
        # p.interaction(None, tb)
368
    except ImportError:
369
        sys.stderr.write('Entering post-mortem PDB shell\n')
370
        traceback.print_exception(etype, value, tb)
371
        pdb.post_mortem(tb)