Skip to content
This repository has been archived by the owner on May 28, 2022. It is now read-only.

Refactor and decouple REST api framework #569

Merged
merged 1 commit into from
Oct 4, 2014

Conversation

dbrenden
Copy link

The recording API endpoints have been moved from the server.py module to a new class called recording.py.

@dideler
Copy link
Member

dideler commented Sep 11, 2014

Great, can you just move the reference to 568 from the title to the PR description? Please put it at the bottom of the description as "Closes #568".

Edit: It's common to use imperative style when using Git. So "Moved recording ..." would be "Move recording ...". There's lots of resources online explaining why this is preferred, if you're interested in learning more.

@dideler dideler added this to the 2014 Fall - UCOSP milestone Sep 11, 2014
@dbrenden dbrenden changed the title #568 WIP: Moved recording API endpoints from server.py to recording.py Moved recording API endpoints from server.py to recording.py Sep 11, 2014
@zxiiro
Copy link
Member

zxiiro commented Sep 11, 2014

Regarding the adding "Closes #568" to the description. You should actually add it to your commit message so that it is linked in the commit message back to the issue.

Your commit message should look something like

Moved recording API endpoints from server.py to recording.py
Some detailed description if neccessary
Closes #568

@dideler
Copy link
Member

dideler commented Sep 12, 2014

You should actually add it to your commit

Yeah, since these commits are squashed that would work (I don't always squash my commits, which is why I rather close it from the PR). Having the reference in both places (i.e. PR description and commit message) would be most convenient, and is simple enough to do.

@dbrenden dbrenden changed the title Moved recording API endpoints from server.py to recording.py Move recording API endpoints from server.py to recording.py Sep 13, 2014
@mtomwing
Copy link
Member

FYI, the build failed because of some flake8 errors:

@RUNNING: flake8 src
src/freeseer/frontend/controller/__init__.py:3:1: F401 'recording' imported but unused
src/freeseer/frontend/controller/recording.py:200:1: W391 blank line at end of file
src/freeseer/frontend/controller/server.py:90:27: F821 undefined name 'ServerError'
@EXIT WITH STATUS: 1
@FAILING...

@mtomwing
Copy link
Member

Looks good. Though there is still room for more refactoring. Like for example since all the endpoints return JSON, it would be nice if there was a decorator that did the transformation automatically and then the endpoint function could simply return a dict.

@dbrenden dbrenden changed the title Move recording API endpoints from server.py to recording.py Refactor and decouple REST api framework Sep 19, 2014
response.status_code = status_code
return response
except HTTPError as e:
return e.message, e.status_code
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to also return a response, but with the HTTPError's status code and message.

Edit: Unless Flask already does that when you return a tuple?

@@ -0,0 +1,32 @@
#!/usr/bin/python
# flake8: noqa
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this might not be needed anymore.

@mtomwing
Copy link
Member

mtomwing commented Oct 3, 2014

On IRC you mentioned that you fixed the last few things I mentioned, but I don't see any changes.

@mtomwing
Copy link
Member

mtomwing commented Oct 3, 2014

Assuming this is already rebased against master, please squash it and I'll do the merge later today.

@dideler
Copy link
Member

dideler commented Oct 3, 2014

@dbrenden Michael's afk right now, but he told me over Hangouts that he wants you to squash it into a single commit since it's all refactoring work.

@dbrenden dbrenden force-pushed the framework-refactor branch 2 times, most recently from bd3fb04 to 131f3ed Compare October 3, 2014 17:14
@mtomwing
Copy link
Member

mtomwing commented Oct 3, 2014

Once the commit message is fixed up I'll merge this. As mentioned on IRC I want a description of what happened, not a list of every single change.

@dbrenden dbrenden force-pushed the framework-refactor branch 2 times, most recently from 27972fc to 50b7376 Compare October 4, 2014 18:16
Broke out recording api resources, and setup/teardown logic from server.py into its own Blueprint.
Implemented decorator in server.py module that carries out http_response object creation and
error handling. This decorator is to be used by all endpoints.

Updated tests to preserve functionality.

Misc logic and style fixes.
@mtomwing mtomwing merged commit b718476 into Freeseer:master Oct 4, 2014
@mtomwing
Copy link
Member

mtomwing commented Oct 4, 2014

Thanks for your contribution!

@dbrenden dbrenden deleted the framework-refactor branch October 4, 2014 18:32
@dideler
Copy link
Member

dideler commented Oct 21, 2014

Looking at the comments, this was originally supposed to close #568 but it never did. @dbrenden what's the status of #568?

@dbrenden
Copy link
Author

The work for #568 is done so it should be closed.

On 21 Oct 2014 07:43, "Dennis Ideler" notifications@github.com wrote:

Looking at the comments, this was originally supposed to close #568 but
it never did. @dbrenden what's the status of #568?


Reply to this email directly or view it on GitHub.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants