#308 Split off the views in their own module
Merged by abompard. Opened by abompard.
abompard/fedora-hubs split-views  into  develop

Download 308.patch

A couple comments:

  • I've created a hubs/views directories, and all views are sub-modules.
  • They are all imported in hubs/app.py as usually done on Flask apps
  • The widget-specific routes are added in hubs/views/__init__.py after importing the other views.

Also, I've added a before_request hook that stores the database session in the flask.g.db variable, and modified the views to use it instead of importing the session from the hubs/app.py file. I did this because otherwise the unit tests would fail when the session was imported, for the following reason: in the setUp method of the main unit test class in hubs/tests/__init__.py, the app is imported and then the session variable is replaced in hubs.app by a dummy database. However, at that point the views have already imported the session from hubs.app, and don't see the replacement, they are thus using the non-dummy database, and tests fail. Using the shared flask.g.db variable solves this problem.

Apart from that, I haven't changed the views.

Looks good to me.

On what basis do we break the views? either similar functionality or area of functionality right?

Currently it's a bit arbitrary, I'd say by area of functionality. I've regrouped the views that are below a hub id in the URL in the same module.

Thanks for reviewing it Sayan. I have a little improvement in the way we discover widget routes, I'll squeeze that in and merge it if it's OK with you all (it's really simple, and add a unit test, yay ;-) ).

1 new commit added

  • Use the registry to discover widget routes

Pull-Request has been merged by abompard

:clap:

Metadata