--- a/server/sqlutils.py Fri Jan 22 08:40:38 2010 +0100
+++ b/server/sqlutils.py Fri Jan 22 08:49:16 2010 +0100
@@ -314,6 +314,29 @@
if hasattr(yams.constraints, 'patch_sqlite_decimal'):
yams.constraints.patch_sqlite_decimal()
+ def fspath(eid, etype, attr):
+ try:
+ cu = cnx.cursor()
+ cu.execute('SELECT X.cw_%s FROM cw_%s as X '
+ 'WHERE X.cw_eid=%%(eid)s' % (attr, etype),
+ {'eid': eid})
+ return cu.fetchone()[0]
+ except:
+ import traceback
+ traceback.print_exc()
+ raise
+ cnx.create_function('fspath', 3, fspath)
+
+ def _fsopen(fspath):
+ if fspath:
+ try:
+ return buffer(file(fspath).read())
+ except:
+ import traceback
+ traceback.print_exc()
+ raise
+ cnx.create_function('_fsopen', 1, _fsopen)
+
sqlite_hooks = SQL_CONNECT_HOOKS.setdefault('sqlite', [])
sqlite_hooks.append(init_sqlite_connexion)