# HG changeset patch
# User Marcin Kuzminski
# Date 2012-02-22 02:30:26
# Node ID 6020e3884a58e5c03fa16cf5fbc2d54547fb3dff
# Parent 5415d0de5970fd08f0122cb6c550d2b3bda12cf5
implements #212 moved default encoding variable into rhodecode-config. It's now possible to change
default utf8 to some other encoding.
- also added instance-id to config
- update ini files
diff --git a/development.ini b/development.ini
--- a/development.ini
+++ b/development.ini
@@ -46,16 +46,17 @@ port = 5000
use = egg:rhodecode
full_stack = true
static_files = true
-lang=en
+lang = en
cache_dir = %(here)s/data
index_dir = %(here)s/data/index
-app_instance_uuid = develop
+app_instance_uuid = rc-develop
cut_off_limit = 256000
force_https = false
commit_parse_limit = 25
use_gravatar = true
container_auth_enabled = false
proxypass_auth_enabled = false
+default_encoding = utf8
## overwrite schema of clone url
## available vars:
@@ -86,6 +87,11 @@ issue_server_link = https://myissueserve
issue_prefix = #
+## instance-id prefix
+## a prefix key for this instance used for cache invalidation when running
+## multiple instances of rhodecode, make sure it's globally unique for
+## all running rhodecode instances. Leave empty if you don't use it
+instance_id =
####################################
### CELERY CONFIG ####
@@ -179,7 +185,7 @@ beaker.session.auto = False
##true exire at browser close
#beaker.session.cookie_expires = 3600
-
+
################################################################################
## WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT* ##
## Debug mode will enable the interactive debugging tool, allowing ANYONE to ##
diff --git a/production.ini b/production.ini
--- a/production.ini
+++ b/production.ini
@@ -46,16 +46,17 @@ port = 8001
use = egg:rhodecode
full_stack = true
static_files = true
-lang=en
+lang = en
cache_dir = %(here)s/data
index_dir = %(here)s/data/index
-app_instance_uuid = prod1234
+app_instance_uuid = rc-production
cut_off_limit = 256000
-force_https = false
+force_https = false
commit_parse_limit = 50
use_gravatar = true
container_auth_enabled = false
proxypass_auth_enabled = false
+default_encoding = utf8
## overwrite schema of clone url
## available vars:
@@ -86,6 +87,11 @@ issue_server_link = https://myissueserve
issue_prefix = #
+## instance-id prefix
+## a prefix key for this instance used for cache invalidation when running
+## multiple instances of rhodecode, make sure it's globally unique for
+## all running rhodecode instances. Leave empty if you don't use it
+instance_id =
####################################
### CELERY CONFIG ####
@@ -165,6 +171,7 @@ beaker.cache.sql_cache_long.key_length =
beaker.session.type = file
beaker.session.key = rhodecode
+# secure cookie requires AES python libraries
#beaker.session.encrypt_key = g654dcno0-9873jhgfreyu
#beaker.session.validate_key = 9712sds2212c--zxc123
beaker.session.timeout = 36000
diff --git a/rhodecode/config/deployment.ini_tmpl b/rhodecode/config/deployment.ini_tmpl
--- a/rhodecode/config/deployment.ini_tmpl
+++ b/rhodecode/config/deployment.ini_tmpl
@@ -46,16 +46,17 @@ port = 5000
use = egg:rhodecode
full_stack = true
static_files = true
-lang=en
+lang = en
cache_dir = %(here)s/data
index_dir = %(here)s/data/index
app_instance_uuid = ${app_instance_uuid}
cut_off_limit = 256000
-force_https = false
+force_https = false
commit_parse_limit = 50
use_gravatar = true
container_auth_enabled = false
proxypass_auth_enabled = false
+default_encoding = utf8
## overwrite schema of clone url
## available vars:
@@ -65,7 +66,7 @@ proxypass_auth_enabled = false
## netloc - network location
## path - usually repo_name
-# clone_uri = {scheme}://{user}{pass}{netloc}{path}
+#clone_uri = {scheme}://{user}{pass}{netloc}{path}
## issue tracking mapping for commits messages
## comment out issue_pat, issue_server, issue_prefix to enable
@@ -86,6 +87,11 @@ issue_server_link = https://myissueserve
issue_prefix = #
+## instance-id prefix
+## a prefix key for this instance used for cache invalidation when running
+## multiple instances of rhodecode, make sure it's globally unique for
+## all running rhodecode instances. Leave empty if you don't use it
+instance_id =
####################################
### CELERY CONFIG ####
@@ -272,13 +278,13 @@ propagate = 0
class = StreamHandler
args = (sys.stderr,)
level = INFO
-formatter = color_formatter
+formatter = generic
[handler_console_sql]
class = StreamHandler
args = (sys.stderr,)
level = WARN
-formatter = color_formatter_sql
+formatter = generic
################
## FORMATTERS ##
@@ -296,4 +302,4 @@ datefmt = %Y-%m-%d %H:%M:%S
[formatter_color_formatter_sql]
class=rhodecode.lib.colored_formatter.ColorFormatterSql
format= %(asctime)s.%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s
-datefmt = %Y-%m-%d %H:%M:%S
\ No newline at end of file
+datefmt = %Y-%m-%d %H:%M:%S
diff --git a/rhodecode/config/environment.py b/rhodecode/config/environment.py
--- a/rhodecode/config/environment.py
+++ b/rhodecode/config/environment.py
@@ -41,12 +41,11 @@ def load_environment(global_conf, app_co
# store some globals into rhodecode
rhodecode.CELERY_ON = str2bool(config['app_conf'].get('use_celery'))
- rhodecode.CONFIG = config
config['routes.map'] = make_map(config)
config['pylons.app_globals'] = app_globals.Globals(config)
config['pylons.h'] = rhodecode.lib.helpers
-
+ rhodecode.CONFIG = config
# Setup cache object as early as possible
import pylons
pylons.cache._push_object(config['pylons.app_globals'].cache)
@@ -59,7 +58,7 @@ def load_environment(global_conf, app_co
input_encoding='utf-8', default_filters=['escape'],
imports=['from webhelpers.html import escape'])
- #sets the c attribute access when don't existing attribute are accessed
+ # sets the c attribute access when don't existing attribute are accessed
config['pylons.strict_tmpl_context'] = True
test = os.path.split(config['__file__'])[-1] == 'test.ini'
if test:
@@ -68,7 +67,7 @@ def load_environment(global_conf, app_co
create_test_env(TESTS_TMP_PATH, config)
create_test_index(TESTS_TMP_PATH, config, True)
- #MULTIPLE DB configs
+ # MULTIPLE DB configs
# Setup the SQLAlchemy database engine
sa_engine_db1 = engine_from_config(config, 'sqlalchemy.db1.')
@@ -82,4 +81,7 @@ def load_environment(global_conf, app_co
# CONFIGURATION OPTIONS HERE (note: all config options will override
# any Pylons config options)
+ # store config reference into our module to skip import magic of
+ # pylons
+ rhodecode.CONFIG.update(config)
return config
diff --git a/rhodecode/lib/__init__.py b/rhodecode/lib/__init__.py
--- a/rhodecode/lib/__init__.py
+++ b/rhodecode/lib/__init__.py
@@ -181,7 +181,7 @@ def generate_api_key(username, salt=None
return hashlib.sha1(username + salt).hexdigest()
-def safe_unicode(str_, from_encoding='utf8'):
+def safe_unicode(str_, from_encoding=None):
"""
safe unicode function. Does few trick to turn str_ into unicode
@@ -195,6 +195,11 @@ def safe_unicode(str_, from_encoding='ut
if isinstance(str_, unicode):
return str_
+ if not from_encoding:
+ import rhodecode
+ DEFAULT_ENCODING = rhodecode.CONFIG.get('default_encoding','utf8')
+ from_encoding = DEFAULT_ENCODING
+
try:
return unicode(str_)
except UnicodeDecodeError:
@@ -215,7 +220,7 @@ def safe_unicode(str_, from_encoding='ut
return unicode(str_, from_encoding, 'replace')
-def safe_str(unicode_, to_encoding='utf8'):
+def safe_str(unicode_, to_encoding=None):
"""
safe str function. Does few trick to turn unicode_ into string
@@ -233,6 +238,11 @@ def safe_str(unicode_, to_encoding='utf8
if isinstance(unicode_, str):
return unicode_
+ if not to_encoding:
+ import rhodecode
+ DEFAULT_ENCODING = rhodecode.CONFIG.get('default_encoding','utf8')
+ to_encoding = DEFAULT_ENCODING
+
try:
return unicode_.encode(to_encoding)
except UnicodeEncodeError:
diff --git a/rhodecode/lib/base.py b/rhodecode/lib/base.py
--- a/rhodecode/lib/base.py
+++ b/rhodecode/lib/base.py
@@ -111,6 +111,7 @@ class BaseController(WSGIController):
def __before__(self):
c.rhodecode_version = __version__
+ c.rhodecode_instanceid = config.get('instance_id')
c.rhodecode_name = config.get('rhodecode_title')
c.use_gravatar = str2bool(config.get('use_gravatar'))
c.ga_code = config.get('rhodecode_ga_code')
diff --git a/rhodecode/lib/vcs/utils/__init__.py b/rhodecode/lib/vcs/utils/__init__.py
--- a/rhodecode/lib/vcs/utils/__init__.py
+++ b/rhodecode/lib/vcs/utils/__init__.py
@@ -27,7 +27,7 @@ def date_fromtimestamp(unixts, tzoffset=
return datetime.datetime.fromtimestamp(float(unixts))
-def safe_unicode(str_, from_encoding='utf8'):
+def safe_unicode(str_, from_encoding=None):
"""
safe unicode function. Does few trick to turn str_ into unicode
@@ -40,7 +40,10 @@ def safe_unicode(str_, from_encoding='ut
"""
if isinstance(str_, unicode):
return str_
-
+ if not from_encoding:
+ import rhodecode
+ DEFAULT_ENCODING = rhodecode.CONFIG.get('default_encoding','utf8')
+ from_encoding = DEFAULT_ENCODING
try:
return unicode(str_)
except UnicodeDecodeError:
@@ -61,7 +64,7 @@ def safe_unicode(str_, from_encoding='ut
return unicode(str_, from_encoding, 'replace')
-def safe_str(unicode_, to_encoding='utf8'):
+def safe_str(unicode_, to_encoding=None):
"""
safe str function. Does few trick to turn unicode_ into string
@@ -75,7 +78,10 @@ def safe_str(unicode_, to_encoding='utf8
if isinstance(unicode_, str):
return unicode_
-
+ if not to_encoding:
+ import rhodecode
+ DEFAULT_ENCODING = rhodecode.CONFIG.get('default_encoding','utf8')
+ to_encoding = DEFAULT_ENCODING
try:
return unicode_.encode(to_encoding)
except UnicodeEncodeError:
diff --git a/rhodecode/model/db.py b/rhodecode/model/db.py
--- a/rhodecode/model/db.py
+++ b/rhodecode/model/db.py
@@ -1034,7 +1034,12 @@ class CacheInvalidation(Base, BaseModel)
:param key:
"""
- return "%s" % (key)
+ import rhodecode
+ prefix = ''
+ iid = rhodecode.CONFIG.get('instance_id')
+ if iid:
+ prefix = iid
+ return "%s%s" % (prefix, key)
@classmethod
def get_by_key(cls, key):
diff --git a/rhodecode/templates/base/base.html b/rhodecode/templates/base/base.html
--- a/rhodecode/templates/base/base.html
+++ b/rhodecode/templates/base/base.html
@@ -41,7 +41,7 @@
${_('Submit a bug')}
diff --git a/rhodecode/templates/summary/summary.html b/rhodecode/templates/summary/summary.html
--- a/rhodecode/templates/summary/summary.html
+++ b/rhodecode/templates/summary/summary.html
@@ -221,7 +221,7 @@
%if c.readme_data: