Django Piston - how can I create custom methods?

Posted by orokusaki on Stack Overflow See other posts from Stack Overflow or by orokusaki
Published on 2010-06-10T22:34:38Z Indexed on 2010/06/10 23:22 UTC
Read the original article Hit count: 228

Filed under:
|
|
|

I put my questions in the code comments for clarity:

from piston.handler import AnonymousBaseHandler


class AnonymousAPITest(AnonymousBaseHandler):
    fields = ('update_subscription',)

    def update_subscription(self, request, months):
        # Do some stuff here to update a subscription based on the
        # number of months provided.
        # How the heck can I call this method?
        return {'msg': 'Your subscription has been updated!'}

    def read(self, request):
        return {
            'msg': 'Why would I need a read() method on a fully custom API?'
        }

© Stack Overflow or respective owner

Related posts about python

Related posts about django