##// END OF EJS Templates
implements #212 moved default encoding variable into rhodecode-config. It's now possible to change...
marcink -
r2016:6020e388 beta
parent child Browse files
Show More
@@ -46,16 +46,17 b' port = 5000'
46 use = egg:rhodecode
46 use = egg:rhodecode
47 full_stack = true
47 full_stack = true
48 static_files = true
48 static_files = true
49 lang=en
49 lang = en
50 cache_dir = %(here)s/data
50 cache_dir = %(here)s/data
51 index_dir = %(here)s/data/index
51 index_dir = %(here)s/data/index
52 app_instance_uuid = develop
52 app_instance_uuid = rc-develop
53 cut_off_limit = 256000
53 cut_off_limit = 256000
54 force_https = false
54 force_https = false
55 commit_parse_limit = 25
55 commit_parse_limit = 25
56 use_gravatar = true
56 use_gravatar = true
57 container_auth_enabled = false
57 container_auth_enabled = false
58 proxypass_auth_enabled = false
58 proxypass_auth_enabled = false
59 default_encoding = utf8
59
60
60 ## overwrite schema of clone url
61 ## overwrite schema of clone url
61 ## available vars:
62 ## available vars:
@@ -86,6 +87,11 b' issue_server_link = https://myissueserve'
86
87
87 issue_prefix = #
88 issue_prefix = #
88
89
90 ## instance-id prefix
91 ## a prefix key for this instance used for cache invalidation when running
92 ## multiple instances of rhodecode, make sure it's globally unique for
93 ## all running rhodecode instances. Leave empty if you don't use it
94 instance_id =
89
95
90 ####################################
96 ####################################
91 ### CELERY CONFIG ####
97 ### CELERY CONFIG ####
@@ -179,7 +185,7 b' beaker.session.auto = False'
179 ##true exire at browser close
185 ##true exire at browser close
180 #beaker.session.cookie_expires = 3600
186 #beaker.session.cookie_expires = 3600
181
187
182
188
183 ################################################################################
189 ################################################################################
184 ## WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT* ##
190 ## WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT* ##
185 ## Debug mode will enable the interactive debugging tool, allowing ANYONE to ##
191 ## Debug mode will enable the interactive debugging tool, allowing ANYONE to ##
@@ -46,16 +46,17 b' port = 8001'
46 use = egg:rhodecode
46 use = egg:rhodecode
47 full_stack = true
47 full_stack = true
48 static_files = true
48 static_files = true
49 lang=en
49 lang = en
50 cache_dir = %(here)s/data
50 cache_dir = %(here)s/data
51 index_dir = %(here)s/data/index
51 index_dir = %(here)s/data/index
52 app_instance_uuid = prod1234
52 app_instance_uuid = rc-production
53 cut_off_limit = 256000
53 cut_off_limit = 256000
54 force_https = false
54 force_https = false
55 commit_parse_limit = 50
55 commit_parse_limit = 50
56 use_gravatar = true
56 use_gravatar = true
57 container_auth_enabled = false
57 container_auth_enabled = false
58 proxypass_auth_enabled = false
58 proxypass_auth_enabled = false
59 default_encoding = utf8
59
60
60 ## overwrite schema of clone url
61 ## overwrite schema of clone url
61 ## available vars:
62 ## available vars:
@@ -86,6 +87,11 b' issue_server_link = https://myissueserve'
86
87
87 issue_prefix = #
88 issue_prefix = #
88
89
90 ## instance-id prefix
91 ## a prefix key for this instance used for cache invalidation when running
92 ## multiple instances of rhodecode, make sure it's globally unique for
93 ## all running rhodecode instances. Leave empty if you don't use it
94 instance_id =
89
95
90 ####################################
96 ####################################
91 ### CELERY CONFIG ####
97 ### CELERY CONFIG ####
@@ -165,6 +171,7 b' beaker.cache.sql_cache_long.key_length ='
165
171
166 beaker.session.type = file
172 beaker.session.type = file
167 beaker.session.key = rhodecode
173 beaker.session.key = rhodecode
174 # secure cookie requires AES python libraries
168 #beaker.session.encrypt_key = g654dcno0-9873jhgfreyu
175 #beaker.session.encrypt_key = g654dcno0-9873jhgfreyu
169 #beaker.session.validate_key = 9712sds2212c--zxc123
176 #beaker.session.validate_key = 9712sds2212c--zxc123
170 beaker.session.timeout = 36000
177 beaker.session.timeout = 36000
@@ -46,16 +46,17 b' port = 5000'
46 use = egg:rhodecode
46 use = egg:rhodecode
47 full_stack = true
47 full_stack = true
48 static_files = true
48 static_files = true
49 lang=en
49 lang = en
50 cache_dir = %(here)s/data
50 cache_dir = %(here)s/data
51 index_dir = %(here)s/data/index
51 index_dir = %(here)s/data/index
52 app_instance_uuid = ${app_instance_uuid}
52 app_instance_uuid = ${app_instance_uuid}
53 cut_off_limit = 256000
53 cut_off_limit = 256000
54 force_https = false
54 force_https = false
55 commit_parse_limit = 50
55 commit_parse_limit = 50
56 use_gravatar = true
56 use_gravatar = true
57 container_auth_enabled = false
57 container_auth_enabled = false
58 proxypass_auth_enabled = false
58 proxypass_auth_enabled = false
59 default_encoding = utf8
59
60
60 ## overwrite schema of clone url
61 ## overwrite schema of clone url
61 ## available vars:
62 ## available vars:
@@ -65,7 +66,7 b' proxypass_auth_enabled = false'
65 ## netloc - network location
66 ## netloc - network location
66 ## path - usually repo_name
67 ## path - usually repo_name
67
68
68 # clone_uri = {scheme}://{user}{pass}{netloc}{path}
69 #clone_uri = {scheme}://{user}{pass}{netloc}{path}
69
70
70 ## issue tracking mapping for commits messages
71 ## issue tracking mapping for commits messages
71 ## comment out issue_pat, issue_server, issue_prefix to enable
72 ## comment out issue_pat, issue_server, issue_prefix to enable
@@ -86,6 +87,11 b' issue_server_link = https://myissueserve'
86
87
87 issue_prefix = #
88 issue_prefix = #
88
89
90 ## instance-id prefix
91 ## a prefix key for this instance used for cache invalidation when running
92 ## multiple instances of rhodecode, make sure it's globally unique for
93 ## all running rhodecode instances. Leave empty if you don't use it
94 instance_id =
89
95
90 ####################################
96 ####################################
91 ### CELERY CONFIG ####
97 ### CELERY CONFIG ####
@@ -272,13 +278,13 b' propagate = 0'
272 class = StreamHandler
278 class = StreamHandler
273 args = (sys.stderr,)
279 args = (sys.stderr,)
274 level = INFO
280 level = INFO
275 formatter = color_formatter
281 formatter = generic
276
282
277 [handler_console_sql]
283 [handler_console_sql]
278 class = StreamHandler
284 class = StreamHandler
279 args = (sys.stderr,)
285 args = (sys.stderr,)
280 level = WARN
286 level = WARN
281 formatter = color_formatter_sql
287 formatter = generic
282
288
283 ################
289 ################
284 ## FORMATTERS ##
290 ## FORMATTERS ##
@@ -296,4 +302,4 b' datefmt = %Y-%m-%d %H:%M:%S'
296 [formatter_color_formatter_sql]
302 [formatter_color_formatter_sql]
297 class=rhodecode.lib.colored_formatter.ColorFormatterSql
303 class=rhodecode.lib.colored_formatter.ColorFormatterSql
298 format= %(asctime)s.%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s
304 format= %(asctime)s.%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s
299 datefmt = %Y-%m-%d %H:%M:%S No newline at end of file
305 datefmt = %Y-%m-%d %H:%M:%S
@@ -41,12 +41,11 b' def load_environment(global_conf, app_co'
41
41
42 # store some globals into rhodecode
42 # store some globals into rhodecode
43 rhodecode.CELERY_ON = str2bool(config['app_conf'].get('use_celery'))
43 rhodecode.CELERY_ON = str2bool(config['app_conf'].get('use_celery'))
44 rhodecode.CONFIG = config
45
44
46 config['routes.map'] = make_map(config)
45 config['routes.map'] = make_map(config)
47 config['pylons.app_globals'] = app_globals.Globals(config)
46 config['pylons.app_globals'] = app_globals.Globals(config)
48 config['pylons.h'] = rhodecode.lib.helpers
47 config['pylons.h'] = rhodecode.lib.helpers
49
48 rhodecode.CONFIG = config
50 # Setup cache object as early as possible
49 # Setup cache object as early as possible
51 import pylons
50 import pylons
52 pylons.cache._push_object(config['pylons.app_globals'].cache)
51 pylons.cache._push_object(config['pylons.app_globals'].cache)
@@ -59,7 +58,7 b' def load_environment(global_conf, app_co'
59 input_encoding='utf-8', default_filters=['escape'],
58 input_encoding='utf-8', default_filters=['escape'],
60 imports=['from webhelpers.html import escape'])
59 imports=['from webhelpers.html import escape'])
61
60
62 #sets the c attribute access when don't existing attribute are accessed
61 # sets the c attribute access when don't existing attribute are accessed
63 config['pylons.strict_tmpl_context'] = True
62 config['pylons.strict_tmpl_context'] = True
64 test = os.path.split(config['__file__'])[-1] == 'test.ini'
63 test = os.path.split(config['__file__'])[-1] == 'test.ini'
65 if test:
64 if test:
@@ -68,7 +67,7 b' def load_environment(global_conf, app_co'
68 create_test_env(TESTS_TMP_PATH, config)
67 create_test_env(TESTS_TMP_PATH, config)
69 create_test_index(TESTS_TMP_PATH, config, True)
68 create_test_index(TESTS_TMP_PATH, config, True)
70
69
71 #MULTIPLE DB configs
70 # MULTIPLE DB configs
72 # Setup the SQLAlchemy database engine
71 # Setup the SQLAlchemy database engine
73 sa_engine_db1 = engine_from_config(config, 'sqlalchemy.db1.')
72 sa_engine_db1 = engine_from_config(config, 'sqlalchemy.db1.')
74
73
@@ -82,4 +81,7 b' def load_environment(global_conf, app_co'
82 # CONFIGURATION OPTIONS HERE (note: all config options will override
81 # CONFIGURATION OPTIONS HERE (note: all config options will override
83 # any Pylons config options)
82 # any Pylons config options)
84
83
84 # store config reference into our module to skip import magic of
85 # pylons
86 rhodecode.CONFIG.update(config)
85 return config
87 return config
@@ -181,7 +181,7 b' def generate_api_key(username, salt=None'
181 return hashlib.sha1(username + salt).hexdigest()
181 return hashlib.sha1(username + salt).hexdigest()
182
182
183
183
184 def safe_unicode(str_, from_encoding='utf8'):
184 def safe_unicode(str_, from_encoding=None):
185 """
185 """
186 safe unicode function. Does few trick to turn str_ into unicode
186 safe unicode function. Does few trick to turn str_ into unicode
187
187
@@ -195,6 +195,11 b" def safe_unicode(str_, from_encoding='ut"
195 if isinstance(str_, unicode):
195 if isinstance(str_, unicode):
196 return str_
196 return str_
197
197
198 if not from_encoding:
199 import rhodecode
200 DEFAULT_ENCODING = rhodecode.CONFIG.get('default_encoding','utf8')
201 from_encoding = DEFAULT_ENCODING
202
198 try:
203 try:
199 return unicode(str_)
204 return unicode(str_)
200 except UnicodeDecodeError:
205 except UnicodeDecodeError:
@@ -215,7 +220,7 b" def safe_unicode(str_, from_encoding='ut"
215 return unicode(str_, from_encoding, 'replace')
220 return unicode(str_, from_encoding, 'replace')
216
221
217
222
218 def safe_str(unicode_, to_encoding='utf8'):
223 def safe_str(unicode_, to_encoding=None):
219 """
224 """
220 safe str function. Does few trick to turn unicode_ into string
225 safe str function. Does few trick to turn unicode_ into string
221
226
@@ -233,6 +238,11 b" def safe_str(unicode_, to_encoding='utf8"
233 if isinstance(unicode_, str):
238 if isinstance(unicode_, str):
234 return unicode_
239 return unicode_
235
240
241 if not to_encoding:
242 import rhodecode
243 DEFAULT_ENCODING = rhodecode.CONFIG.get('default_encoding','utf8')
244 to_encoding = DEFAULT_ENCODING
245
236 try:
246 try:
237 return unicode_.encode(to_encoding)
247 return unicode_.encode(to_encoding)
238 except UnicodeEncodeError:
248 except UnicodeEncodeError:
@@ -111,6 +111,7 b' class BaseController(WSGIController):'
111
111
112 def __before__(self):
112 def __before__(self):
113 c.rhodecode_version = __version__
113 c.rhodecode_version = __version__
114 c.rhodecode_instanceid = config.get('instance_id')
114 c.rhodecode_name = config.get('rhodecode_title')
115 c.rhodecode_name = config.get('rhodecode_title')
115 c.use_gravatar = str2bool(config.get('use_gravatar'))
116 c.use_gravatar = str2bool(config.get('use_gravatar'))
116 c.ga_code = config.get('rhodecode_ga_code')
117 c.ga_code = config.get('rhodecode_ga_code')
@@ -27,7 +27,7 b' def date_fromtimestamp(unixts, tzoffset='
27 return datetime.datetime.fromtimestamp(float(unixts))
27 return datetime.datetime.fromtimestamp(float(unixts))
28
28
29
29
30 def safe_unicode(str_, from_encoding='utf8'):
30 def safe_unicode(str_, from_encoding=None):
31 """
31 """
32 safe unicode function. Does few trick to turn str_ into unicode
32 safe unicode function. Does few trick to turn str_ into unicode
33
33
@@ -40,7 +40,10 b" def safe_unicode(str_, from_encoding='ut"
40 """
40 """
41 if isinstance(str_, unicode):
41 if isinstance(str_, unicode):
42 return str_
42 return str_
43
43 if not from_encoding:
44 import rhodecode
45 DEFAULT_ENCODING = rhodecode.CONFIG.get('default_encoding','utf8')
46 from_encoding = DEFAULT_ENCODING
44 try:
47 try:
45 return unicode(str_)
48 return unicode(str_)
46 except UnicodeDecodeError:
49 except UnicodeDecodeError:
@@ -61,7 +64,7 b" def safe_unicode(str_, from_encoding='ut"
61 return unicode(str_, from_encoding, 'replace')
64 return unicode(str_, from_encoding, 'replace')
62
65
63
66
64 def safe_str(unicode_, to_encoding='utf8'):
67 def safe_str(unicode_, to_encoding=None):
65 """
68 """
66 safe str function. Does few trick to turn unicode_ into string
69 safe str function. Does few trick to turn unicode_ into string
67
70
@@ -75,7 +78,10 b" def safe_str(unicode_, to_encoding='utf8"
75
78
76 if isinstance(unicode_, str):
79 if isinstance(unicode_, str):
77 return unicode_
80 return unicode_
78
81 if not to_encoding:
82 import rhodecode
83 DEFAULT_ENCODING = rhodecode.CONFIG.get('default_encoding','utf8')
84 to_encoding = DEFAULT_ENCODING
79 try:
85 try:
80 return unicode_.encode(to_encoding)
86 return unicode_.encode(to_encoding)
81 except UnicodeEncodeError:
87 except UnicodeEncodeError:
@@ -1034,7 +1034,12 b' class CacheInvalidation(Base, BaseModel)'
1034
1034
1035 :param key:
1035 :param key:
1036 """
1036 """
1037 return "%s" % (key)
1037 import rhodecode
1038 prefix = ''
1039 iid = rhodecode.CONFIG.get('instance_id')
1040 if iid:
1041 prefix = iid
1042 return "%s%s" % (prefix, key)
1038
1043
1039 @classmethod
1044 @classmethod
1040 def get_by_key(cls, key):
1045 def get_by_key(cls, key):
@@ -41,7 +41,7 b''
41 <a href="${h.url('bugtracker')}">${_('Submit a bug')}</a>
41 <a href="${h.url('bugtracker')}">${_('Submit a bug')}</a>
42 </p>
42 </p>
43 <p class="footer-link-right">
43 <p class="footer-link-right">
44 <a href="${h.url('rhodecode_official')}">RhodeCode</a>
44 <a href="${h.url('rhodecode_official')}">RhodeCode${'-%s' % c.rhodecode_instanceid if c.rhodecode_instanceid else ''}</a>
45 ${c.rhodecode_version} &copy; 2010-${h.datetime.today().year} by Marcin Kuzminski
45 ${c.rhodecode_version} &copy; 2010-${h.datetime.today().year} by Marcin Kuzminski
46 </p>
46 </p>
47 </div>
47 </div>
@@ -221,7 +221,7 b''
221
221
222 %if c.readme_data:
222 %if c.readme_data:
223 <div class="box" style="background-color: #FAFAFA">
223 <div class="box" style="background-color: #FAFAFA">
224 <div class="title">
224 <div id="readme" class="title">
225 <div class="breadcrumbs"><a href="${h.url('files_home',repo_name=c.repo_name,revision='tip',f_path=c.readme_file)}">${c.readme_file}</a></div>
225 <div class="breadcrumbs"><a href="${h.url('files_home',repo_name=c.repo_name,revision='tip',f_path=c.readme_file)}">${c.readme_file}</a></div>
226 </div>
226 </div>
227 <div class="readme">
227 <div class="readme">
General Comments 0
You need to be logged in to leave comments. Login now