From 661935147a055b7c1b35c21292568e10161887dd Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bar=C4=B1=C5=9F=20Metin?= Date: Thu, 23 Sep 2010 11:35:05 +0200 Subject: [PATCH 1/1] don't apply all aspects blindly (although there is only one for the moment...) --- PLC/API.py | 11 +++++++---- aspects/__init__.py | 14 +++++++++----- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/PLC/API.py b/PLC/API.py index 0d228f7..7af3cec 100644 --- a/PLC/API.py +++ b/PLC/API.py @@ -141,11 +141,14 @@ class PLCAPI: else: raise PLCAPIError, "Unsupported database type " + self.config.PLC_DB_TYPE - # Aspects modify the API injecting code before/after method - # calls. As of now we only have aspects for OMF integration, - # that's why we enable aspects only if PLC_OMF is set to true. + # Aspects modify the API by injecting code before, after or + # around method calls. -- http://github.com/baris/pyaspects/blob/master/README + # + # As of now we only have aspects for OMF integration, that's + # why we enable aspects only if PLC_OMF is set to true. if self.config.PLC_OMF_ENABLED: - from aspects import apply_aspects; apply_aspects() + from aspects import apply_omf_aspect + apply_omf_aspect() def callable(self, method): diff --git a/aspects/__init__.py b/aspects/__init__.py index bcce3bc..1df5a9f 100644 --- a/aspects/__init__.py +++ b/aspects/__init__.py @@ -6,11 +6,15 @@ from PLC.Method import Method from aspects.omfaspects import OMFAspect -def apply_aspects(): - - # TEST - #from pyaspects.debuggeraspect import DebuggerAspect - #weave_class_method(DebuggerAspect(out=open("/tmp/all_method_calls.log", "a")), Method, "__call__") +def apply_omf_aspect(): # track all PLC methods to add OMF hooks weave_class_method(OMFAspect(), Method, "__call__") + + +def apply_debugger_aspect(): + # just log all method calls w/ their parameters + from pyaspects.debuggeraspect import DebuggerAspect + weave_class_method(DebuggerAspect(out=open("/tmp/all_method_calls.log", "a")), Method, "__call__") + + -- 2.43.0