diff options
author | Adrien Di Mascio <Adrien.DiMascio@logilab.fr> | 2008-07-24 14:34:48 +0200 |
---|---|---|
committer | Adrien Di Mascio <Adrien.DiMascio@logilab.fr> | 2008-07-24 14:34:48 +0200 |
commit | 1a4dcdc0f6b17410c97511f85cdc9211360f2825 (patch) | |
tree | 65b1149858ea701843fb7cb092e83704af49efa5 /adbh.py | |
parent | 599c946f9039e418fcde1c6dd75eb138b811d30c (diff) | |
download | logilab-common-1a4dcdc0f6b17410c97511f85cdc9211360f2825.tar.gz |
[adbh] supported_backends is now defined in lgc (was defined in RQL before)
Each FunctionDescr can now declare on which DB it is supported
Diffstat (limited to 'adbh.py')
-rw-r--r-- | adbh.py | 13 |
1 files changed, 12 insertions, 1 deletions
@@ -31,6 +31,7 @@ class metafunc(type): class FunctionDescr(object): __metaclass__ = metafunc + supported_backends = () rtype = None # None <-> returned type should be the same as the first argument aggregat = False minargs = 1 @@ -86,6 +87,7 @@ class _GenericAdvFuncHelper: """ # DBMS resources descriptors and accessors + backend_name = None # overriden in subclasses ('postgres', 'sqlite', etc.) needs_from_clause = False union_parentheses_support = True users_support = True @@ -155,7 +157,7 @@ class _GenericAdvFuncHelper: def system_database(self): """return the system database for the given driver""" raise NotImplementedError('not supported by this DBMS') - + def backup_command(self, dbname, dbhost, dbuser, dbpassword, backupfile, keepownership=True): """return a command to backup the given database""" @@ -276,6 +278,7 @@ def pgdbcmd(cmd, dbhost, dbuser): class _PGAdvFuncHelper(_GenericAdvFuncHelper): """Postgres helper, taking advantage of postgres SEQUENCE support """ + backend_name = 'postgres' # modifiable but should not be shared FUNCTIONS = _GenericAdvFuncHelper.FUNCTIONS.copy() @@ -386,6 +389,7 @@ class _SqliteAdvFuncHelper(_GenericAdvFuncHelper): An exception is raised when the functionality is not emulatable """ + backend_name = 'sqlite' # modifiable but should not be shared FUNCTIONS = _GenericAdvFuncHelper.FUNCTIONS.copy() @@ -411,6 +415,7 @@ class _SqliteAdvFuncHelper(_GenericAdvFuncHelper): class _MyAdvFuncHelper(_GenericAdvFuncHelper): """MySQL helper, taking advantage of postgres SEQUENCE support """ + backend_name = 'mysql' needs_from_clause = True ilike_support = False # insensitive search by default @@ -514,3 +519,9 @@ def get_adv_func_helper(driver): def register_function(driver, funcdef): ADV_FUNC_HELPER_DIRECTORY[driver].register_function(funcdef) +# this function should be called `register_function` but the other +# definition was defined prior to this one +def auto_register_function(funcdef): + """register the function `funcdef` on supported backends""" + for driver in funcdef.supported_backends: + register_function(driver, funcdef) |