0

I'm comming from php where $_GET [ 'filter' ] on a url such as example.com/?filter[0][field]=username&filter[0][data][type]=string&filter[0][data][value]=someusername will return an array which can be parsed as:

foreach ( $_GET [ 'filter' ] as $k => $field ) {
    $fieldName = $field [$k] [ 'data' ] [ 'field' ];
    $fieldType = $field [$k] [ 'data' ] [ 'type' ];
    $fieldValue = $field [$k] [ 'data' ] [ 'value' ];
    //        do something with the values
}

Question is....how do I parse them in python in such way?

I cannot access request.args.get( 'filter', None ) but I have results on request.args.get( 'filter[0][field]', None )

2
  • depends entirely on which of the million frameworks you use Commented May 31, 2011 at 14:21
  • if you're using django, please specify in your question Commented May 31, 2011 at 14:26

2 Answers 2

0

http://docs.python.org/library/urlparse.html

urlparse.parse_qs

0

In case you are using the publisher of apache mod python you can specify the arguments in your index function. Let's assume you call

http://yourserver/script.py?name=John&age=36

Then your script.py should look something like

def index (req, name = None, age = None):
    return "Hello %s, you are %s years old." % (name, age)

Same thing for both GET and POST.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.