1 # copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
1 # copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
3 # |
3 # |
4 # This file is part of CubicWeb. |
4 # This file is part of CubicWeb. |
5 # |
5 # |
6 # CubicWeb is free software: you can redistribute it and/or modify it under the |
6 # CubicWeb is free software: you can redistribute it and/or modify it under the |
29 from os.path import join, exists |
29 from os.path import join, exists |
30 from glob import glob |
30 from glob import glob |
31 |
31 |
32 from logilab.common.modutils import LazyObject |
32 from logilab.common.modutils import LazyObject |
33 from logilab.common.textutils import splitstrip |
33 from logilab.common.textutils import splitstrip |
|
34 from logilab.common.registry import yes |
34 |
35 |
35 from yams import BASE_GROUPS |
36 from yams import BASE_GROUPS |
36 |
37 |
37 from cubicweb import CW_SOFTWARE_ROOT |
38 from cubicweb import CW_SOFTWARE_ROOT |
|
39 from cubicweb.appobject import AppObject |
38 |
40 |
39 class ShuttingDown(BaseException): |
41 class ShuttingDown(BaseException): |
40 """raised when trying to access some resources while the repository is |
42 """raised when trying to access some resources while the repository is |
41 shutting down. Inherit from BaseException so that `except Exception` won't |
43 shutting down. Inherit from BaseException so that `except Exception` won't |
42 catch it. |
44 catch it. |
43 """ |
45 """ |
44 |
46 |
45 # server-side debugging ######################################################### |
47 # server-side services ######################################################### |
|
48 |
|
49 class Service(AppObject): |
|
50 """Base class for services. |
|
51 |
|
52 A service is a selectable object that performs an action server-side. |
|
53 Use :class:`cubicweb.dbapi.Connection.call_service` to call them from |
|
54 the web-side. |
|
55 |
|
56 When inheriting this class, do not forget to define at least the __regid__ |
|
57 attribute (and probably __select__ too). |
|
58 """ |
|
59 __registry__ = 'services' |
|
60 __select__ = yes() |
|
61 |
|
62 def call(self, **kwargs): |
|
63 raise NotImplementedError |
|
64 |
|
65 |
|
66 # server-side debugging ######################################################## |
46 |
67 |
47 # server debugging flags. They may be combined using binary operators. |
68 # server debugging flags. They may be combined using binary operators. |
48 |
69 |
49 #:no debug information |
70 #:no debug information |
50 DBG_NONE = 0 #: no debug information |
71 DBG_NONE = 0 #: no debug information |