1. Matteo Bertini
  2. RhodeCode

Commits

Marcin Kuzminski  committed 6020e38

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

  • Participants
  • Parent commits 5415d0d
  • Branches beta

Comments (0)

Files changed (10)

File development.ini

View file
 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:
 
 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        ####
 ##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  ##

File production.ini

View file
 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:
 
 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        ####
 
 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

File rhodecode/config/deployment.ini_tmpl

View file
 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:
 ## 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
 
 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        ####
 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 ##
 [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
+datefmt = %Y-%m-%d %H:%M:%S

File rhodecode/config/environment.py

View file
 
     # 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)
         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:
         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.')
 
     # 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

File rhodecode/lib/__init__.py

View file
     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
 
     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:
         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
 
     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:

File rhodecode/lib/base.py

View file
 
     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')

File rhodecode/lib/vcs/utils/__init__.py

View file
     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
 
     """
     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:
         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
 
 
     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:

File rhodecode/model/db.py

View file
 
         :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):

File rhodecode/templates/base/base.html

View file
                 <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>

File rhodecode/templates/summary/summary.html

View file
 
 %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">