def test_oldstyle_class(self): class Bar(): def test(self): return 1 def __call__(self): return 2 fullyQualifiedName(Bar) fullyQualifiedName(Bar.test) self.assertEqual(Bar._appenlight_name, 'appenlight_client/tests:Bar') self.assertEqual(Bar.test._appenlight_name, 'appenlight_client/tests:Bar.test')
def test_newstyle_class(self): class Foo(object): def test(self): return 1 def __call__(self): return 2 fullyQualifiedName(Foo) fullyQualifiedName(Foo.test) self.assertEqual(Foo._appenlight_name, 'appenlight_client/tests:Foo') self.assertEqual(Foo.test._appenlight_name, 'appenlight_client/tests:Foo.test')
def view_callable_wrapper(self, environ, start_response): try: action = environ['pylons.routes_dict'].get('action', '') controller = fullyQualifiedName(self.__class__) environ['appenlight.view_name'] = "%s.%s" % (controller, action) except Exception, e: pass
def process_view(self, request, view_func, view_args, view_kwargs): try: if 'appenlight.view_name' not in request.environ: request.environ['appenlight.view_name'] = '%s.%s' % (fullyQualifiedName(view_func), request.method) except Exception: request.environ['appenlight.view_name'] = '' return None
def view_callable_wrapper(context, request): appenlight_storage = get_local_storage() view_name = '' try: original_view = getattr(appenlight_callable, '__original_view__') if original_view: view_name = fullyQualifiedName(appenlight_callable) # fix the problem with bound methods, # we have to attach the resolved view name somehow. if is_bound_method(original_view): _original_view = original_view def original_view(context, request): return _original_view(context, request) if not hasattr(original_view, '_appenlight_name'): original_view._appenlight_name = view_name except Exception: raise if 'pyramid/static' in view_name: # normalize static views view_name = 'pyramid/static' if not getattr(appenlight_storage, 'view_name', None): appenlight_storage.view_name = view_name return appenlight_callable(context, request)
def view_callable_wrapper(self, environ, start_response): try: action = environ['pylons.routes_dict'].get('action', '') controller = fullyQualifiedName(self.__class__) environ['appenlight.view_name'] = "%s.%s" % (controller, action) except Exception: pass return appenlight_callable(self, environ, start_response)
def populate_post_vars(sender, **extra): """ This is to handle iterated wsgi.input by werkzeug when we create webob obj parsing environ """ try: view_callable = sender.view_functions[request.endpoint] request.environ['appenlight.view_name'] = fullyQualifiedName(view_callable) except Exception, e: pass
def populate_post_vars(sender, **extra): """ This is to handle iterated wsgi.input by werkzeug when we create webob obj parsing environ """ try: view_callable = sender.view_functions[request.endpoint] request.environ["appenlight.view_name"] = fullyQualifiedName(view_callable) except Exception: pass if request.method in ["POST", "PUT"]: request.environ["appenlight.post_vars"] = request.form else: request.environ["appenlight.post_vars"] = {}
def populate_post_vars(sender, **extra): """ This is to handle iterated wsgi.input by werkzeug when we create webob obj parsing environ """ try: view_callable = sender.view_functions[request.endpoint] request.environ['appenlight.view_name'] = fullyQualifiedName( view_callable) except Exception: pass if request.method in ['POST', 'PUT']: request.environ['appenlight.post_vars'] = request.form else: request.environ['appenlight.post_vars'] = {}
def view_callable_wrapper(context, request): appenlight_storage = get_local_storage() view_name = '' try: original_view = getattr(appenlight_callable, '__original_view__') if original_view: view_name = fullyQualifiedName(appenlight_callable) if not hasattr(original_view, '_appenlight_name'): original_view._appenlight_name = view_name except Exception: raise if 'pyramid/static' in view_name: # normalize static views view_name = 'pyramid/static' if not getattr(appenlight_storage, 'view_name', None): appenlight_storage.view_name = view_name return appenlight_callable(context, request)
def test_func(self): def some_call(): return 1 fullyQualifiedName(some_call) some_call() self.assertEqual(some_call._appenlight_name, 'appenlight_client/tests:some_call')