Developer's notes ================= Frequently asked questions -------------------------- .. contents:: :local: :backlinks: top Another web framework, are you kidding me? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :doc:`Fiole` is a new challenger in the category of the Python micro-frameworks. As you probably know, there are very good competitors in the market and we don't really need a new one. Read :doc:`the introduction` for a quick outline of the development guidelines for the ``Fiole`` framework. So, how ``Fiole`` is different or similar to the others? * `web.py`_ is the first in the series, created in January 2006 by Aaron Swartz (aaronsw). It has no dependency and it supports old versions of Python, but it is not compatible with Python 3. It is a whole package and it provides additional features, while ``Fiole`` focuses on the essentials. ``web.py`` does not support the decorator syntax, compared with more recent frameworks. * `itty.py`_ is a single-file micro-framework experiment, released on March 2009. It is the first `Sinatra`_-influenced Python framework. However, it does not have public tests, and it does not ship a template engine. * `Bottle`_ is a micro-web framework born on July 2009. ``Fiole`` is similar to ``Bottle`` because it is a single file, inspired by ``itty.py``, with no dependency. It embeds a template engine, which has a syntax close to Bottle's `SimpleTemplate`_. When it comes to the differences, ``Fiole`` template engine is faster, and its source code is smaller and follows the PEP 8 guidelines. On the other side ``Bottle`` has more features. * `Flask`_ is the successor of `Denied`_, born on 1st April 2010. It is a great framework with `a must-read documentation`_. ``Flask`` is a package which depends on `Werkzeug`_ and `Jinja`_. In contrast with it, ``Fiole`` is a single file without external dependencies and with a lot less documentation and less features. ``Flask`` has many extensions. To sum up: * ``Fiole`` is a single file like ``itty.py`` and ``Bottle`` * ``Fiole`` has no dependency, same as ``web.py``, ``itty.py`` and ``Bottle`` * ``Fiole`` embeds a template engine similar to ``web.py`` and ``Bottle`` * ``Fiole`` supports the decorator syntax like ``itty.py``, ``Bottle`` and ``Flask`` * ``Fiole`` supports signed cookies like ``Flask`` does * ``Fiole`` source code is PEP8-compliant like ``itty.py`` and ``Flask`` * ``Fiole`` supports Python 3 like ``Bottle`` and ``Flask`` * ``Fiole`` supports hooks like ``Bottle`` and ``Flask`` * ``Fiole`` *does not* have an extensive documentation like ``Flask`` or ``Bottle`` * ``Fiole`` *does not* provide built-in adapters for every WSGI server like ``itty.py`` or ``Bottle`` Of course the above comparison is partial and subjective. .. _web.py: http://www.infoworld.com/d/application-development/pillars-python-webpy-web-framework-169072 .. _itty.py: http://toastdriven.com/blog/2009/mar/07/itty-sinatra-inspired-micro-framework/ .. _Sinatra: http://sinatrarb.com/ .. _Bottle: http://bottlepy.org/ .. _SimpleTemplate: http://bottlepy.org/docs/dev/stpl.html .. _Werkzeug: http://werkzeug.pocoo.org/ .. _Jinja: http://jinja.pocoo.org/ .. _Denied: http://lucumr.pocoo.org/2010/4/3/april-1st-post-mortem/ .. _Flask: http://flask.pocoo.org/ .. _a must-read documentation: http://flask.pocoo.org/docs/ How much is it extensible? ~~~~~~~~~~~~~~~~~~~~~~~~~~ ``Fiole`` is thread-safe and you can configure more than one application (for complex projects). ``Fiole`` supports hooks which can be registered for each application. Moreover, the components of ``Fiole`` are well thought to allow extensibility. For example the template engine is configurable through attributes, and all the components of the template engine can be subclassed easily. As an alternative, you can use any template engine, such as ``Jinja`` or ``Mako`` instead of the built-in template engine. There's no specific integration between ``Fiole`` and the built-in template ``Engine``. Only the adapter for the ``wsgiref`` server is provided. You can write your own adapter for your preferred WSGI server. There are examples available in ``Bottle`` or ``itty.py`` source code for example. How to make my application really fast? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ First, I am not an expert about this topic. Still, there are various places where you can improve the performance of your web application. Some ideas that come to my mind: * use a reverse proxy (``nginx``, ...) * delegate serving static files to the proxy * enable on-the-fly gzip compression on the proxy * provide the relevant HTTP headers to enable browser caching * replace the WSGI server with a scalable WSGI server which supports concurrency * add server caching * use load-balancing * switch to PyPy The template engine is already very fast. Even so, you can achieve a better performance with small changes: * disable ``default_filters`` and use the ``|str`` filter only when needed * replace the ``escape`` filter with a C implementation (e.g. ``Webext``) However the first thing to do is to benchmark your own application with realistic data in order to know where is the bottleneck before doing any random optimization. I need only the template engine, can you release it? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Indeed, the :doc:`template engine