Vocabulary
This commit is contained in:
@ -7,9 +7,12 @@ from .utils import _
|
||||
from .error import CallError, NotAllowedError
|
||||
from .logger import log
|
||||
from .config import DEBUG
|
||||
from .config import get_config
|
||||
from .context import Context
|
||||
from . import register
|
||||
|
||||
def connect(db_conf):
|
||||
return psycopg2.connect(**db_conf)
|
||||
|
||||
class CallDispatcher:
|
||||
def valid_public_function(self,
|
||||
@ -94,11 +97,14 @@ class CallDispatcher:
|
||||
risotto_context.function = obj['function']
|
||||
if obj['risotto_context']:
|
||||
kw['risotto_context'] = risotto_context
|
||||
if obj['database']:
|
||||
db_conf = get_config.get('database')
|
||||
risotto_context.db_cursor = await connect(db_conf).cursor()
|
||||
returns = await risotto_context.function(self.injected_self[obj['module']], **kw)
|
||||
except CallError as err:
|
||||
raise err
|
||||
except Exception as err:
|
||||
if DEBUG:
|
||||
if get_config().get('global').get('debug'):
|
||||
print_exc()
|
||||
log.error_msg(risotto_context,
|
||||
kwargs,
|
||||
|
Reference in New Issue
Block a user