From 6b1f6a43003bbbd1f6e0410df7088b54ae68181c Mon Sep 17 00:00:00 2001 From: Leandro Roberto Date: Mon, 27 Aug 2018 09:51:00 -0300 Subject: [PATCH] =?UTF-8?q?refatora=20a=20identifica=C3=A7=C3=A3o=20de=20o?= =?UTF-8?q?rigem=20de=20objetos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sapl/translation.py | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/sapl/translation.py b/sapl/translation.py index 264f34dbb..f17da6ef3 100644 --- a/sapl/translation.py +++ b/sapl/translation.py @@ -104,23 +104,25 @@ class ExpressaoTextualManage(object): pass else: - try: - p = item._proxy____args - trace = traceback.extract_stack() - trace.reverse() - while len(trace) > 0 and trace[0].filename != __file__: - trace.pop(0) - - while len(trace) > 0 and trace[0].filename == __file__: - trace.pop(0) - - if trace: - if trace[0].name == '': - msg['proxy'].append(item) - except: - pass + if hasattr(item, '_proxy____args'): + if not self._source_from_object(): + msg['proxy'].append(item) return msg + def _source_from_object(self): + # Falso negativo: expressões dentro de função lambda, mesmo sendo + # atributo de uma classe. + + PROJECT_DIR = settings.PROJECT_DIR + + trace = traceback.extract_stack() + trace.reverse() + while len(trace) > 0 and trace[0].filename.startswith(PROJECT_DIR): + trace.pop(0) + if trace[0].name == '': + return False + return True + def rebuild_expressao(self, et): catalog = self.__catalog value_catalog = catalog['indice'][et.value] @@ -131,7 +133,7 @@ class ExpressaoTextualManage(object): except: pass - def rebuild(self): + """def rebuild(self): global ExpressaoTextual ExpressaoTextual.objects.update(bind=False) @@ -169,7 +171,7 @@ class ExpressaoTextualManage(object): p._proxy____args = (ex.custom,) print(p._proxy____args) except: - print('text') + print('text')""" ExpressaoTextual.objects.filter(bind=False).delete()