Skip to content
Snippets Groups Projects
Commit 370898981f65 authored by adrien di mascio's avatar adrien di mascio
Browse files

cleaner function handling based on the new logilab.db package

parent 4f10ff2c720c
No related branches found
No related tags found
No related merge requests found
......@@ -12,7 +12,7 @@
Package: python-rql
Architecture: any
XB-Python-Version: ${python:Versions}
Depends: ${python:Depends}, ${misc:Depends}, ${shlibs:Depends}, python-logilab-common (>= 0.35.3-1), yapps2-runtime
Depends: ${python:Depends}, ${misc:Depends}, ${shlibs:Depends}, python-logilab-common (>= 0.35.3-1), yapps2-runtime, python-logilab-db
Provides: ${python:Provides}
Description: relationship query language (RQL) utilities
A library providing the base utilities to handle RQL queries,
......
......@@ -52,6 +52,8 @@
'LIMIT', 'OFFSET'))
from logilab.common.adbh import _GenericAdvFuncHelper, FunctionDescr, \
auto_register_function
from logilab.common.decorators import monkeypatch
from logilab.db import SQL_FUNCTIONS_REGISTRY, FunctionDescr
RQL_FUNCTIONS_REGISTRY = SQL_FUNCTIONS_REGISTRY.copy()
......@@ -57,3 +59,4 @@
def st_description(cls, funcnode, mainindex, tr):
@monkeypatch(FunctionDescr)
def st_description(self, funcnode, mainindex, tr):
return '%s(%s)' % (
......@@ -59,5 +62,5 @@
return '%s(%s)' % (
tr(cls.name),
tr(self.name),
', '.join(sorted(child.get_description(mainindex, tr)
for child in iter_funcnode_variables(funcnode))))
......@@ -61,8 +64,6 @@
', '.join(sorted(child.get_description(mainindex, tr)
for child in iter_funcnode_variables(funcnode))))
FunctionDescr.st_description = classmethod(st_description)
def iter_funcnode_variables(funcnode):
for term in funcnode.children:
try:
......@@ -93,6 +94,4 @@
node2 = node2.parent
raise Exception('DUH!')
FUNCTIONS = _GenericAdvFuncHelper.FUNCTIONS.copy()
def register_function(funcdef):
......@@ -98,10 +97,6 @@
def register_function(funcdef):
if isinstance(funcdef, basestring) :
funcdef = FunctionDescr(funcdef.upper())
assert not funcdef.name in FUNCTIONS, \
'%s is already registered' % funcdef.name
FUNCTIONS[funcdef.name] = funcdef
auto_register_function(funcdef)
RQL_FUNCTIONS_REGISTRY.register_function(funcdef)
SQL_FUNCTIONS_REGISTRY.register_function(funcdef)
def function_description(funcname):
"""Return the description (`FunctionDescription`) for a RQL function."""
......@@ -105,7 +100,7 @@
def function_description(funcname):
"""Return the description (`FunctionDescription`) for a RQL function."""
return FUNCTIONS[funcname.upper()]
return RQL_FUNCTIONS_REGISTRY.get_function(funcname)
def quote(value):
"""Quote a string value."""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment