Anders Langworthy writes:
> I consider the two best documentation sources for CherryPy to be the
> source itself and your mock Twiseless app.
Even though I snipped most of the conversation so far, this bit
regarding Sylvain's Twiseless app and the source speak volumes for the
future of CherryPy for myself.
The docs are definitely in need of some love, but I believe that doesn't
really speak to the future of CherryPy. No, what CherryPy needs is a
framework! Sort of...
I always feel like CherryPy is the tool that can cut your face off. It
is efficient, powerful, and flexible, yet, using it means you have to
know what you're doing. Once you do know what you're doing, the world
becomes a plethora of powerful tools, encapsulating orthogonal concerns
and plugins managing the nitty gritty details orchestrating your
databases and pools of connections. It is just that getting there is a
tough process.
As others have mentioned, I'd propose is that CherryPy 4.x focus on
separating the concerns.
- Cheroot: The CherryPy WSGI server
- MagicBus: A CherryPy bus to make happily managed proceses
- CherryPy: A raw WSGI library to build frameworks
- *Alamode: A minimalist framework that exposes best practices for data
driven applications
Alamode is a new idea that takes aspects of Twiseless and other best
practices we've found and codifies them into an easy to use
framework. The goal is not to do things like scaffolding or include
crazy widgets, but we would promote and provide tooling for some basic
aspects such as:
- templating
- routing / dispatch
- setting up pools / databases / supporting services
- tools / application plugins
- testing
- async vs. threads vs. processes
This seems like a huge task, but it doesn't seem *that* crazy. The goal
is not to create the perfect framework, but rather provide *a* framework
that describes the means of peeling the layers off to reveal the "raw"
CherryPy framework.
In order to provide an experience different from the default CherryPy,
it would make sense to try and create something similar to Flask's
API. If folks don't like Flask's API, that is OK. Alamode is there to
facilitate people easing into CherryPy and provide a direction for
polishing the harsher aspects of CherryPy as a framework. It would
build on the stable shoulders of the current CherryPy tools. No matter
what the the framework endorses, the goal is to develop CherryPy's
framework and tools.
A new framework seems like it could be fun, but I don't want to take
away from the excitement hiding within cheroot and magicbus. Cheroot
could do well to find a way to adopt different processing models (async
vs. processes vs. threads). Applications often end up doing crazy things
in order to support different models. Imagine being able to configure
something like this:
config = {
# Support a model like flup where we prefork a pool of 8
# processes, each using a pool of 30 threads.
'/': {
'server.serving.model': 'prefork',
'server.serving.threads': 30,
'server.serving.processes': 8,
},
# Use greenlets to provide an async model. We also would provide a
# worker API to handoff non-async friendly tasks to a worker. Here
# my example could use a Celery worker.
'/chat': {
'server.serving.model': 'async',
'server.serving.workers': MyCeleryWorker(),
},
# Yet another model where each request is placed on some sort of
# worker queue, handled by a worker. This could be something like
# Mongrel2's design or something else completely.
'/crunch': {
'server.serving.model': 'worker',
'server.serving.handler': MyZMQWorker,
}
}
# We added a plugin for starting up a pool of workers to listen on a
# zmq pub/sub socket for our /crunch endpoint.
cherrypy.engine.zmqworkers = ZMQWorkerPool(20)
Cheroot seems like it could be refactored to have an extremely pluggable
API to support this kind of model. Hopefully we could have the best of
all worlds with this kind of system.
The magicbus could also gain some more power by providing some
coordination plugins. Small plugins like heartbeats and distributed
event passing could make for some cool features to help answer the
question of orchestrating processes for scale.
Lastly, CherryPy as a library and framework would benefit from all the
above. Tools, plugins and the framework could all have to improve in
their APIs in order to support the new features. Even if the docs are
the only place this happens, we'd have a whole new array of use cases,
blog posts, mailing list conversations and examples to draw from.
If you've read this ramble this far, thanks! I use CherryPy every day at
work and see others avoiding it in favor of tools like Flask. It makes
no sense to me until I sit in their shoes. They see CherryPy as boring
and not worth the investment. What they don't understand is CherryPy has
so many great design elements that make the future of the web (data
driven RESTful services with a fancy HTML / mobile interface on top)
easy to write. I wrote CherryFlask[1] to convince myself that CherryPy
has a future in this regard and once again was proven that it is a well
designed and powerful framework.
Seeing as I'm not a huge contributor to CherryPy, please do not feel I'm
demanding that we do this proposal. I'm happy to head up organizing the
framework aspects assuming others are willing to provide their best
practices. I already started writing an Alamode library based on some
best practices we use for dispatching at work. I have a few ideas for a
consistent configuration model and testing as well. There is also my
CherryFlask experiment that could be expanded upon.
No matter what we do moving forward it would be worthwhile to write up
some sort of a design document and/or mission statement we can loosely
agree upon to help find direction. Again, I'd be happy to act as a
secretary in this regard and keep a spec/design document up to date.
Thanks again for reading my rambling, and as always, thanks for
CherryPy!
Best,
Eric