##// END OF EJS Templates
another major code rafactor, reimplemented (almost from scratch)...
another major code rafactor, reimplemented (almost from scratch) the way caching works, Should be solid rock for now. Some code optymizations on scmModel.get() to make it don't load unneded things. Changed db cache to file that should also reduce memory size

File last commit:

r1002:3a7f5b1a beta
r1038:5554aa9c beta
Show More
loader.py
68 lines | 1.7 KiB | text/x-python | PythonLexer
Celery is configured by the .ini files and run from paster now...
r776 from celery.loaders.base import BaseLoader
from pylons import config
to_pylons = lambda x: x.replace('_', '.').lower()
to_celery = lambda x: x.replace('.', '_').upper()
LIST_PARAMS = """CELERY_IMPORTS ADMINS ROUTES""".split()
class PylonsSettingsProxy(object):
"""Pylons Settings Proxy
Proxies settings from pylons.config
"""
def __getattr__(self, key):
pylons_key = to_pylons(key)
try:
value = config[pylons_key]
made rhodecode work with celery 2.2, made some tasks optimizations(forget results)...
r1002 if key in LIST_PARAMS:return value.split()
Celery is configured by the .ini files and run from paster now...
r776 return self.type_converter(value)
except KeyError:
raise AttributeError(pylons_key)
made rhodecode work with celery 2.2, made some tasks optimizations(forget results)...
r1002 def get(self, key):
try:
return self.__getattr__(key)
except AttributeError:
return None
def __getitem__(self, key):
try:
return self.__getattr__(key)
except AttributeError:
raise KeyError()
Celery is configured by the .ini files and run from paster now...
r776 def __setattr__(self, key, value):
pylons_key = to_pylons(key)
config[pylons_key] = value
made rhodecode work with celery 2.2, made some tasks optimizations(forget results)...
r1002 def __setitem__(self, key, value):
self.__setattr__(key, value)
Celery is configured by the .ini files and run from paster now...
r776
def type_converter(self, value):
#cast to int
if value.isdigit():
return int(value)
#cast to bool
if value.lower() in ['true', 'false']:
return value.lower() == 'true'
return value
class PylonsLoader(BaseLoader):
"""Pylons celery loader
Maps the celery config onto pylons.config
"""
def read_configuration(self):
self.configured = True
return PylonsSettingsProxy()
def on_worker_init(self):
"""
Import task modules.
"""
self.import_default_modules()