cwconfig.py
changeset 4023 eae23c40627a
parent 4021 280c910c8710
child 4135 cb0d0bf255f7
equal deleted inserted replaced
4022:934e758a73ef 4023:eae23c40627a
   554                 elif exists(path + '.py'):
   554                 elif exists(path + '.py'):
   555                     vregpath.append(path + '.py')
   555                     vregpath.append(path + '.py')
   556         return vregpath
   556         return vregpath
   557 
   557 
   558     def __init__(self):
   558     def __init__(self):
       
   559         register_stored_procedures()
   559         ConfigurationMixIn.__init__(self)
   560         ConfigurationMixIn.__init__(self)
   560         self.adjust_sys_path()
   561         self.adjust_sys_path()
   561         self.load_defaults()
   562         self.load_defaults()
   562         self.translations = {}
   563         self.translations = {}
   563 
   564 
   965 set_log_methods(CubicWebConfiguration, logging.getLogger('cubicweb.configuration'))
   966 set_log_methods(CubicWebConfiguration, logging.getLogger('cubicweb.configuration'))
   966 
   967 
   967 # alias to get a configuration instance from an instance id
   968 # alias to get a configuration instance from an instance id
   968 instance_configuration = CubicWebConfiguration.config_for
   969 instance_configuration = CubicWebConfiguration.config_for
   969 application_configuration = deprecated('use instance_configuration')(instance_configuration)
   970 application_configuration = deprecated('use instance_configuration')(instance_configuration)
       
   971 
       
   972 
       
   973 _EXT_REGISTERED = False
       
   974 def register_stored_procedures():
       
   975     from logilab.common.adbh import FunctionDescr
       
   976     from rql.utils import register_function, iter_funcnode_variables
       
   977 
       
   978     global _EXT_REGISTERED
       
   979     if _EXT_REGISTERED:
       
   980         return
       
   981     _EXT_REGISTERED = True
       
   982 
       
   983     class COMMA_JOIN(FunctionDescr):
       
   984         supported_backends = ('postgres', 'sqlite',)
       
   985         rtype = 'String'
       
   986 
       
   987         @classmethod
       
   988         def st_description(cls, funcnode, mainindex, tr):
       
   989             return ', '.join(sorted(term.get_description(mainindex, tr)
       
   990                                     for term in iter_funcnode_variables(funcnode)))
       
   991 
       
   992     register_function(COMMA_JOIN)  # XXX do not expose?
       
   993 
       
   994 
       
   995     class CONCAT_STRINGS(COMMA_JOIN):
       
   996         aggregat = True
       
   997 
       
   998     register_function(CONCAT_STRINGS) # XXX bw compat
       
   999 
       
  1000     class GROUP_CONCAT(CONCAT_STRINGS):
       
  1001         supported_backends = ('mysql', 'postgres', 'sqlite',)
       
  1002 
       
  1003     register_function(GROUP_CONCAT)
       
  1004 
       
  1005 
       
  1006     class LIMIT_SIZE(FunctionDescr):
       
  1007         supported_backends = ('postgres', 'sqlite',)
       
  1008         rtype = 'String'
       
  1009 
       
  1010         @classmethod
       
  1011         def st_description(cls, funcnode, mainindex, tr):
       
  1012             return funcnode.children[0].get_description(mainindex, tr)
       
  1013 
       
  1014     register_function(LIMIT_SIZE)
       
  1015 
       
  1016 
       
  1017     class TEXT_LIMIT_SIZE(LIMIT_SIZE):
       
  1018         supported_backends = ('mysql', 'postgres', 'sqlite',)
       
  1019 
       
  1020     register_function(TEXT_LIMIT_SIZE)