XML ReviewUI Extension

Review Request #3564 — Created Nov. 26, 2012 and submitted

Information

Review Board
master

Reviewers

A ReviewBoard Extension that demonstrates how to:
- Register a ReviewUI for XML file attachments.
- Register a Mimetype Handler to create XML thumbnails for these attachments.

Currently:
- Both the ReviewUI / Mimetype Handler provide syntax / keyword highlight for XML file via pygments.
Manually tested with ReviewUI integration through Extensions patch: http://reviews.reviewboard.org/r/3565/
- Successfully installed this extension, its ReviewUI, and its Mimetype Handler
- Once installed, "Add Comment" button on XML attachments change to "Review" buttons.
- Once installed, able to review XML file attachments via the "Review" button.
- Once installed, XML file attachments now have thumbnails (if it was not enabled before)
- Color markup for the XML file attachment correctly rendered through pygments.

Description From Last Updated

Should go alphabetical: pygments.formatters then pygments.lexers

KA Karl-L

Any potential for IOError (e.g. file doesn't exist)? This might be handled elsewhere, so feel free to ignore if this …

KA Karl-L

Two spaces between the imports and functions, one space between the functions. Also, not sure if there's any precedent (or …

KA Karl-L

This should go right after "import logging"

AA aam1r

Add a blank line between these two lines

AA aam1r

Add space between these two lines

AA aam1r

This looks a bit long for one line. Try moving the "% PACKAGE" To the next.

chipx86chipx86

Two blank lines.

chipx86chipx86

I don't think we need to subclass everything. What I'd prefer is to just instantiate a URLHook and pass it …

chipx86chipx86

Indentation looks off here.

daviddavid

Same comment.

chipx86chipx86

I think it will read a little easier if you put "extension" on the next line. Also indent only 4 …

daviddavid

Same.

chipx86chipx86

Should inherit from FileAttachmentReviewable. Those defaults are available in that parent class. The only one you introduce is 'rendered', which …

chipx86chipx86

I don't really know why we have this. I'd say unless there's an immediate reason for some dashboard, remove it.

chipx86chipx86

Add two blank lines above each function.

daviddavid

This file should be called xml_review_ui.py

daviddavid

Is this line too long?

daviddavid

This file should be mimetypes.py

daviddavid

This file should be xmlReviewableView.js

daviddavid
SL
KA
  1. Not really familiar with how all the RB extensions work, but this looks pretty good otherwise. I only have a few minor nitpicks and questions (see opened issues).
  2. Show all issues
    Should go alphabetical: pygments.formatters then pygments.lexers
    1. Good call; I think I'm also going to just do "import pygments" instead to keep the both the imports + namespace clean.
  3. Show all issues
    Any potential for IOError (e.g. file doesn't exist)?  This might be handled elsewhere, so feel free to ignore if this is the case.
    1. I'll wrap the whole thing just in case.
  4. xml_review_ui_extension/xml_review_ui_extension/views.py (Diff revision 1)
     
     
     
     
     
     
    Show all issues
    Two spaces between the imports and functions, one space between the functions.
    
    Also, not sure if there's any precedent (or desire to go this way), but Django's class-based generic views would let you add these views inline in your urls.py modules. E.g. in urls.py, the url would look like:
    
    url(r'^$', TemplateView.as_view(template_name="xml_review_ui_extension/configure.html")
    
    along with the appropriate import. See https://docs.djangoproject.com/en/1.4/topics/class-based-views/ for more on class-based views. The project mentors may not be into using them, so if you're interested, double-check before going down that road.
    1. This is actually auto-generated boilerplate code from ./contrib/tools/generate_extension.py as part of the XMLReviewUIExtension.
      
      Thanks for looking over all the code, Karl! I appreciate it =)
  5. 
      
SL
AA
  1. 
      
  2. I think this will all fit in one line
    1. Wow, good eye! Exactly 79 chars =p after joining
  3. 
      
AA
  1. 
      
  2. Show all issues
    This should go right after "import logging"
    1. Had a similar discussion about this here: http://reviews.reviewboard.org/r/3454/#comment7350 - as for "import" vs "from" ordering - there are different conventions used in RB, I'm following the one where within each "group", "from"'s are subgrouped together alphabetically, and then "import"'s are subgrouped together alphabetically.
  3. Show all issues
    Add a blank line between these two lines
    1. Extension boilerplate generator generated code: fix style issue here only bandaids & obscures source of the issue.
  4. Show all issues
    Add space between these two lines
    1. Also boilerplate generator generated code, see comment as above.
  5. 
      
SL
chipx86
  1. This looks cool, but just like the markdown change, we'll need some form of commenting.
  2. 
      
SL
SL
david
  1. What configuration are you planning on adding?
    1. I made it configurable so the infrastructure is there in the event that this extension needs to be expanded in the future to do more than syntax highlighting. Should I remove it so there's less ambiguity about what's currently configurable about the extension (of which nothing is planned to be configurable)
    2. I think it's generally best to keep things simple. Don't add more than you need until you need it (so long as you don't code yourself into a corner).
  2. xml_review_ui_extension/xml_review_ui_extension/XMLReviewUI.py (Diff revision 5)
     
     
     
     
     
     
     
     
    Because 1.7 requires Python 2.5 and newer, we can now use the "with" structure here to make this nicer.
  3. Show all issues
    Indentation looks off here.
  4. Show all issues
    I think it will read a little easier if you put "extension" on the next line. Also indent only 4 spaces from the "super"
  5. xml_review_ui_extension/xml_review_ui_extension/views.py (Diff revision 5)
     
     
     
     
     
     
    Show all issues
    Add two blank lines above each function.
  6. 
      
chipx86
  1. 
      
  2. xml_review_ui_extension/setup.py (Diff revision 5)
     
     
    Show all issues
    This looks a bit long for one line. Try moving the "% PACKAGE" To the next.
  3. Show all issues
    Two blank lines.
  4. Show all issues
    I don't think we need to subclass everything. What I'd prefer is to just instantiate a URLHook and pass it the patterns. Keeps things simpler.
  5. Show all issues
    Same comment.
  6. Show all issues
    Same.
  7. Show all issues
    Should inherit from FileAttachmentReviewable.
    
    Those defaults are available in that parent class. The only one you introduce is 'rendered', which should be the only entry in here.
    1. Removed this class / file after IRC discussion with ChipX86: to use RB.FileAttachmentReviewable in the template directly instead, since RB.XMLReviewable adds nothing new except for maybe a default value for rendered.
  8. Show all issues
    I don't really know why we have this. I'd say unless there's an immediate reason for some dashboard, remove it.
  9. 
      
SL
SL
SL
david
  1. This is looking pretty good. My major comments are about the naming of the files, which doesn't match our conventions.
  2. Show all issues
    This file should be called xml_review_ui.py
  3. Show all issues
    Is this line too long?
    1. I had it as 2 lines before, but aam1r had a sharp eye and suggested to put it on one line.
      
      I double-checked and the last ) is on the 79th column.
  4. Show all issues
    This file should be mimetypes.py
  5. Show all issues
    This file should be xmlReviewableView.js
  6. 
      
SL
chipx86
  1. So this looks good, but it's not the right repository for it. Any extensions should go in rb-extension-pack. I'm moving it to there and committing!
  2. 
      
SL
Review request changed
Status:
Completed
Change Summary:
Pushed to rb-extension-pack master (31b3292)