Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split up flask.py into multiple files #62

Closed
mitsuhiko opened this issue Jun 3, 2010 · 12 comments
Closed

Split up flask.py into multiple files #62

mitsuhiko opened this issue Jun 3, 2010 · 12 comments

Comments

@mitsuhiko
Copy link
Contributor

Flask gets more and more docstrings and inline documentation comments so that it becomes a quite large file. I would love to split this up for the next release into the following modules:

  • flask - imports the public api
  • flask.ctx - _RequestContext and all kinds of locals
  • flask.app - Config/App
  • flask.module - Module
  • flask.helpers - the helper functions such as url_for, jsonify etc.
  • flask.wrappers - Request/Response/_RequestContext
  • flask.session - Session
@leafstorm
Copy link

I'm fine with that, though once you do that it could be arguable whether Flask is a microframework anymore. On the other hand, it's arguable whether Flask is a microframework now, with the module support making it possible to write arbitrarily large applications.

Still, I think Flask has taken a life of its own beyond its origins as an experiment in microframeworks and GitHub. If this makes it easier to make it more powerful in the future, I'm fine with that. (Though now you might need to make up another microframework for your series of blog posts on how to make a framework with Werkzeug. ^_^)

@mitsuhiko
Copy link
Contributor Author

I'm fine with that, though once you do that it could be arguable whether Flask is a microframework anymore.

I hope the definition of a microframework is not that it is stored in a single file :)

@justquick
Copy link
Contributor

regardless of the definition, i think this is a good idea for readability/edit-ability. im going to have a hack at this in my fork

@mitsuhiko
Copy link
Contributor Author

I'm no longer convinced that this is the way to go though. I can't think of anything else I want to add to Flask. Do you?

@justquick
Copy link
Contributor

not at the moment but im sure other functionality will crop up that you would want to add. in any case, having the file broken down makes reading and maintaining the codebase a little easier in my book. my rule of thumb is after 1K lines its time to break it up and currently flask.py is over 1.5K. If you are interested in taking a look, i have it working in my "module" branch and all unittests pass

http://github.com/justquick/flask/tree/module

@leafstorm
Copy link

Yeah, as a framework, Flask has certainly built itself up to the point where it can stand on its own if there's an active community of extensioneers. (You should definitely use that word in the docs.) The only thing I can think of for 0.5 is being able to create additional exports of static files and reconfigure the template loader, because right now those are pretty hardwired into the core of Flask. If you could do that, it would be just about everything the extensioneers need to make everything else an extension.

As for the issue of splitting into a package itself, I'm fine either way. I don't think Flask is too big for a single module (it's pushing it, though), but there are benefits to the package format - especially if it does grow more.

@leafstorm
Copy link

Oh, and also doing something about issue #33 would be nice.

@mitsuhiko
Copy link
Contributor Author

I think I am considering pulling those changes. However I probably want to rearrange a few things. Are the changes from that branch up to date with the latest in my master?

@justquick
Copy link
Contributor

out on vacation for the 4th of july. ill pull your most recent changes into my fork and fix that json bug you raised then let you know next week

@mitsuhiko
Copy link
Contributor Author

I started a branch for that on my own now based on yours justquick. Same name: http://github.com/mitsuhiko/flask/tree/module

@mitsuhiko
Copy link
Contributor Author

Updated the branch. It now supports a static and template folders per module.

@mitsuhiko
Copy link
Contributor Author

Done.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 14, 2020
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants