[WIP] API Explorer back-end

Review Request #7904 — Created Jan. 24, 2016 and discarded

Information

Djblets
master

Reviewers

An API Explorer allows developers to make requests to the Web API from their browsers without having to download XML or JSON files. The API Explorer will display the response as syntax highlighted JSON in order to be understandable and facilitate development and understanding of the Web API.

In the future, users will be able to make POST, PUT and DELETE requests from a provided form and view documentation related to the resource.

This patch focuses on creating an HTML Encoder that will retrieve the payload and determine the resource being accessed.

Modifications to the way the Web API handles requests are also made to ensure that requests can also be made from a web browser.

Tested /api/users/<user_name> and /api/users/ which returned the correct information, in the proper format which displayed correctly in a web browser.

Description From Last Updated

Two blank lines between these.

brenniebrennie

This should have: from __future__ import unicode literals

brenniebrennie

Docstring?

brenniebrennie

Alphabetize.

brenniebrennie

Docstring.

brenniebrennie

Docstring.

brenniebrennie

Docstring.

brenniebrennie

Can we reforamt this as: return render_to_string( 'webapi/explorer.html', { 'payload': o, })

brenniebrennie

Single quotes for strings.

brenniebrennie

Alphabetize these.

brenniebrennie

Can you change all these to use single quotes?

brenniebrennie

Please format this as: if (self.mimetype == 'text/plain' or is_mimetype_a(self.mimetype, 'application/json')): # ...

brenniebrennie

Can you change this to all use single quotes?

brenniebrennie

Single quotes.

brenniebrennie

We already import json above. Lets just use json.dumps.

brenniebrennie

So our import layout is as follows: from __future__ import unicode_literals # Always first. # Standard library imports. import json …

brenniebrennie

'datetime' imported but unused

reviewbotreviewbot

Col: 80 E501 line too long (86 > 79 characters)

reviewbotreviewbot

'Directive' imported but unused

reviewbotreviewbot

Col: 80 E501 line too long (110 > 79 characters)

reviewbotreviewbot

Col: 80 E501 line too long (110 > 79 characters)

reviewbotreviewbot

Col: 80 E501 line too long (113 > 79 characters)

reviewbotreviewbot

Col: 80 E501 line too long (113 > 79 characters)

reviewbotreviewbot

Col: 80 E501 line too long (110 > 79 characters)

reviewbotreviewbot

Col: 80 E501 line too long (110 > 79 characters)

reviewbotreviewbot

Col: 80 E501 line too long (113 > 79 characters)

reviewbotreviewbot

Col: 80 E501 line too long (113 > 79 characters)

reviewbotreviewbot
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        djblets/webapi/responses.py
        djblets/webapi/encoders.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        djblets/webapi/responses.py
        djblets/webapi/encoders.py
    
    
  2. 
      
AD
AD
AD
AD
reviewbot
  1. Tool: PEP8 Style Checker
    Processed Files:
        djblets/util/templatetags/djblets_webapi.py
        djblets/webapi/responses.py
        djblets/webapi/encoders.py
    
    
    
    Tool: Pyflakes
    Processed Files:
        djblets/util/templatetags/djblets_webapi.py
        djblets/webapi/responses.py
        djblets/webapi/encoders.py
    
    
  2. 
      
brennie
  1. 
      
  2. djblets/util/templatetags/djblets_webapi.py (Diff revision 2)
     
     
     
     
    Show all issues

    Two blank lines between these.

  3. Show all issues

    This should have:

    from __future__ import unicode literals
    
  4. Show all issues

    Docstring?

    1. For reference: dblets_webapi.py is going to be removed as it is no longer used.
  5. djblets/webapi/encoders.py (Diff revision 2)
     
     
     
     
     
    Show all issues

    Alphabetize.

  6. djblets/webapi/encoders.py (Diff revision 2)
     
     
    Show all issues

    Docstring.

  7. djblets/webapi/encoders.py (Diff revision 2)
     
     
    Show all issues

    Docstring.

  8. djblets/webapi/encoders.py (Diff revision 2)
     
     
    Show all issues

    Docstring.

  9. djblets/webapi/encoders.py (Diff revision 2)
     
     
     
    Show all issues

    Can we reforamt this as:

    return render_to_string(
        'webapi/explorer.html',
        {
            'payload': o,
        })
    
  10. djblets/webapi/encoders.py (Diff revision 2)
     
     
    Show all issues

    Single quotes for strings.

  11. djblets/webapi/responses.py (Diff revision 2)
     
     
     
    Show all issues

    Alphabetize these.

  12. djblets/webapi/responses.py (Diff revision 2)
     
     
     
     
     
     
    Show all issues

    Can you change all these to use single quotes?

  13. djblets/webapi/responses.py (Diff revision 2)
     
     
     
    Show all issues

    Please format this as:

    if (self.mimetype == 'text/plain' or
        is_mimetype_a(self.mimetype, 'application/json')):
        # ...
    
  14. djblets/webapi/responses.py (Diff revision 2)
     
     
     
     
     
     
     
     
    Show all issues

    Can you change this to all use single quotes?

  15. djblets/webapi/responses.py (Diff revision 2)
     
     
     
     
     
    Show all issues

    Single quotes.

  16. 
      
AD
AD
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        djblets/util/templatetags/djblets_webapi.py
        djblets/webapi/responses.py
        djblets/webapi/encoders.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        djblets/util/templatetags/djblets_webapi.py
        djblets/webapi/responses.py
        djblets/webapi/encoders.py
    
    
  2. 
      
brennie
  1. 
      
  2. djblets/webapi/encoders.py (Diff revision 3)
     
     
    Show all issues

    We already import json above. Lets just use json.dumps.

  3. djblets/webapi/encoders.py (Diff revision 3)
     
     
     
     
     
    Show all issues

    So our import layout is as follows:

    from __future__ import unicode_literals  # Always first.
    
    # Standard library imports.
    import json
    from xml.foo import bar
    
    # 3-rd party library imports.
    from django.conf import settings
    # ...
    from pygments import hilight
    
    # Our current project imports
    from djblets import foobar
    

    We put full imports import foo above partial imports (from foo import bar),

    1. Ohhh, that makes sense thanks.

  4. 
      
AD
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        djblets/util/templatetags/djblets_webapi.py
        djblets/webapi/resources/base.py
        djblets/webapi/responses.py
        djblets/webapi/encoders.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        djblets/util/templatetags/djblets_webapi.py
        djblets/webapi/resources/base.py
        djblets/webapi/responses.py
        djblets/webapi/encoders.py
    
    
  2. 
      
AD
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        djblets/util/templatetags/djblets_webapi.py
        djblets/webapi/resources/base.py
        djblets/webapi/responses.py
        djblets/webapi/encoders.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        djblets/util/templatetags/djblets_webapi.py
        djblets/webapi/resources/base.py
        djblets/webapi/responses.py
        djblets/webapi/encoders.py
    
    
  2. djblets/webapi/encoders.py (Diff revision 5)
     
     
    Show all issues
     'datetime' imported but unused
    
  3. djblets/webapi/encoders.py (Diff revision 5)
     
     
    Show all issues
    Col: 80
     E501 line too long (86 > 79 characters)
    
  4. djblets/webapi/resources/base.py (Diff revision 5)
     
     
    Show all issues
     'Directive' imported but unused
    
  5. 
      
AD
AD
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        djblets/webapi/resources/base.py
        djblets/webapi/responses.py
        djblets/webapi/encoders.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        djblets/webapi/resources/base.py
        djblets/webapi/responses.py
        djblets/webapi/encoders.py
    
    
  2. djblets/webapi/resources/base.py (Diff revision 6)
     
     
    Show all issues
    Col: 80
     E501 line too long (110 > 79 characters)
    
  3. djblets/webapi/resources/base.py (Diff revision 6)
     
     
    Show all issues
    Col: 80
     E501 line too long (110 > 79 characters)
    
  4. djblets/webapi/resources/base.py (Diff revision 6)
     
     
    Show all issues
    Col: 80
     E501 line too long (113 > 79 characters)
    
  5. djblets/webapi/resources/base.py (Diff revision 6)
     
     
    Show all issues
    Col: 80
     E501 line too long (113 > 79 characters)
    
  6. 
      
AD
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        djblets/webapi/resources/base.py
        djblets/webapi/responses.py
        djblets/webapi/encoders.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        djblets/webapi/resources/base.py
        djblets/webapi/responses.py
        djblets/webapi/encoders.py
    
    
  2. djblets/webapi/resources/base.py (Diff revision 7)
     
     
    Show all issues
    Col: 80
     E501 line too long (110 > 79 characters)
    
  3. djblets/webapi/resources/base.py (Diff revision 7)
     
     
    Show all issues
    Col: 80
     E501 line too long (110 > 79 characters)
    
  4. djblets/webapi/resources/base.py (Diff revision 7)
     
     
    Show all issues
    Col: 80
     E501 line too long (113 > 79 characters)
    
  5. djblets/webapi/resources/base.py (Diff revision 7)
     
     
    Show all issues
    Col: 80
     E501 line too long (113 > 79 characters)
    
  6. 
      
AD
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        djblets/webapi/resources/base.py
        djblets/webapi/responses.py
        djblets/webapi/encoders.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        djblets/webapi/resources/base.py
        djblets/webapi/responses.py
        djblets/webapi/encoders.py
    
    
  2. 
      
AD
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        djblets/webapi/resources/base.py
        djblets/webapi/responses.py
        djblets/webapi/encoders.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        djblets/webapi/resources/base.py
        djblets/webapi/responses.py
        djblets/webapi/encoders.py
    
    
  2. 
      
AD
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        djblets/webapi/resources/base.py
        djblets/webapi/responses.py
        djblets/webapi/encoders.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        djblets/webapi/resources/base.py
        djblets/webapi/responses.py
        djblets/webapi/encoders.py
    
    
  2. 
      
AD
david
Review request changed
Status:
Discarded