Changeset - 6020e3884a58
[Not reviewed]
beta
0 10 0
Marcin Kuzminski - 14 years ago 2012-02-22 03:30:26
marcin@python-works.com
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
10 files changed with 68 insertions and 25 deletions:
0 comments (0 inline, 0 general)
development.ini
Show inline comments
 
@@ -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  ##
production.ini
Show inline comments
 
@@ -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
rhodecode/config/deployment.ini_tmpl
Show inline comments
 
@@ -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
rhodecode/config/environment.py
Show inline comments
 
@@ -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
rhodecode/lib/__init__.py
Show inline comments
 
@@ -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:
rhodecode/lib/base.py
Show inline comments
 
@@ -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')
rhodecode/lib/vcs/utils/__init__.py
Show inline comments
 
@@ -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:
rhodecode/model/db.py
Show inline comments
 
@@ -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):
rhodecode/templates/base/base.html
Show inline comments
 
@@ -41,7 +41,7 @@
 
                <a href="${h.url('bugtracker')}">${_('Submit a bug')}</a>
 
           </p>
 
	       <p class="footer-link-right">
 
	           <a href="${h.url('rhodecode_official')}">RhodeCode</a>
 
	           <a href="${h.url('rhodecode_official')}">RhodeCode${'-%s' % c.rhodecode_instanceid if c.rhodecode_instanceid else ''}</a>
 
	           ${c.rhodecode_version} &copy; 2010-${h.datetime.today().year} by Marcin Kuzminski
 
	       </p>
 
       </div>
rhodecode/templates/summary/summary.html
Show inline comments
 
@@ -221,7 +221,7 @@
 

	
 
%if c.readme_data:
 
<div class="box" style="background-color: #FAFAFA">
 
    <div class="title">
 
    <div id="readme" class="title">
 
        <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>
 
    </div>
 
    <div class="readme">
0 comments (0 inline, 0 general)