mirror of
https://github.com/yweber/lodel2.git
synced 2026-04-01 16:47:16 +02:00
Disabled wrapper in default settings + some little modifications
Modified Makefile (it was outdated) Modified the way of checking caller in _LeCrud.__new__ Modified the way the method is called by ACL wrapper
This commit is contained in:
parent
1b78028bb5
commit
912f27d4bf
4 changed files with 23 additions and 10 deletions
4
Makefile
4
Makefile
|
|
@ -35,13 +35,13 @@ cleandoc:
|
|||
-rm -Rf ./doc/html ./doc/doxygen_sqlite3.db
|
||||
|
||||
cleandocimages:
|
||||
cd $(graphviz_images_path); make clean
|
||||
$(MAKE) -C $(graphviz_images_path) clean
|
||||
|
||||
# Python cleaning
|
||||
cleanpyc:
|
||||
-find ./ |grep -E "\.pyc$$" |xargs rm -f 2>/dev/null
|
||||
cleanpycache: cleanpyc
|
||||
-find ./ -type d |grep '__pycache__' | xargs rmdir -f 2>/dev/null
|
||||
-find ./ -type d |grep '__pycache__' | xargs rmdir 2>/dev/null
|
||||
|
||||
cleandyn:
|
||||
-rm leapi/dyn.py
|
||||
|
|
|
|||
|
|
@ -8,7 +8,8 @@ import copy
|
|||
import warnings
|
||||
import importlib
|
||||
import re
|
||||
import inspect
|
||||
#import inspect
|
||||
import sys
|
||||
|
||||
from Lodel.settings import Settings
|
||||
from libs.transwrap.transwrap import get_class_wrapper
|
||||
|
|
@ -60,13 +61,16 @@ class _LeCrud(object):
|
|||
_query_re = None
|
||||
## @brief Stores Query filters operators
|
||||
_query_operators = ['=', '<=', '>=', '!=', '<', '>', ' in ', ' not in ', ' like ', ' not like ']
|
||||
|
||||
|
||||
## @brief Returns a wrapped object
|
||||
def __new__(cls, *args, **kwargs):
|
||||
if Settings.acl_bypass or inspect.stack()[2][3] == '__init__':
|
||||
# differents ways of checking the caller
|
||||
#if Settings.acl_bypass or inspect.stack()[2][3] == '__init__':
|
||||
if Settings.acl_bypass or sys._getframe().f_back.f_code.co_name == '__do_call__':
|
||||
return super().__new__(cls)
|
||||
else:
|
||||
return get_class_wrapper(cls)(*args, **kwargs)
|
||||
|
||||
|
||||
## @brief Asbtract constructor for every child classes
|
||||
# @param uid int : lodel_id if LeObject, id_relation if its a LeRelation
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ class DefaultCallCatcher(object):
|
|||
# @param kwargs dict : method call named arguments
|
||||
# @return the call returned value
|
||||
@classmethod
|
||||
def method_call(self, obj, method, args, kwargs):
|
||||
def method_call(cls, obj, method, args, kwargs):
|
||||
if obj is method:
|
||||
print("\tCatched ! %s(%s %s)" % (obj.__name__, args, kwargs))
|
||||
else:
|
||||
|
|
@ -42,7 +42,16 @@ class DefaultCallCatcher(object):
|
|||
else:
|
||||
print("\tCatched ! %s.%s(%s %s)" % (obj, method.__name__, args,kwargs))
|
||||
print("\t\tCallobject = %s method = %s with %s %s" % (obj, method, args, kwargs))
|
||||
|
||||
return cls.__do_call__(method, args, kwargs)
|
||||
|
||||
## @brief Do the method call
|
||||
# @note You have to use this method to make the call, because the __new__ method test caller method name to know if it has to return a real instance or a wrapped one
|
||||
# @param method : the python bounded method
|
||||
# @param args tuple : positional arguments
|
||||
# @param kwargs dict : keywords arguments
|
||||
# @return method returned value
|
||||
@classmethod
|
||||
def __do_call__(cls, method, args, kwargs):
|
||||
return method(*args, **kwargs)
|
||||
|
||||
## @brief Generate a wrapper
|
||||
|
|
@ -64,7 +73,7 @@ def get_wrapper(module_name, class_name, call_catcher_cls = DefaultCallCatcher):
|
|||
# @param call_catcher_cls : A child class of DefaultCallCatcher designed to be called by the wrapper
|
||||
# @return A class that is a wrapper for towrap
|
||||
def get_class_wrapper(towrap, call_catcher_cls = DefaultCallCatcher):
|
||||
|
||||
|
||||
## @brief Function wrapper
|
||||
#
|
||||
# In fact this class will only be a wrapper for methods
|
||||
|
|
@ -150,5 +159,5 @@ def get_class_wrapper(towrap, call_catcher_cls = DefaultCallCatcher):
|
|||
setattr(wrap, name, make_instance_magix(name))
|
||||
if name not in class_ex:
|
||||
setattr(metawrap, name, make_class_magix(name))
|
||||
|
||||
|
||||
return wrap
|
||||
|
|
|
|||
|
|
@ -28,4 +28,4 @@ migration_options = {
|
|||
em_graph_format = 'png'
|
||||
em_graph_output = '/tmp/em_%s_graph.png'
|
||||
|
||||
acl_bypass = False
|
||||
acl_bypass = True
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue