Mercurial > kallithea
comparison rhodecode/lib/celerypylons/loader.py @ 1002:3a7f5b1a19dd beta
made rhodecode work with celery 2.2, made some tasks optimizations(forget results)
added celeryconfig.py with just the definitions of hosts, it seams just this is needed to get celery working nice, all other config options are taken from .ini files. This is a temp workaround until i get the proper soltuion to this problem.
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Tue, 08 Feb 2011 02:57:21 +0100 |
parents | f6c613fba757 |
children | ffd45b185016 |
comparison
equal
deleted
inserted
replaced
1001:94e0541a5283 | 1002:3a7f5b1a19dd |
---|---|
15 """ | 15 """ |
16 def __getattr__(self, key): | 16 def __getattr__(self, key): |
17 pylons_key = to_pylons(key) | 17 pylons_key = to_pylons(key) |
18 try: | 18 try: |
19 value = config[pylons_key] | 19 value = config[pylons_key] |
20 if key in LIST_PARAMS: return value.split() | 20 if key in LIST_PARAMS:return value.split() |
21 return self.type_converter(value) | 21 return self.type_converter(value) |
22 except KeyError: | 22 except KeyError: |
23 raise AttributeError(pylons_key) | 23 raise AttributeError(pylons_key) |
24 | |
25 def get(self, key): | |
26 try: | |
27 return self.__getattr__(key) | |
28 except AttributeError: | |
29 return None | |
30 | |
31 def __getitem__(self, key): | |
32 try: | |
33 return self.__getattr__(key) | |
34 except AttributeError: | |
35 raise KeyError() | |
24 | 36 |
25 def __setattr__(self, key, value): | 37 def __setattr__(self, key, value): |
26 pylons_key = to_pylons(key) | 38 pylons_key = to_pylons(key) |
27 config[pylons_key] = value | 39 config[pylons_key] = value |
28 | 40 |
41 def __setitem__(self, key, value): | |
42 self.__setattr__(key, value) | |
29 | 43 |
30 def type_converter(self, value): | 44 def type_converter(self, value): |
31 #cast to int | 45 #cast to int |
32 if value.isdigit(): | 46 if value.isdigit(): |
33 return int(value) | 47 return int(value) |
34 | 48 |
35 #cast to bool | 49 #cast to bool |
36 if value.lower() in ['true', 'false']: | 50 if value.lower() in ['true', 'false']: |
37 return value.lower() == 'true' | 51 return value.lower() == 'true' |
38 | |
39 return value | 52 return value |
40 | 53 |
41 class PylonsLoader(BaseLoader): | 54 class PylonsLoader(BaseLoader): |
42 """Pylons celery loader | 55 """Pylons celery loader |
43 | 56 |