equal
deleted
inserted
replaced
88 from logilab.common.deprecation import deprecated |
88 from logilab.common.deprecation import deprecated |
89 from logilab.common.logging_ext import set_log_methods, init_log |
89 from logilab.common.logging_ext import set_log_methods, init_log |
90 from logilab.common.configuration import (Configuration, Method, |
90 from logilab.common.configuration import (Configuration, Method, |
91 ConfigurationMixIn, merge_options) |
91 ConfigurationMixIn, merge_options) |
92 |
92 |
93 from cubicweb import CW_SOFTWARE_ROOT, CW_MIGRATION_MAP, ConfigurationError |
93 from cubicweb import (CW_SOFTWARE_ROOT, CW_MIGRATION_MAP, |
|
94 ConfigurationError, Binary) |
94 from cubicweb.toolsutils import env_path, create_dir |
95 from cubicweb.toolsutils import env_path, create_dir |
95 |
96 |
96 CONFIGURATIONS = [] |
97 CONFIGURATIONS = [] |
97 |
98 |
98 SMTP_LOCK = Lock() |
99 SMTP_LOCK = Lock() |
1048 |
1049 |
1049 register_function(TEXT_LIMIT_SIZE) |
1050 register_function(TEXT_LIMIT_SIZE) |
1050 |
1051 |
1051 |
1052 |
1052 class FSPATH(FunctionDescr): |
1053 class FSPATH(FunctionDescr): |
1053 supported_backends = ('postgres', 'sqlite',) |
1054 """return path of some bytes attribute stored using the Bytes |
1054 rtype = 'Bytes' |
1055 File-System Storage (bfss) |
|
1056 """ |
|
1057 rtype = 'Bytes' # XXX return a String? potential pb with fs encoding |
|
1058 |
|
1059 def update_cb_stack(self, stack): |
|
1060 assert len(stack) == 1 |
|
1061 stack[0] = self.source_execute |
|
1062 |
|
1063 def as_sql(self, backend, args): |
|
1064 raise NotImplementedError('source only callback') |
|
1065 |
|
1066 def source_execute(self, source, value): |
|
1067 fpath = source.binary_to_str(value) |
|
1068 try: |
|
1069 return Binary(fpath) |
|
1070 except OSError, ex: |
|
1071 self.critical("can't open %s: %s", fpath, ex) |
|
1072 return None |
1055 |
1073 |
1056 register_function(FSPATH) |
1074 register_function(FSPATH) |