2

i 'm heavily using django-piston for many of my projects, and i wanted to know if there was any way to monitor calls to a REST API creates using Django-Piston.

Any Signals emitted ? or decorators ? and more importantly if anyone cares ?

Because if some people are dealing with creating REST API in Django, please tell me what you use to monitor them, and if among those some use Piston, maybe we can create something to address this issue :)

++

Olivier.

Olivier Girardot
  • 4,618
  • 6
  • 28
  • 29

1 Answers1

3

You could easily modify one of your handlers to perform custom logging operations or otherwise anytime its called. For example:

from piston import handler
class MyHandler(handler.BaseHandler):
    # blah blah blah

    def create(self, request):
        attrs = self.flatten_dict(request.POST)
        # log stuff here
jathanism
  • 33,067
  • 9
  • 68
  • 86
  • Why not subclass ``BaseHandler`` to do this? – S.Lott Apr 14 '11 at 14:47
  • Isn't that what I did? I'm confused by your suggestion! – jathanism Apr 14 '11 at 16:21
  • 1
    Yes, but. You imply that this is **only** useful in a single modified handler. A better solution would be to (1) create a subclass that logs, call it `LoggingHandler`, and (2) replace all uses of `handler.BaseHandler` with `LoggingHandler`. That way, it wouldn't be a one-off solution but would be an across-the-board solution. – S.Lott Apr 14 '11 at 17:07