|
a/Allura/allura/lib/helpers.py |
|
b/Allura/allura/lib/helpers.py |
|
... |
|
... |
27 |
import logging
|
27 |
import logging
|
28 |
import cPickle as pickle
|
28 |
import cPickle as pickle
|
29 |
from hashlib import sha1
|
29 |
from hashlib import sha1
|
30 |
from datetime import datetime, timedelta
|
30 |
from datetime import datetime, timedelta
|
31 |
from collections import defaultdict
|
31 |
from collections import defaultdict
|
|
|
32 |
import shlex
|
32 |
|
33 |
|
33 |
import tg
|
34 |
import tg
|
34 |
import genshi.template
|
35 |
import genshi.template
|
35 |
import chardet
|
36 |
import chardet
|
36 |
import pkg_resources
|
37 |
import pkg_resources
|
|
... |
|
... |
837 |
"""
|
838 |
"""
|
838 |
root = pkg_resources.get_distribution('allura').location
|
839 |
root = pkg_resources.get_distribution('allura').location
|
839 |
conf = appconfig('config:%s' % os.path.join(root, ini_path))
|
840 |
conf = appconfig('config:%s' % os.path.join(root, ini_path))
|
840 |
with ming_config(**conf):
|
841 |
with ming_config(**conf):
|
841 |
yield
|
842 |
yield
|
|
|
843 |
|
|
|
844 |
|
|
|
845 |
def split_select_field_options(field_options):
|
|
|
846 |
try:
|
|
|
847 |
# shlex have problems with parsing unicode,
|
|
|
848 |
# it's better to pass properly encoded byte-string
|
|
|
849 |
field_options = shlex.split(field_options.encode('utf-8'))
|
|
|
850 |
# convert splitted string back to unicode
|
|
|
851 |
field_options = map(really_unicode, field_options)
|
|
|
852 |
except ValueError:
|
|
|
853 |
field_options = field_options.split()
|
|
|
854 |
# After regular split field_options might contain a " characters,
|
|
|
855 |
# which would break html when rendered inside tag's value attr.
|
|
|
856 |
# Escaping doesn't help here, 'cause it breaks EasyWidgets' validation,
|
|
|
857 |
# so we're getting rid of those.
|
|
|
858 |
field_options = [o.replace('"', '') for o in field_options]
|
|
|
859 |
return field_options
|